Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Customizing CSS

Customizing the Payload Admin Panel through CSS alone is one of the easiest and most powerful ways to customize the look and feel of the dashboard. To allow for this level of customization, Payload:

  1. Exposes a root-level stylesheet for you to inject custom selectors
  2. Provides a CSS library that can be easily overridden or extended
  3. Uses BEM naming conventions so that class names are globally accessible

To customize the CSS within the Admin UI, determine scope and change you'd like to make, and then add your own CSS to the configuration as needed.

Global CSS

Global CSS refers to the CSS that is applied to the entire Admin Panel. This is where you can have a significant impact to the look and feel of the Admin UI through just a few lines of code.

You can add your own global CSS through the root custom.css file of your app. This file is loaded into the root of the Admin Panel and can be used to inject custom selectors or styles however needed.

Here is an example of how you might target the Dashboard View and change the background color:

1
.dashboard {
2
background-color: red;
3
}

Specificity rules

Payload's default styles and design tokens are declared in @layer payload-default. Unlayered custom CSS takes precedence over these normal declarations, regardless of selector specificity or stylesheet load order.

We have also provided a layer @layer payload if you want to use layers and ensure that your styles are applied after payload.

To override existing styles in a way that the previous rules of specificity would be respected you can use the default layer like so

1
@layer payload-default {
2
/* my styles within the Payload specificity */
3
}

Re-using Payload CSS variables

Payload defines its design tokens as CSS Variables on both :root and :host. Custom admin components inherit these tokens without importing anything.

1
@layer payload-default {
2
.my-component {
3
padding: var(--spacer-3);
4
color: var(--color-text);
5
}
6
}

Overriding tokens

Override token values on :root in your own unlayered CSS:

1
:root {
2
--button-radius: 19px;
3
}

Using tokens outside the Admin Panel

Import @payloadcms/ui/css/tokens to use Payload's design tokens outside the Admin Panel without loading its resets, component styles, fonts, or global element styles:

1
import '@payloadcms/ui/css/tokens'

For Shadow DOM, load the stylesheet into the shadow root itself. A normal CSS import may place it in the outer document instead.

Values in rem use the document's root font size, including inside Shadow DOM. Load the fonts you want and apply typography tokens in your own styles.

CSS Library

To make it as easy as possible for you to override default styles, Payload uses BEM naming conventions for all CSS within the Admin UI. If you provide your own CSS, you can override any built-in styles easily, including targeting nested components and their various component states.

You can also override Payload's built-in CSS Variables. These variables are widely consumed by the Admin Panel, so modifying them has a significant impact on the look and feel of the Admin UI.

The following variables are defined and can be overridden:

For an up-to-date, comprehensive list of all available variables, please refer to the Source Code.

Dark Mode

Colors are designed to automatically adapt to the theme of the Admin Panel. Theme-dependent --color-* tokens are redefined under [data-theme='dark'] and :host([data-theme='dark']), so semantic tokens like --color-bg and --color-text, along with the success / warning / danger colors, adjust automatically for dark mode.

Tokens default to light mode. Set data-theme="dark" or data-theme="light" on the document's <html> element or on the shadow host to select its palette. Add data-enhanced-contrast to that same element to enable enhanced contrast, including nested themed controls.

A nested data-theme changes colors and elevations while inheriting shared spacing, typography, radii, and component customizations.

Built-in enhanced contrast styling follows the document or shadow host. Local contrast flags need custom styling.

Was this page helpful?

Next

Accessibility