Introduction
Natura11y's dynamic color system makes it easy to maintain consistent colors across your design. You can easily create and apply color themes for entire pages, such as dark mode. Themes can also be applied to specific sections or individual components like cards or buttons.
Ensure your color combinations meet a sufficient contrast ratio.
Learn more about accessible contrast ratios.
Theme Colors: Your Principal Palette
Your principal theme colors include Primary, Secondary, Dark, Light, and Canvas.
These five colors produce utility classes for theme colors, background colors, text colors, and border colors.
Natura11y treats canvas (white) as a color, which serves as the default theme. Natura11y's CSS file applies the canvas theme (and its correlated colors) to the <body>
selector.
Theme Color Utilities
Natura11y's theme color utility classes are one of its most useful features. Each theme color utility provides predefined colors for background, text, borders, and links (within paragraphs). Theme color utilities also provide colors for instances of confirm and warn.
Figure 2 (below) provides the five theme color utilities:
You may apply theme colors to any containing block-level element within the DOM. Consider the following five cards, each colored with a different theme color utility.
In Figure 3 (below), on line 1, notice the .theme-primary
utility present. No other element within the card needs color specified. Each theme color utility applies its correlated colors to all descendants.
Links
Refer to Figure 1 (above), on line 9. The correlated link color (e.g. --primary-link
) value sets the color of generic links (<a>
tags) within paragraphs (<p>
tags). This is not only convenient, it keeps paragraph links visible and accessible.
Beyond generic links, a text color utility named .text-color-link
is available. With the following example, .text-color-link
(Figure 4, Line 5) colors the buttons within the same selector blue.
Confirm and Warn
In Figure 1 (above), on lines 10 and 11, you will find declarations for confirm and warn color values. Natura11y allows you to specify confirm and warn values for each theme color!
Infinitely Nestable
You can nest theme color utilities throughout the DOM.
Breakpoint Specific
Apply a theme color at a specific breakpoint. Chain a breakpoint modifier (e.g. --lg
for a large breakpoint) to a the color utility. In the following example, .theme-primary--lg
is present on the parent selector of our nav (Figure 5, line 1).
On smaller viewports The above example uses the default canvas theme. It instead used the primary theme when the viewport reaches the large breakpoint. Scale your browser horizontally to see this change occur.
Prefers Color Scheme
Natura11y's .theme-canvas
utility offers a special --prefers
modifier class. With .theme-canvas--prefers
present on the <body>
tag for example, a light or dark color theme is used depending on the operating system's settings.
Subtle Fill
The .subtle-fill-1
and .subtle-fill-2
classes add light background tints to any element, using a percentage of the element's text color (currentColor
).
.subtle-fill-1
applies a background color that is 5% of the current text color..subtle-fill-2
applies a background color that is 10% of the current text color.
In the card examples below, we apply a subtle fill to the action buttons within the .card__footer
class using these new variations.
Notice how the subtle fills appear differently depending on the theme: darker in the white theme and lighter in the dark theme cards.
Background Color Utilities
Need to apply only a background color? Our background color utilities (shown in Figure 6) apply a background color to its selector.
Text Color Utilities
Natura11y's text color utilities are useful for applying text color specificly to certain selectors.
Consider the following example in Figure 7. With our primary theme applied to the containing element (line 1), .text-color-secondary
is present on the third button selector.
Keep in mind that text color utilities take priority over color applied with theme color utilies. This, of course allows for even more variations within your themes.
Available text color utilities shown in figure 8: