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 in their page's CSS. For example, let's create a custom
Bordeaux theme. We'll write a CSS rule which selects for the theme-bordeaux
class, and in that rule we'll set the values of RHDS theming tokens to our custom theme colors.
In the following example, you can see how we first define some custom theme
colours as CSS custom properties beginning with --bordeaux-
, then we use those
values in our custom theme by applying them to RHDS theming tokens.
light-dark()
function when crafting custom themes.
Copy to Clipboard
Copied!
Toggle line wrap
<rh-card class="theme-bordeaux list-with-dividers" ssr-hint-has-slotted-default="true" ssr-hint-has-slotted="footer">
<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" ssr-hint-has-slotted-default="true" ssr-hint-has-slotted="footer">
<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 <a href="../color-palettes/">color palette</a>.</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 {
/* first, define some custom theme colors */
--bordeaux-darkest: #19050a;
--bordeaux-darker: #260710;
--bordeaux-dark: #330915;
--bordeaux-brand-dark: #7f1734;
--bordeaux-brand-light: #d52757;
--bordeaux-light: #a55d71;
--bordeaux-lighter: #d9b9c2;
--bordeaux-lightest: #f2e8eb;
/* next, apply those colours to RHDS' theming tokens */
--rh-color-surface-darkest: var(--bordeaux-darkest);
--rh-color-surface-darker: var(--bordeaux-darker);
--rh-color-surface-dark: var(--bordeaux-dark);
--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: light-dark(
var(--bordeaux-darkest),
var(--bordeaux-lightest)
);
--rh-color-interactive-primary-default: light-dark(
var(--bordeaux-darker),
var(--bordeaux-lighter)
);
--rh-color-interactive-primary-hover: light-dark(
var(--bordeaux-dark),
var(--bordeaux-light)
);
--rh-color-interactive-primary-focus: light-dark(
var(--bordeaux-dark),
var(--bordeaux-light)
);
--rh-color-interactive-primary-active: light-dark(
var(--bordeaux-dark),
var(--bordeaux-light)
);
--rh-color-border-subtle: light-dark(
var(--bordeaux-darker),
var(--bordeaux-lighter)
);
--rh-color-icon-primary: light-dark(
var(--bordeaux-brand-dark),
var(--bordeaux-brand-light)
);
}
.list-with-dividers {
margin-block-end: var(--rh-space-lg);
& 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);
}
}
a {
color: var(--rh-color-interactive-primary-default);
&:hover { color: var(--rh-color-interactive-primary-hover); }
&:focus-within { color: var(--rh-color-interactive-primary-focus); }
&:active { color: var(--rh-color-interactive-primary-active); }
&:visited {
color: var(--rh-color-interactive-primary-visited);
&:hover { color: var(--rh-color-interactive-primary-visited-hover); }
&:focus-within { color: var(--rh-color-interactive-primary-visited-focus); }
&:active { color: var(--rh-color-interactive-primary-visited-active); }
}
}
Copy to Clipboard
Copied!
Toggle line wrap
--rh-color-interactive-primary-default
rather than the crayon tokens
e.g. --rh-color-purple-10
. This ensures that your custom colors apply to
elements in the way the designers originally intended
Customizing entire pages
To customize entire page, we can apply the theme-bordeaux
class to the body element.
Have you written a custom theme for RHDS? Brag about it! Let us know in slack, show it off on your blog.
When to use custom themes
A custom theme may be used for very specific brand projects like campaigns, podcasts, or events. For other applications, the default theme is already perfectly weighted. If your project does need a custom theme, contact the Brand team and Design system team for guidance.
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.