Score:-4

How can I use custom HTML/CSS in the login page?

kw flag

I have custom HTML and CSS code for a login page. I want to customize my site's login form to look like the custom login page I have. How can I customize the default login page with the HTML and CSS code I have? All similar questions I saw were either outdated or didn't address this "custom HTML/CSS code" aspect.

id flag
Use Drupal's theme system. Turning on theme debugging will tell you exactly which templates to implement if you are unsure.
levente.nas avatar
kw flag
Ah I see. Thanks!
Score:1
US flag
user106880

You can write a custom module to use attaching a library to a form

As forms are just render arrays, attaching a library works just the same:

/**
 * Implements hook_form_alter().
 */

    function yourmodule_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
      if ($form_id == 'article_node_form') { {
          $form['#attached']['library'][] = 'yourmodule/yourlibrary';
        }
    }

Here is the official documentation with an anchor to the part that explain how to add it to a form : https://www.drupal.org/docs/creating-custom-modules/adding-stylesheets-css-and-javascript-js-to-a-drupal-module#s-attaching-a-library-to-a-form

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.