diff --git a/root.services.yml b/root.services.yml
new file mode 100644
index 0000000..9d3f490
--- /dev/null
+++ b/root.services.yml
@@ -0,0 +1,5 @@
+
+services:
+  Drupal\root\Hook\RootHooks:
+    class: Drupal\root\Hook\RootHooks
+    autowire: true
diff --git a/root.theme b/root.theme
index f26f18c..9fb1e8a 100644
--- a/root.theme
+++ b/root.theme
@@ -4,7 +4,8 @@
  * @file
  * Functions to support theming in Seeds Root theme.
  */
-
+use Drupal\Core\Hook\Attribute\LegacyHook;
+use Drupal\root\Hook\RootHooks;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Component\Serialization\Json;
 use Drupal\root\RootEditContent;
@@ -12,19 +13,10 @@ use Drupal\root\RootEditContent;
 /**
  * Implements hook_preprocess_HOOK() for HTML document templates.
  */
-function root_preprocess_html(&$variables) {
-  $variables['attributes']['class'][] = 'seeds-root';
-  // Edit form? Use the new root Edit form layout.
-  if (\Drupal::classResolver(RootEditContent::class)->isContentForm()) {
-    $variables['attributes']['class'][] = 'root--edit-form';
-  }
-  // Load rtl style.
-  if ($variables['html_attributes']['dir'] == 'ltr') {
-    $variables['page']['#attached']['library'][] = 'root/ltr';
-  } else {
-    /* Comment out and change "root" to enable rtl style  */
-    $variables['page']['#attached']['library'][] = 'root/rtl';
-  }
+#[LegacyHook]
+function root_preprocess_html(&$variables)
+{
+    \Drupal::service(RootHooks::class)->preprocessHtml($variables);
 }
 
 /**
diff --git a/src/Hook/RootHooks.php b/src/Hook/RootHooks.php
new file mode 100644
index 0000000..d28bfb0
--- /dev/null
+++ b/src/Hook/RootHooks.php
@@ -0,0 +1,33 @@
+<?php
+
+namespace Drupal\root\Hook;
+
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\Component\Serialization\Json;
+use Drupal\root\RootEditContent;
+use Drupal\Core\Hook\Attribute\Hook;
+/**
+ * Hook implementations for root.
+ */
+class RootHooks
+{
+    /**
+     * Implements hook_preprocess_HOOK() for HTML document templates.
+     */
+    #[Hook('preprocess_html')]
+    public function preprocessHtml(&$variables)
+    {
+        $variables['attributes']['class'][] = 'seeds-root';
+        // Edit form? Use the new root Edit form layout.
+        if (\Drupal::classResolver(\Drupal\root\RootEditContent::class)->isContentForm()) {
+            $variables['attributes']['class'][] = 'root--edit-form';
+        }
+        // Load rtl style.
+        if ($variables['html_attributes']['dir'] == 'ltr') {
+            $variables['page']['#attached']['library'][] = 'root/ltr';
+        } else {
+            /* Comment out and change "root" to enable rtl style  */
+            $variables['page']['#attached']['library'][] = 'root/rtl';
+        }
+    }
+}
diff --git a/src/RootEditContent.php b/src/RootEditContent.php
index 1ce103a..daba250 100644
--- a/src/RootEditContent.php
+++ b/src/RootEditContent.php
@@ -86,7 +86,7 @@ class RootEditContent implements ContainerInjectionInterface {
    * @param string $form_id
    *   The form id.
    */
-  public function isContentForm(array $form = NULL, FormStateInterface $form_state = NULL, $form_id = '') {
+  public function isContentForm(?array $form = NULL, ?FormStateInterface $form_state = NULL, $form_id = '') {
     $is_content_form = FALSE;
 
     // Get route name.
