Photo by Pierre Bamin on Unsplash
Customization
Distinguish yourself without starting from scratch.
There are two ways to customize Natura11y. The CDN Stylesheet allows you to redefine styles. We'll cover this method in the following section. Your other option is to set up a modern development environment.
Customizable CDN
Our Quick Start guide shows you how to include the framework's core stylesheet via CDN. Within the framework, we use CSS custom properties to declare styles. People often refer to CSS custom properties as CSS variables. We use this term throughout our documentation.
If you're not familiar with CSS variables, take time now to read the MDN web docs. Figure 1 (below) offers a simple example of using a SASS variable and a CSS Variable to achieve the same result.
CSS variables provide benefits that Sass variables do not. Did you know CSS variables update at runtime? You can declare new values from natura11y.css anytime after that stylesheet reference.
There are different ways to declare new values for CSS variables. Adding a style tag in the header is ideal for prototyping and exploring. Creating a second stylesheet is the preferred method. You can even redeclare values using JavaScript.
In the following exercise, learn how to change your theme colors with a second stylesheet.
Practice Exercise: Customizing Colors
Make new directory somewhere on your computer. Call it color-example. Copy and paste the markup from Figure 2 (below) into a new HTML document. Save this document as index.html inside of the color-example directory.
Preview index.html in a browser. It should resemble the following.
Primary
Secondary
Dark
Light
Declared as CSS variables in natura11y.css, we have four colors. They are Primary, Secondary, Dark, and Light. Let's customize their color values with a second stylesheet.
Within the color-example directory, create a new directory called css. Make a new CSS file and name it new-colors.css. Save it into the /css directory.
Open your HTML document. Add a link to new-colors.css somewhere below natura11y.css (Figure 3, line 5).
With new-colors.css open, include the CSS from Figure 4. Save this file and refresh your browser.
Primary
Secondary
Dark
Light
Did your colors update to the new palette? With your new stylesheet in place, you have the ability to customize much more than just colors. In fact, you have full control over your design.
Reference Guide: CSS Variables
CSS Variables are hierarchal, or scoped. A variable's scope determines its reach throughout the DOM tree.
All CSS Variables in the framework are either scoped to the document or to a block. Document scoped variables use the :root
psuedo selector (available to the entire page). Block scoped variables use their selector class (e.g., .card
). These variables are available only to their selector (Figure 5).
The following table accounts for all CSS variables with Natura11y. Pay close attention to scope of each set of variables (noted under each header in the table).
When declaring new values within your own CSS, be sure their scopes match.
CSS Variable | Default Value | Description | |
---|---|---|---|
--accordion-button-padding-x | var(--spacer-3) | Left and right padding of the accordion component button | |
--accordion-button-padding-y | var(--spacer-3) | Top and bottom padding of the accordion component button | |
--accordion-panel-padding-x | var(--spacer-3) | Left and right padding of the accordion component panel | |
--accordion-panel-padding-y | var(--spacer-3) | Top and bottom padding of the accordion component panel | |
--accordion-active-color | currentColor | Color of active accordion component button |
CSS Variable | Default Value | Description | |
---|---|---|---|
--alert-padding-x | var(--spacer-2) | Left and right padding of the alert component header and body | |
--alert-padding-y | var(--spacer-2) | Top and bottom padding of the alert component header and body |
CSS Variable | Default Value | Description | |
---|---|---|---|
--article-sidebar-width | 260px | Width of the article component sidebar |
CSS Variable | Default Value | Description | |
---|---|---|---|
--backdrop-fixed-height | 400px | Height of the backdrop component with the fixed height modifier class |
CSS Variable | Default Value | Description | |
---|---|---|---|
--default-border-width | 1px | Width of all borders applied across your stylesheet | |
--default-border-style | solid | Style of all borders applied across your stylesheet | |
--border-radius | 0.5em | Border radius of the border-radius utility classes |
CSS Variable | Default Value | Description | |
---|---|---|---|
--button-padding-x | 1em | Left and right padding of the button utility class | |
--button-padding-y | 0.75em | Top and bottom padding of the button utility class | |
--button-font-weight | var(--body-font-weight-bold) | Weight of text elements within the button utility class | |
--button-text-transform | initial | Text transform of text elements within the button utility class | |
--button-letter-spacing | normal | Letter spacing of text elements within the button utility class | |
--button-text-transform | initial | Text transform value of the button utility class | |
--button-border-radius | 0.25em | Default Border radius of all button selectors | |
--button-outline-border-width | calc( var(--default-border-width) * 2) | Border width of the button outline modifier class | |
--button-icon-only-size | 2.25em | Width and height of the button icon only modifier class |
CSS Variable | Default Value | Description | |
---|---|---|---|
--card-padding-x | var(--spacer-2) | Left and right padding of the card component header, body, and footer | |
--card-padding-y | var(--spacer-2) | Top and bottom padding of the card component header, body, and footer |
CSS Variable | Default Value | Description | |
---|---|---|---|
--primary | #1E00B3 | The primary color applied within the theme and color utility classes | |
--primary-text | white | Color of text elements within the primary theme utility class | |
--primary-border | hsla(0, 0%, 0%, 0.25); | Color of borders within the primary theme utility class | |
--primary-link | currentColor | Color of links within the primary theme utility class | |
--primary-confirm | currentColor | Color of confirmation alerts within the primary theme utility class | |
--primary-warn | currentColor | Color of warning alerts within the primary theme utility class | |
--secondary | #64cc7e | The secondary color applied within the theme and color utility classes | |
--secondary-text | var(--dark) | Color of text elements within the secondary theme utility class | |
--secondary-border | hsla(0, 0%, 0%, 0.25) | Color of borders within the secondary theme utility class | |
--secondary-link | currentColor | Color of links within the secondary theme utility class | |
--secondary-confirm | currentColor | Color of confirmation alerts within the secondary theme utility class | |
--secondary-warn | currentColor | Color of warning alerts within the secondary theme utility class | |
--dark | #191b35 | The dark color applied within the theme and color utility classes | |
--dark-text | currentColor | Color of text elements within the dark theme utility class | |
--dark-border | currentColor | Color of borders within the dark theme utility class | |
--dark-link | currentColor | Color of links within the dark theme utility class | |
--dark-confirm | currentColor | Color of confirmation alerts within the dark theme utility class | |
--dark-warn | currentColor | Color of warning alerts within the dark theme utility class | |
--light | #191b35 | The light color applied within the theme and color utility classes | |
--light-text | var(--dark) | Color of text elements within the light theme utility class | |
--light-border | hsla(0, 0%, 50%, 0.25) | Color of borders within the light theme utility class | |
--light-link | var(--a11y-link) | Color of links within the light theme utility class | |
--light-confirm | #007e35 | Color of confirmation alerts within the light theme utility class | |
--light-warn | #ce1736 | Color of warning alerts within the light theme utility class | |
--canvas-text | var(--dark) | Color of text elements within the canvas theme (default) utility class | |
--canvas-border | hsla(0, 0%, 50%, 0.25) | Color of borders within the canvas theme (default) utility class | |
--canvas-link | var(--a11y-link) | Color of links within the canvas theme (default) utility class | |
--canvas-confirm | #008237 | Color of confirmation alerts within the canvas theme (default) utility class | |
--canvas-warn | #e4193c | Color of warning alerts within the canvas theme (default) utility class | |
--a11y-link | blue | Accessible link color applied to links within canvas and light themes |
CSS Variable | Default Value | Description | |
---|---|---|---|
--container-padding-x-sm | var(--spacer-2) | Left and right padding of the container component on smaller (mobile) viewports | |
--container-padding-x-lg | var(--spacer-3) | Left and right padding of the container component on larger (desktop) viewports | |
--narrow-width | 40rem | Maximum width of the narrow utility class | |
--medium-width | calc( var(--narrow-width) * 1.75) | Maximum width of the medium utility class | |
--wide-width | calc( var(--narrow-width) * 2.5) | Maximum width of the wide utility class |
CSS Variable | Default Value | Description | |
---|---|---|---|
--body-min-width | 325px | Minimum width of the body element | |
--body-max-width | 100% | Maximum width of the body element | |
--html-background-color | var(--canvas) | Background color of the html element |
CSS Variable | Default Value | Description | |
---|---|---|---|
--form-field-padding-x | var(--spacer-3) | Left and right padding of certain form entry elements | |
--form-field-padding-y | var(--button-padding-y) | Top and bottom padding of certain form entry elements | |
--form-field-border-radius | 0.25em | Maximum width of the medium utility class |
CSS Variable | Default Value | Description | |
---|---|---|---|
--grid-divider-gap | var(--spacer-3) | Default total gap size of the grid divider selector | |
--grid-divider-border-width | var(--default-border-width) | Width of centered border between grid divider gap | |
--grid-divider-border-x-color | var(--canvas-border) | Color of centered border along the horizontal axis of the grid divider selector | |
--grid-divider-border-y-color | var(--canvas-border) | Color of centered border along the vertical axis of the grid--divider selector |
CSS Variable | Default Value | Description | |
---|---|---|---|
--gradient-veneer-start | 50% | Gradient's starting position (relative to its direction) of the gradient veneer utilities | |
--gradient-veneer-opacity | 1 | Opacity of the gradient utility class within the gradient veneer utilities |
CSS Variable | Default Value | Description | |
---|---|---|---|
--modal-padding-x | var(--spacer-2) | Left and right padding of the modal component header, body, and footer | |
--modal-padding-y | var(--spacer-2) | Top and bottom padding of the modal component header, body, and footer | |
--modal-overlay-opacity | 0.8 | Opacity of the modal overlay | |
--modal-z-index | 8000 | Z-index value of the entire modal component |
CSS Variable | Default Value | Description | |
---|---|---|---|
--nav-gap | 0.75em | Size of spacer 1, used in CSS including margin and padding utility classes | |
--nav-divider-padding-y | 0.625em | Size of spacer 2, used in CSS including margin and padding utility classes | |
--nav-divider-padding-x | var(--spacer-3) | Size of spacer 3, used in CSS including margin and padding utility classes | |
--primary-nav-padding-x | var(--spacer-3) | Size of spacer 4, used in CSS including margin and padding utility classes | |
--primary-nav-padding-y | var(--spacer-2) | Size of spacer 5, used in CSS including margin and padding utility classes | |
--primary-nav-search-width | 200px | Size of spacer 5, used in CSS including margin and padding utility classes |
CSS Variable | Default Value | Description | |
---|---|---|---|
--spacer-base | 1rem | Size of base spacer value, used in multiplying the five spacer values | |
--spacer-1 | calc(var(--spacer-base) * 0.5) | Size of spacer 1, used in CSS including margin and padding utility classes | |
--spacer-2 | calc(var(--spacer-base) * 1) | Size of spacer 2, used in CSS including margin and padding utility classes | |
--spacer-3 | calc(var(--spacer-base) * 1.5) | Size of spacer 3, used in CSS including margin and padding utility classes | |
--spacer-4 | calc(var(--spacer-base) * 2.5) | Size of spacer 4, used in CSS including margin and padding utility classes | |
--spacer-5 | calc(var(--spacer-base) * 4) | Size of spacer 5, used in CSS including margin and padding utility classes | |
--spacer-6 | calc(var(--spacer-base) * 6.5) | Size of spacer 6, used in CSS including margin and padding utility classes |
CSS Variable | Default Value | Description | |
---|---|---|---|
--subtle-fill-opacity | 0.075 | Opacity of the subtle fill when used globally |
CSS Variable | Default Value | Description | |
---|---|---|---|
--table-cell-padding-x | var(--spacer-3) | Left and right padding of the table cells | |
--table-cell-padding-y | 0.75em | Top and bottom padding of the table cells | |
--table-scroll-min-width | 800px | Minimum width of the table within the table scroll component |
CSS Variable | Default Value | Description | |
---|---|---|---|
--body-font-family | Source Sans Pro | Font family applied to the entire document | |
--body-font-weight-normal | 400 | Numeric font weight value for normal fonts | |
--body-font-weight-medium | 600 | Numeric font weight value for medium fonts | |
--body-font-weight-bold | 700 | Numeric font weight value for bold fonts | |
--body-font-size | 22px | Base font size applied to the entire document | |
--body-line-height | 1.5 | Line height applied to the entire document (excluding headers) | |
--font-size-sm | calc(var(--body-font-size) * 0.7) | Small font size used in CSS including font size utility classes | |
--font-size-md | calc(var(--body-font-size) * 0.8) | Medium font size used in CSS including font size utility classes | |
--font-size-lg | calc(var(--body-font-size) * 1) | Large font size used in CSS including font size utility classes | |
--font-size-xl | calc(var(--body-font-size) * 1.4) | Extra large font size used in CSS including font size utility classes | |
--h1-font-size | calc(var(--body-font-size) * 3) | Font size of Section Header Level 1 | |
--h2-font-size | calc(var(--body-font-size) * 2.2) | Font size of Section Header Level 2 | |
--h3-font-size | calc(var(--body-font-size) * 1.8) | Font size of Section Header Level 3 | |
--h4-font-size | calc(var(--body-font-size) * 1.6) | Font size of Section Header Level 4 | |
--h5-font-size | calc(var(--body-font-size) * 1.4) | Font size of Section Header Level 5 | |
--h6-font-size | calc(var(--body-font-size) * 1.2) | Font size of Section Header Level 6 | |
--header-line-height | 1.125 | Line height applied to headers | |
--banner-headline-font-size-sm | calc(var(--body-font-size) * 2.75) | Font size of the Banner Headline utility class on smaller (mobile) viewports | |
--banner-headline-font-size-lg | calc(var(--body-font-size) * 2.75) | Font size of the Banner Headline utility class on larger (desktop) viewports | |
--paragraph-margin-bottom | 1.25em | Bottom margin set to paragraphs |