Front-end theming
Two parts of Nahnu Login Shield show up inside your site’s theme, not in the WordPress admin: the Login & security panel (also available with the [nahnls_account_security] shortcode) and the two-factor challenge on the WooCommerce My Account page. This topic shows how to make them match your brand with a few lines of CSS, how to switch on dark mode, and how to turn the plugin’s styling off completely.
What you can style#
| Piece | Stylesheet | Handle | Wrapper class |
|---|---|---|---|
Login & security panel, and the [nahnls_account_security] shortcode | assets/css/account-panel.css | nahnls-account-panel | .nahnls-ap |
| 2FA challenge on WooCommerce My Account | assets/css/2fa-front.css | nahnls-2fa-front | .nahnls-2fa-wc |
Both stylesheets are driven by CSS custom properties (variables). Change the variables, and the whole piece follows.
Change the colours, radius and font#
The variables are defined on the two wrapper classes with zero specificity (inside :where()). So any rule that targets the wrapper wins. Add this to your theme’s CSS, Customizer “Additional CSS”, or a snippet:
.nahnls-ap,
.nahnls-2fa-wc {
--nahnls-primary: var(--my-brand);
--nahnls-radius: 4px;
} Set the variables on the wrapper classes, not on :root. The wrapper’s own defaults would hide a value set on an ancestor.
The variables
| Variable | Default | Used for |
|---|---|---|
--nahnls-primary | #2563eb | Primary buttons, links (plain panel), switches, card icons, focus ring, checkbox accent, info notice tint |
--nahnls-on-primary | #fff | Text on primary buttons |
--nahnls-surface | #fff | Cards, inputs, table, backup-code and QR backgrounds |
--nahnls-surface-2 | #f3f4f6 | Secondary buttons, backup-code box |
--nahnls-border | #e5e7eb | Borders, dividers, secondary button hover |
--nahnls-text | #1f2937 | Text in the plain panel, and the base for strong borders and notice text |
--nahnls-muted | #6b7280 | Secondary text and the “Not set up” pill |
--nahnls-success | #15803d | The “On” pill, active row icons and success notices |
--nahnls-danger | #b91c1c | Remove and turn-off buttons, error notices, the passkey error message |
--nahnls-radius | 8px | Boxes and the row lists. Cards use 1.5 times this, inputs, buttons and notices 0.75 times, and code chips 0.5 times. Pills and switches are always fully rounded |
--nahnls-font | inherit | All text |
--nahnls-font-mono | ui-monospace, SFMono-Regular, Menlo, Consolas, monospace | Codes, the secret key and code inputs |
Notice backgrounds, borders and text are calculated from --nahnls-danger, --nahnls-success and --nahnls-primary with color-mix(), so they follow your palette and get darker in dark mode.
Variables that start with --_nahnls- are internal. They may change, so don’t use them.
Example: match a brand
.nahnls-ap,
.nahnls-2fa-wc {
--nahnls-primary: #7c3aed;
--nahnls-on-primary: #ffffff;
--nahnls-radius: 12px;
--nahnls-font: "Inter", system-ui, sans-serif;
} Dark mode#
The plugin’s dark colours are used when any of these is true:
.nahnls-darkis on the wrapper or any ancestor.[data-theme="dark"]is on the wrapper or any ancestor (for example<html data-theme="dark">)..nahnls-auto-darkis on the wrapper or an ancestor, the visitor’s system prefers dark, and no ancestor has[data-theme="light"].
Without one of these, the dark colours never apply, even when the visitor’s system prefers dark. If your site has its own dark-mode switch, add .nahnls-dark or data-theme="dark" when it is on. If you want the plugin to follow the visitor’s system setting, add nahnls-auto-dark to an ancestor, such as <body>.
<body class="nahnls-auto-dark"> Dark values:
| Variable | Dark value |
|---|---|
--nahnls-primary | #60a5fa |
--nahnls-on-primary | #0b1220 |
--nahnls-surface | #111827 |
--nahnls-surface-2 | #1f2937 |
--nahnls-border | #374151 |
--nahnls-text | #f3f4f6 |
--nahnls-muted | #9ca3af |
--nahnls-success | #4ade80 |
--nahnls-danger | #f87171 |
The wrapper also gets color-scheme: dark, so form controls inside it follow.
To use your own dark colours, set the variables inside your dark selector:
[data-theme="dark"] .nahnls-ap,
[data-theme="dark"] .nahnls-2fa-wc {
--nahnls-primary: #a78bfa;
--nahnls-surface: #0f0f14;
} The WooCommerce version#
When the panel is shown inside WooCommerce My Account (.nahnls-ap--wc) and on the 2FA challenge, most things come from your WooCommerce theme: text, buttons, inputs and the woocommerce-* notices. The plugin’s own pieces use the variables in both versions: the cards, the rows with their icons, the status pills, the switches, code chips, the QR box and the passkey message. So in that version, --nahnls-primary colours the switches, card icons and text links, but not your theme’s buttons. Style those with your theme.
Right-to-left languages#
Both stylesheets use logical CSS properties only, so they work in right-to-left languages without extra CSS. The “back” and “forward” arrows are chosen with is_rtl() and carry a data-dir attribute. The 2FA stylesheet flips the arrow when the page’s rendered dir differs from it. Codes and secrets always stay left-to-right.
Turn the plugin’s styling off#
If you want to style everything yourself, stop the plugin from loading its two stylesheets. The markup and class names stay the same.
add_filter( 'nahnls_front_css_enabled', function ( $enabled, $handle ) {
return in_array( $handle, [ 'nahnls-account-panel', 'nahnls-2fa-front' ], true ) ? false : $enabled;
}, 10, 2 ); | Argument | Meaning |
|---|---|
$enabled | true by default |
$handle | nahnls-account-panel or nahnls-2fa-front |
One style stays on. On the challenge page, a small rule hides the standard login and register forms while a challenge is shown. It lives in its own stylesheet, assets/css/2fa-wc-hide.css (handle nahnls-2fa-front-hide), and works from the nahnls-2fa-pending class that the plugin adds to the <body> while a challenge is on screen. Themes that don’t print body_class() are covered by an equivalent body:has(#nahnls-2fa-wc) rule. So the page still works without the plugin’s styling.
Other front-end pieces#
The login page, the magic-link pages, the passkey button and the CAPTCHA widget have their own stylesheets (login-alt.css, magic-link.css, magic-link-page.css, passkey-button.css, widget.css). They are not driven by the variables above. To change them, use ordinary CSS with selectors that are more specific than the plugin’s. For the magic-link form you can also pass your own classes (class, input_class, button_class). See Passwordless API. For the passkey button, pass class.
Tips#
- Use your browser’s inspector to find the wrapper and see which variables are applied.
- Add your CSS late enough in the page that it comes after the plugin’s stylesheet, or rely on the zero-specificity rule, which makes the wrapper selector win regardless of order.
- If a colour doesn’t change, check that you set the variable on
.nahnls-apor.nahnls-2fa-wcand not on:rootorbody. - After turning the stylesheets off, check the panel on a phone. The plugin’s styling also handles spacing and layout.
Was this helpful?
Thanks for your feedback!
✓ Feedback received. Thank you!