---
title: Customizing CSS
label: Customizing CSS
order: 50
desc: Customize the Payload Admin Panel further by adding your own CSS style sheet to the configuration, powerful theme and design options are waiting for you.
keywords: admin, css, documentation, Content Management System, cms, headless, javascript, node, react, nextjs
---

Customizing the Payload [Admin Panel](./overview) 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](#global-css) for you to inject custom selectors
1. Provides a [CSS library](#css-library) that can be easily overridden or extended
1. Uses [BEM naming conventions](http://getbem.com) 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](./overview). 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:

```css
.dashboard {
  background-color: red; // highlight-line
}
```

<Banner type="warning">
  **Note:** If you are building [Custom
  Components](../custom-components/overview), it is best to import your own
  stylesheets directly into your components, rather than using the global
  stylesheet. You can continue to use the [CSS library](#css-library) as needed.
</Banner>

### 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

```css
@layer payload-default {
  /* my styles within the Payload specificity */
}
```

## Re-using Payload CSS variables

Payload defines its design tokens as [CSS Variables](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties) on both `:root` and `:host`. Custom admin components inherit these tokens without importing anything.

```css
@layer payload-default {
  .my-component {
    padding: var(--spacer-3);
    color: var(--color-text);
  }
}
```

### Overriding tokens

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

```css
:root {
  --button-radius: 19px;
}
```

<Banner type="info">Inside Shadow DOM, override tokens on `:host`.</Banner>

### 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:

```ts
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](http://getbem.com/) 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](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties). 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:

- [Breakpoints](https://github.com/payloadcms/payload/blob/main/packages/ui/src/css/spacing.css)
- [Colors](https://github.com/payloadcms/payload/blob/main/packages/ui/src/css/colors.css)
  - Semantic tokens for background, text, border, and icon colors (e.g. `--color-bg`, `--color-text`, `--color-border`, `--color-icon`)
  - Success / warning / danger color tokens
  - [The raw `--ramp-*` color palette](https://github.com/payloadcms/payload/blob/main/packages/ui/src/css/color-ramps.css)
- [Sizing](https://github.com/payloadcms/payload/blob/main/packages/ui/src/css/app.css)
  - [Horizontal gutter](https://github.com/payloadcms/payload/blob/main/packages/ui/src/css/spacing.css)
  - Navigation width
  - [Font sizes](https://github.com/payloadcms/payload/blob/main/packages/ui/src/css/typography.css)
  - Etc.

For an up-to-date, comprehensive list of all available variables, please refer to the [Source Code](https://github.com/payloadcms/payload/blob/main/packages/ui/src/css).

<Banner type="warning">
  **Warning:** If you're overriding colors, make sure to consider how [your
  changes will affect dark mode](#dark-mode).
</Banner>

#### Dark Mode

Colors are designed to automatically adapt to the theme of the [Admin Panel](./overview). 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.
