Customizing
On this page
Red Hat Design System is composed of tokens, elements, and patterns, each layer
building on the last. Theming emerges as a design possibility from the
composition of those smaller pieces. By setting custom values for themeable
design tokens, elements, sections, or entire pages can take on a new color
scheme, layout density, etc. Custom themes can apply to multiple color-palettes
and to both the light
and dark
backgrounds.
Custom themes
To create a custom theme, designers and developers need only set the values for the relevant color properties in the design system. For example, a Bordeaux theme might look like this:
Copy to Clipboard
Copied!
Toggle line wrap
<rh-card class="theme-bordeaux list-with-dividers">
<ul>
<li>This card uses a custom theme</li>
<li><a href="#">Links also are affected</a></li>
<li>See how it reacts when you change the color-palette</li>
</ul>
<rh-cta slot="footer" href="#">Call to action</rh-cta>
</rh-card>
<rh-card id="bordeaux-card-provider" class="theme-bordeaux">
<rh-blockquote>You can also set a color palette on a specific element</rh-blockquote>
<label for="bordeaux-card-picker" slot="footer">Set this card's color palette.</label>
<rh-context-picker id="bordeax-card-picker" target="bordeaux-card-provider" allow="darkest, lighter, lightest" slot="footer"></rh-context-picker>
</rh-card>
Copy to Clipboard
Copied!
Toggle line wrap
.theme-bordeaux {
--bordeaux-darkest: #19050a;
--bordeaux-darker: #260710;
--bordeaux-dark: #330915;
--bordeaux-dark-alt: #290711;
--bordeaux-brand-dark: #7f1734;
--bordeaux-brand-light: #d52757;
--bordeaux-light: #a55d71;
--bordeaux-lighter: #d9b9c2;
--bordeaux-lightest: #f2e8eb;
--rh-color-surface-darkest: var(--bordeaux-darkest);
--rh-color-surface-darker: var(--bordeaux-darker);
--rh-color-surface-dark: var(--bordeaux-dark);
--rh-color-surface-dark-alt: var(--bordeaux-dark-alt);
--rh-color-surface-light: var(--bordeaux-light);
--rh-color-surface-lighter: var(--bordeaux-lighter);
--rh-color-surface-lightest: var(--bordeaux-lightest);
--rh-color-border-interactive-on-dark: var(--bordeaux-lightest);
--rh-color-border-interactive-on-light: var(--bordeaux-darkest);
--rh-color-interactive-primary-default-on-dark: var(--bordeaux-lighter);
--rh-color-interactive-primary-default-on-light: var(--bordeaux-darker);
--rh-color-interactive-primary-hover-on-dark: var(--bordeaux-light);
--rh-color-interactive-primary-hover-on-light: var(--bordeaux-dark);
--rh-color-interactive-primary-focus-on-dark: var(--bordeaux-light);
--rh-color-interactive-primary-focus-on-light: var(--bordeaux-dark);
--rh-color-interactive-primary-active-on-dark: var(--bordeaux-light);
--rh-color-interactive-primary-active-on-light: var(--bordeaux-dark);
--rh-color-border-subtle-on-dark: var(--bordeaux-lighter);
--rh-color-border-subtle-on-light: var(--bordeaux-darker);
--rh-color-icon-primary-on-light: var(--bordeaux-brand-dark);
--rh-color-icon-primary-on-dark: var(--bordeaux-brand-light);
}
.list-with-dividers {
& ul {
display: flex;
flex-flow: column;
margin: 0;
padding: 0;
list-style-type: none;
& li {
margin-block: 0;
padding-block: var(--rh-space-lg);
border-block-end: 1px solid var(--rh-color-border-subtle);
&:last-child {
padding-block-end: 0;
border-block-end: none;
}
}
}
& h3 {
margin-block-end: var(--rh-space-lg);
}
}
Copy to Clipboard
Copied!
Toggle line wrap
--rh-color-interactive-primary-default-on-light
rather than the crayon tokens
e.g. --rh-color-purple-10
.
Careful!
Do not set the "computed" theme tokens, e.g.
--rh-color-interactive-primary-default
, those will always be calculated for
you from their -on-light
and -on-dark
versions.
- set token values on
:root
for whole pages, or on a selector for a class (e.g. 3-card promo band) - brag about your customizations! did other teams use it, or something similar? maybe it should be added upstream to the design system?
When to use custom themes
A custom theme may be used for very specific brand projects like campaigns. However, the light and dark themes are fine for the majority of other projects. If your project does need a custom theme, contact the Brand team and Design system team for guidance. A custom theme may feature a bespoke color palette, but try to use other styles with elements and patterns from the design system if possible.
Choosing a theme
For most projects, the light and dark themes are good enough. Evaluate your project thoroughly before creating a custom theme.
Other libraries
To learn more about our other libraries, visit this page.
Feedback
To give feedback about anything on this page, contact us.
Other libraries
To learn more about our other libraries, visit the getting started page.