diff --git a/composer.json b/composer.json
index f151637..3d4c78d 100644
--- a/composer.json
+++ b/composer.json
@@ -18,7 +18,7 @@
     },
     "minimum-stability": "dev",
     "require": {
-        "drupal/core": "^8.8 || ^9 || ^10 || ^11"
+        "drupal/core": "^11.1 || ^12"
     },
     "autoload": {
         "psr-4": {
diff --git a/patterncss.info.yml b/patterncss.info.yml
index 97d8b03..a477287 100644
--- a/patterncss.info.yml
+++ b/patterncss.info.yml
@@ -2,4 +2,4 @@ name: 'PatternCSS'
 description: 'Integrates Pattern.css, is a CSS only library to fill your empty background with beautiful patterns.'
 type: module
 package: User interface
-core_version_requirement: ^8.8 || ^9 || ^10 || ^11
+core_version_requirement: ^11.1 || ^12
diff --git a/patterncss.module b/patterncss.module
index 96bec41..a942e97 100644
--- a/patterncss.module
+++ b/patterncss.module
@@ -14,33 +14,16 @@
  * Copyright (C) 2020-2023 Jitender Bansal
  */
 
-use Drupal\Core\Installer\InstallerKernel;
+use Drupal\Core\Hook\Attribute\LegacyHook;
+use Drupal\patterncss\Hook\PatterncssHooks;
 use Drupal\Core\Routing\RouteMatchInterface;
 
 /**
  * Implements hook_help().
  */
+#[LegacyHook]
 function patterncss_help($route_name, RouteMatchInterface $route_match) {
-  switch ($route_name) {
-    case 'help.page.patterncss':
-      $output  = '<h3>' . t('About') . '</h3>';
-      $output .= '<p>' . t('The PatternCSS is a module that aims to integrate <a href=":animate_library">Pattern.css</a> library with Drupal. Pattern.css is a library of ready-to-use, cross-browser animations for use in your web projects. Great for emphasis, home pages, sliders, and attention-guiding hints. PatternCSS module allows you to quickly attach Pattern.css library in your page.', [':animate_library' => 'https://animate.style/']) . '</p>';
-      $output .= '<h3>' . t('Uses') . '</h3>';
-      $output .= '<dl>';
-      $output .= '<dt>' . t('Basic usage') . '</dt>';
-      $output .= '<dd><p>' . t('Add the class pattern-checks-sm to an element, along with any of the pattern names like dots, grid etc. (do not forget the pattern- prefix and pattern size e.g -md or -sm suffix!)') . '</p>';
-      $output .= '<pre><code>';
-      $output .= '&lt;div class="pattern-checks-sm bg-blue white"&gt;An animated element&lt;/div&gt;' . "\n";
-      $output .= '</code></pre></dd>';
-      $output .= '<dt>' . t('Usage with Javascript') . '</dt>';
-      $output .= '<dd><p>' . t('You can do a whole bunch of other stuff with pattern.css when you combine it with Javascript.') . '</p>';
-      $output .= '<pre>';
-      $output .= "const element = document.querySelector('.my-element');" . "\n";
-      $output .= "element.classList.add('pattern-checks-sm', 'bg-blue');";
-      $output .= '</pre></dd>';
-      $output .= '</dl>';
-      return $output;
-  }
+  return \Drupal::service(PatterncssHooks::class)->help($route_name, $route_match);
 }
 
 /**
@@ -51,7 +34,7 @@ function patterncss_help($route_name, RouteMatchInterface $route_match) {
  */
 function patterncss_check_installed() {
   // Throw error if Pattern.css library file not found.
-  /** @var Drupal\Core\Asset\LibraryDiscovery $library_discovery */
+  /** @var \Drupal\Core\Asset\LibraryDiscoveryInterface $library_discovery */
   $library_discovery = \Drupal::service('library.discovery');
   $library_exists = FALSE;
   $definition = $library_discovery->getLibraryByName('patterncss', 'pattern.css');
@@ -67,24 +50,9 @@ function patterncss_check_installed() {
 /**
  * Implements hook_page_attachments().
  */
+#[LegacyHook]
 function patterncss_page_attachments(array &$attachments) {
-  // Don't add the Library during installation.
-  if (InstallerKernel::installationAttempted()) {
-    return;
-  }
-
-  // Check first PatternCSS UI module is not installed and library not exists.
-  $moduleHandler = \Drupal::service('module_handler');
-  if (!$moduleHandler->moduleExists('patterncss_ui')) {
-    // Check if Pattern.css library not exist in local library then
-    // attach the latest version of Pattern.css automatically from CDN.
-    if (patterncss_check_installed()) {
-      $attachments['#attached']['library'][] = 'patterncss/pattern.min.css';
-    }
-    else {
-      $attachments['#attached']['library'][] = 'patterncss/pattern.min.cdn';
-    }
-  }
+  \Drupal::service(PatterncssHooks::class)->pageAttachments($attachments);
 }
 
 /**
diff --git a/patterncss.services.yml b/patterncss.services.yml
new file mode 100644
index 0000000..4effbc9
--- /dev/null
+++ b/patterncss.services.yml
@@ -0,0 +1,5 @@
+
+services:
+  Drupal\patterncss\Hook\PatterncssHooks:
+    class: Drupal\patterncss\Hook\PatterncssHooks
+    autowire: true
diff --git a/patterncss_ui/patterncss_ui.info.yml b/patterncss_ui/patterncss_ui.info.yml
index 076b5a1..c40b499 100644
--- a/patterncss_ui/patterncss_ui.info.yml
+++ b/patterncss_ui/patterncss_ui.info.yml
@@ -3,6 +3,6 @@ description: 'Pattern.css library configuration UI.'
 type: module
 package: User interface
 configure: patterncss.admin
-core_version_requirement: ^8.8 || ^9 || ^10 || ^11
+core_version_requirement: ^11.1 || ^12
 dependencies:
   - patterncss:patterncss
diff --git a/patterncss_ui/patterncss_ui.module b/patterncss_ui/patterncss_ui.module
index 8f7f388..71ac6ec 100644
--- a/patterncss_ui/patterncss_ui.module
+++ b/patterncss_ui/patterncss_ui.module
@@ -14,113 +14,26 @@
  * Copyright (C) 2020-2023 Jitender Bansal
  */
 
-use Drupal\Core\Installer\InstallerKernel;
-use Drupal\Core\Link;
+use Drupal\Core\Hook\Attribute\LegacyHook;
+use Drupal\patterncss_ui\Hook\PatterncssUiHooks;
 use Drupal\Core\Routing\RouteMatchInterface;
-use Drupal\Core\Url;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpFoundation\RequestStack;
 
 /**
  * Implements hook_help().
  */
+#[LegacyHook]
 function patterncss_ui_help($route_name, RouteMatchInterface $route_match) {
-  switch ($route_name) {
-    case 'help.page.patterncss_ui':
-      return '<p>' . t('<a href=":patterncss_url">Pattern.css</a> is a CSS only library to fill your empty background with beautiful patterns. see the <a href=":patterncss_github">Pattern.css GitHub</a> for usage and Configure on <a href=":patterncss_config">PatternCSS module settings</a> to put CSS selectors you want to add pattern.', [
-        ':patterncss_url'    => 'https://github.com/bansal/pattern.css',
-        ':patterncss_github' => 'https://github.com/animate-css/pattern.css',
-        ':patterncss_config' => Link::createFromRoute(t('settings page'), 'patterncss.settings')->toString(),
-      ]) . '</p>';
-  }
+  return \Drupal::service(PatterncssUiHooks::class)->help($route_name, $route_match);
 }
 
 /**
  * Implements hook_page_attachments().
  */
+#[LegacyHook]
 function patterncss_ui_page_attachments(array &$attachments) {
-  // Don't add the library during installation.
-  if (InstallerKernel::installationAttempted()) {
-    return;
-  }
-
-  // Load the Pattern.css configuration settings.
-  $config = \Drupal::config('patterncss.settings');
-
-  // Attach Pattern.css to pages with chosen method.
-  $method = $config->get('method') == 'cdn' ? '.cdn' : '.css';
-
-  // Checking the path to load Pattern.css for demo examples,
-  // It's just in Patterncss configuration.
-  $currentPath = Url::fromRoute('<current>')->toString();
-  $settingPath = Url::fromRoute('patterncss.admin')->toString() . '/*';
-
-  if (\Drupal::service('path.matcher')->matchPath($currentPath, $settingPath)) {
-    $attachments['#attached']['library'][] = 'patterncss/pattern' . $method;
-
-    $options = $config->get('options');
-    $options['segment'] = $config->get('segment');
-    $options['selector'] = '#edit-preview .details-wrapper';
-
-    // Attach Pattern.css for examples.
-    $attachments['#attached']['drupalSettings']['patterncss']['sample'] = $options;
-
-    return;
-  }
-
-  // Don't include Pattern.css library if the user has
-  // opted out of loading it or excluded from specified paths.
-  if (!$config->get('load') || !_patterncss_ui_check_url()) {
-    return TRUE;
-  }
-
-  // Check for load development and production version.
-  $variant = $config->get('build.variant') == '1' ? '.min' : '';
-
-  // Attach dynamic Pattern.css library by chosen variant and method.
-  $attachments['#attached']['library'][] = 'patterncss/pattern' . $variant . $method;
-
-  // Get selectors from config.
-  $options = $config->get('options');
-  $patterns = [];
-
-  // Load enabled animate selectors from database.
-  $results = \Drupal::service('patterncss.pattern_manager')->loadPattern()->fetchAll();
-  if (count($results)) {
-    $selectors = [];
-    foreach ($results as $pattern) {
-      $pattern_options = unserialize($pattern->options, ['allowed_classes' => FALSE]);
-
-      $selectors[] = $pattern->selector;
-      $patterns[$pattern->pid] = ['selector' => $pattern->selector] + ['segment' => $pattern->segment] + $pattern_options;
-    }
-
-    // Merge global selectors from config with database selectors.
-    if (count($config->get('options.selector')) && count($selectors)) {
-      $options['selector'] = array_diff($options['selector'], $selectors);
-
-      // Attach config selectors after merge if there were any left.
-      if (count($options['selector'])) {
-        array_unshift($patterns, $options);
-      }
-    }
-  }
-  else {
-    // If global selectors are set, get the selectors from the configuration.
-    if (count($config->get('options.selector'))) {
-      $patterns = [$options];
-    }
-  }
-
-  // If there is animate selectors, then the init file
-  // with options will be added to the page.
-  if (count($patterns)) {
-    // Export settings.
-    $attachments['#attached']['drupalSettings']['patterncss']['elements'] = $patterns;
-
-    // Init animate.
-    $attachments['#attached']['library'][] = 'patterncss_ui/pattern-init';
-  }
+  return \Drupal::service(PatterncssUiHooks::class)->pageAttachments($attachments);
 }
 
 /**
@@ -134,7 +47,7 @@ function patterncss_ui_page_attachments(array &$attachments) {
  * @return bool
  *   TRUE if Pattern.css should be active for the current page.
  */
-function _patterncss_ui_check_url(Request $request = NULL, RequestStack $request_stack = NULL) {
+function _patterncss_ui_check_url(?Request $request = NULL, ?RequestStack $request_stack = NULL) {
   if (!isset($request)) {
     $request = \Drupal::request();
   }
diff --git a/patterncss_ui/patterncss_ui.services.yml b/patterncss_ui/patterncss_ui.services.yml
index b1fe484..ed07ff3 100644
--- a/patterncss_ui/patterncss_ui.services.yml
+++ b/patterncss_ui/patterncss_ui.services.yml
@@ -4,3 +4,7 @@ services:
     arguments: [ '@database' ]
     tags:
       - { name: backend_overridable }
+
+  Drupal\patterncss_ui\Hook\PatterncssUiHooks:
+    class: Drupal\patterncss_ui\Hook\PatterncssUiHooks
+    autowire: true
diff --git a/patterncss_ui/src/Hook/PatterncssUiHooks.php b/patterncss_ui/src/Hook/PatterncssUiHooks.php
new file mode 100644
index 0000000..580531c
--- /dev/null
+++ b/patterncss_ui/src/Hook/PatterncssUiHooks.php
@@ -0,0 +1,110 @@
+<?php
+
+namespace Drupal\patterncss_ui\Hook;
+
+use Drupal\Core\Url;
+use Drupal\Core\Installer\InstallerKernel;
+use Drupal\Core\Link;
+use Drupal\Core\Routing\RouteMatchInterface;
+use Drupal\Core\Hook\Attribute\Hook;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
+
+/**
+ * Hook implementations for patterncss_ui.
+ */
+class PatterncssUiHooks {
+  use StringTranslationTrait;
+
+  /**
+   * Implements hook_help().
+   */
+  #[Hook('help')]
+  public function help($route_name, RouteMatchInterface $route_match) {
+    switch ($route_name) {
+      case 'help.page.patterncss_ui':
+        return '<p>' . $this->t('<a href=":patterncss_url">Pattern.css</a> is a CSS only library to fill your empty background with beautiful patterns. see the <a href=":patterncss_github">Pattern.css GitHub</a> for usage and Configure on <a href=":patterncss_config">PatternCSS module settings</a> to put CSS selectors you want to add pattern.', [
+          ':patterncss_url' => 'https://github.com/bansal/pattern.css',
+          ':patterncss_github' => 'https://github.com/animate-css/pattern.css',
+          ':patterncss_config' => Link::createFromRoute($this->t('settings page'), 'patterncss.settings')->toString(),
+        ]) . '</p>';
+    }
+  }
+
+  /**
+   * Implements hook_page_attachments().
+   */
+  #[Hook('page_attachments')]
+  public function pageAttachments(array &$attachments) {
+    // Don't add the library during installation.
+    if (InstallerKernel::installationAttempted()) {
+      return;
+    }
+    // Load the Pattern.css configuration settings.
+    $config = \Drupal::config('patterncss.settings');
+    // Attach Pattern.css to pages with chosen method.
+    $method = $config->get('method') == 'cdn' ? '.cdn' : '.css';
+    // Checking the path to load Pattern.css for demo examples,
+    // It's just in Patterncss configuration.
+    $currentPath = Url::fromRoute('<current>')->toString();
+    $settingPath = Url::fromRoute('patterncss.admin')->toString() . '/*';
+    if (\Drupal::service('path.matcher')->matchPath($currentPath, $settingPath)) {
+      $attachments['#attached']['library'][] = 'patterncss/pattern' . $method;
+      $options = $config->get('options');
+      $options['segment'] = $config->get('segment');
+      $options['selector'] = '#edit-preview .details-wrapper';
+      // Attach Pattern.css for examples.
+      $attachments['#attached']['drupalSettings']['patterncss']['sample'] = $options;
+      return;
+    }
+    // Don't include Pattern.css library if the user has
+    // opted out of loading it or excluded from specified paths.
+    if (!$config->get('load') || !_patterncss_ui_check_url()) {
+      return TRUE;
+    }
+    // Check for load development and production version.
+    $variant = $config->get('build.variant') == '1' ? '.min' : '';
+    // Attach dynamic Pattern.css library by chosen variant and method.
+    $attachments['#attached']['library'][] = 'patterncss/pattern' . $variant . $method;
+    // Get selectors from config.
+    $options = $config->get('options');
+    $patterns = [];
+    // Load enabled animate selectors from database.
+    $results = \Drupal::service('patterncss.pattern_manager')->loadPattern()->fetchAll();
+    if (count($results)) {
+      $selectors = [];
+      foreach ($results as $pattern) {
+        $pattern_options = unserialize($pattern->options, [
+          'allowed_classes' => FALSE,
+        ]);
+        $selectors[] = $pattern->selector;
+        $patterns[$pattern->pid] = [
+          'selector' => $pattern->selector,
+        ] + [
+          'segment' => $pattern->segment,
+        ] + $pattern_options;
+      }
+      // Merge global selectors from config with database selectors.
+      if (count($config->get('options.selector')) && count($selectors)) {
+        $options['selector'] = array_diff($options['selector'], $selectors);
+        // Attach config selectors after merge if there were any left.
+        if (count($options['selector'])) {
+          array_unshift($patterns, $options);
+        }
+      }
+    }
+    elseif (count($config->get('options.selector'))) {
+      $patterns = [
+        $options,
+      ];
+    }
+    // If there is animate selectors, then the init file
+    // with options will be added to the page.
+    if (count($patterns)) {
+      // Export settings.
+      $attachments['#attached']['drupalSettings']['patterncss']['elements'] = $patterns;
+      // Init animate.
+      $attachments['#attached']['library'][] = 'patterncss_ui/pattern-init';
+    }
+  }
+
+}
diff --git a/src/Hook/PatterncssHooks.php b/src/Hook/PatterncssHooks.php
new file mode 100644
index 0000000..7deff36
--- /dev/null
+++ b/src/Hook/PatterncssHooks.php
@@ -0,0 +1,68 @@
+<?php
+
+namespace Drupal\patterncss\Hook;
+
+use Drupal\Core\Installer\InstallerKernel;
+use Drupal\Core\Routing\RouteMatchInterface;
+use Drupal\Core\Hook\Attribute\Hook;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
+
+/**
+ * Hook implementations for patterncss.
+ */
+class PatterncssHooks {
+  use StringTranslationTrait;
+
+  /**
+   * Implements hook_help().
+   */
+  #[Hook('help')]
+  public function help($route_name, RouteMatchInterface $route_match) {
+    switch ($route_name) {
+      case 'help.page.patterncss':
+        $output = '<h3>' . $this->t('About') . '</h3>';
+        $output .= '<p>' . $this->t('The PatternCSS is a module that aims to integrate <a href=":animate_library">Pattern.css</a> library with Drupal. Pattern.css is a library of ready-to-use, cross-browser animations for use in your web projects. Great for emphasis, home pages, sliders, and attention-guiding hints. PatternCSS module allows you to quickly attach Pattern.css library in your page.', [
+          ':animate_library' => 'https://animate.style/',
+        ]) . '</p>';
+        $output .= '<h3>' . $this->t('Uses') . '</h3>';
+        $output .= '<dl>';
+        $output .= '<dt>' . $this->t('Basic usage') . '</dt>';
+        $output .= '<dd><p>' . $this->t('Add the class pattern-checks-sm to an element, along with any of the pattern names like dots, grid etc. (do not forget the pattern- prefix and pattern size e.g -md or -sm suffix!)') . '</p>';
+        $output .= '<pre><code>';
+        $output .= '&lt;div class="pattern-checks-sm bg-blue white"&gt;An animated element&lt;/div&gt;' . "\n";
+        $output .= '</code></pre></dd>';
+        $output .= '<dt>' . $this->t('Usage with Javascript') . '</dt>';
+        $output .= '<dd><p>' . $this->t('You can do a whole bunch of other stuff with pattern.css when you combine it with Javascript.') . '</p>';
+        $output .= '<pre>';
+        $output .= "const element = document.querySelector('.my-element');" . "\n";
+        $output .= "element.classList.add('pattern-checks-sm', 'bg-blue');";
+        $output .= '</pre></dd>';
+        $output .= '</dl>';
+        return $output;
+    }
+  }
+
+  /**
+   * Implements hook_page_attachments().
+   */
+  #[Hook('page_attachments')]
+  public function pageAttachments(array &$attachments) {
+    // Don't add the Library during installation.
+    if (InstallerKernel::installationAttempted()) {
+      return;
+    }
+    // Check first PatternCSS UI module is not installed and library not exists.
+    $moduleHandler = \Drupal::service('module_handler');
+    if (!$moduleHandler->moduleExists('patterncss_ui')) {
+      // Check if Pattern.css library not exist in local library then
+      // attach the latest version of Pattern.css automatically from CDN.
+      if (patterncss_check_installed()) {
+        $attachments['#attached']['library'][] = 'patterncss/pattern.min.css';
+      }
+      else {
+        $attachments['#attached']['library'][] = 'patterncss/pattern.min.cdn';
+      }
+    }
+  }
+
+}
