Strategies and conventions
Breakpoints #
- XS: 0 - 575px
- SM: 576 - 767px
- MD: 768 - 991px
- LG: 992 - 1199px
- XL: 1200 - 1499px
- 2XL: 1500px and up
Colors #
We have customized the Tailwind theme to include all the colors from the Stanford Identity Guide to generate all the color-related utility classes your projects need, e.g., bg-cardinal-red, text-black, border-palo-alto.
Light and dark variants: For colors from the identity guide with light and dark variants, add -light or -dark to the end of the class name, e.g., bg-digital-red-light, text-lagunita-dark.
Variants of color black: We have 10 variants of black color available that correspond to the identity guide - -black, -black-90 (the number after the last - is the percentage, so this is 90% black), -black-80, -black-70, -black-60, -black-50, -black-40, -black-30, -black-20, -black-10. We also have -black-true for #000000.
Color opacity: To apply opacity to a color, add / and a number to the end of the class name, e.g., bg-digital-red/50 (digital red at 50% opacity), text-white/20 (white at 20% opacity). See the Tailwind documentation on changing color opacity.
Fonts #
We have 5 font family classes available that allow one to use Decanter’s font stack.
Note: You will still need to import these fonts on your own.
All fonts except the Stanford ligature font are available on Google Fonts. The Stanford font is available through the University Communications CDN.
font-sans
Font stack: Source Sans Pro, Helvetica Neue, Helvetica, Arial, sans-serif
Example: The quick brown fox jumps over the lazy dog.font-serif
Font stack: Source Serif Pro, Georgia, Times, Times New Roman, serif
Example: The quick brown fox jumps over the lazy dog.font-stanford(use for Stanford logo)
Font stack: Stanford, Source Serif Pro, Georgia, Times, Times New Roman, serif
Example: Stanford Universityfont-slab
Font stack: Roboto Slab, Georgia, Times, Times New Roman, serif
Example: The quick brown fox jumps over the lazy dog.font-mono
Font stack: Roboto Mono, Menlo, Courier New, monospace
Example: The quick brown fox jumps over the lazy dog.
Centered container and screen edge #
In Decanter, we use a fluid “centered container” (cc class) to constrain the width of the content area on a website by setting proportional “screen edge” at each breakpoint.
Screen edge is the minimal amount of space between the outside edge of this centered container and the edge of the browser window. Its margins are set at each breakpoint, up to and not including the largest breakpoint (2XL). The total width of the centered container is not fixed, but rather expands (fluid) as the viewport expands up to 1700px. At which point, the centered container reaches its maximum width of 1500px with screen edge of 100px margin on either side of the container.
Screen edge values are curated and do not follow a mathematical pattern:
- XS: 20px
- SM: 30px
- MD: 50px
- LG: 80px
- XL and 2XL up to 1700px: 100px
Grid and grid gaps #
We have curated grid gaps that are proportional within each breakpoint range. Our current values:
- XS to MD: 20px
- LG: 36px
- XL: 40px
- 2XL: 48px
Responsive Spacing #
The Decanter design system comes with a responsive spacing strategy. The provided values will scale up and down with screen sizes to maintain optimal use of whitespace and a positive developer experience.
Prefixes:
rs-m- for margin
rs-mb- for margin bottom
rs-mt- for margin top
rs-mr- for margin right
rs-ml- for margin left
rs-mx- for margin left and right
rs-my- for margin top and bottom
rs-p- for padding
rs-pb- for padding bottom
rs-pt- for padding top
rs-pr- for padding right
rs-pl- for padding left
rs-px- for padding left and right
rs-py- for padding top and bottom
| Step | Sizes |
|---|---|
| neg2 | xs: 0.8rem md: 0.9rem 2xl: 1rem |
| neg1 | xs: 1.1rem md: 1.2rem 2xl: 1.3rem |
| 0 | xs: 1.5rem md: 1.8rem 2xl: 1.9rem |
| 1 | xs: 2rem md: 2.6rem 2xl: 2.7rem |
| 2 | xs: 3rem md: 3.6rem 2xl: 3.8rem |
| 3 | xs: 3.2rem md: 4.5rem 2xl: 4.8rem |
| 4 | xs: 3.4rem md: 5.8rem 2xl: 6.1rem |
| 5 | xs: 3.8rem md: 7.2rem 2xl: 7.6rem |
| 6 | xs: 4.5rem md: 9rem 2xl: 9.5rem |
| 7 | xs: 5rem md: 10.8rem 2xl: 11.4rem |
| 8 | xs: 6rem md: 12.6rem 2xl: 13.3rem |
| 9 | xs: 7rem md: 16.2rem 2xl: 17.1rem |
| 10 | xs: 8rem md: 21.6rem 2xl: 22.8rem |
Example
<!-- You can use the responsive spacing classes like so, but you wouldn't use all of them at once. -->
<div class="rs-m-0 rs-mb-1 rs-mt-2 rs-mr-3 rs-ml-4 rs-mx-5 rs-my-6 rs-p-0 rs-pb-1 rs-pt-2 rs-pr-3 rs-pl-4 rs-px-5 rs-py-6">
<p>Responsive spacing</p>
</div>
Margins and Padding #
The Decanter Design System has a different spacing system than the core Tailwind CSS framework. We have a set of margin and padding classes. For more information about how we customize our spacing please visit:
- https://tailwindcss.com/docs/customizing-spacing
- https://tailwindcss.com/docs/padding
- https://tailwindcss.com/docs/margin
- https://tailwindcss.com/docs/space-between
| Key | Value |
|---|---|
| px | 1px |
| 0 | 0 |
| 01em | 0.1em |
| 02em | 0.2em |
| 03em | 0.3em |
| 04em | 0.4em |
| 05em | 0.5em |
| 06em | 0.6em |
| 07em | 0.7em |
| 08em | 0.8em |
| 09em | 0.9em |
| 1em | 1em |
| 1 | 0.1rem |
| 2 | 0.2rem |
| 3 | 0.3rem |
| 4 | 0.4rem |
| 5 | 0.5rem |
| 6 | 0.6rem |
| 7 | 0.7rem |
| 8 | 0.8rem |
| 9 | 0.9rem |
| 10 | 1rem |
| 11 | 1.1rem |
| 12 | 1.2rem |
| 13 | 1.3rem |
| 14 | 1.4rem |
| 15 | 1.5rem |
| 16 | 1.6rem |
| 17 | 1.7rem |
| 18 | 1.8rem |
| 19 | 1.9rem |
| 20 | 2rem |
| 21 | 2.1rem |
| 22 | 2.2rem |
| 23 | 2.3rem |
| 24 | 2.4rem |
| 25 | 2.5rem |
| 26 | 2.6rem |
| 27 | 2.7rem |
| 28 | 2.8rem |
| 29 | 2.9rem |
| 30 | 3rem |
| 31 | 3.1em |
| 32 | 3.2rem |
| 33 | 3.3rem |
| 34 | 3.4rem |
| 35 | 3.5rem |
| 36 | 3.6rem |
| 37 | 3.7rem |
| 38 | 3.8rem |
| 39 | 3.9rem |
| 40 | 4rem |
| 41 | 4.1rem |
| 42 | 4.2rem |
| 43 | 4.3rem |
| 44 | 4.4rem |
| 45 | 4.5rem |
| 46 | 4.6rem |
| 47 | 4.7rem |
| 48 | 4.8rem |
| 49 | 4.9rem |
| 50 | 5rem |
| 55 | 5.5rem |
| 58 | 5.8rem |
| 60 | 6rem |
| 61 | 6.1rem |
| 65 | 6.5rem |
| 70 | 7rem |
| 72 | 7.2rem |
| 75 | 7.5rem |
| 76 | 7.6rem |
| 80 | 8rem |
| 85 | 8.5rem |
| 90 | 9rem |
| 95 | 9.5rem |
| 100 | 10rem |
| 108 | 10.8rem |
| 110 | 11rem |
| 114 | 11.4rem |
| 120 | 12rem |
| 126 | 12.6rem |
| 130 | 13rem |
| 133 | 13.3rem |
| 140 | 14rem |
| 150 | 15rem |
| 160 | 16rem |
| 162 | 16.2rem |
| 170 | 17rem |
| 171 | 17.1rem |
| 180 | 18rem |
| 190 | 19rem |
| 200 | 20rem |
| 216 | 21.6rem |
| 220 | 22rem |
| 228 | 22.8rem |
| 230 | 23rem |
| 240 | 24rem |
| 250 | 25rem |
| 260 | 26rem |
| 270 | 27rem |
| 280 | 28rem |
| 290 | 29rem |
| 300 | 30rem |
| 350 | 35rem |
| 400 | 40rem |
| 450 | 45rem |
| 500 | 50rem |
| 550 | 55rem |
| 600 | 60rem |
| 650 | 65rem |
| 700 | 70rem |
| 750 | 75rem |
| 800 | 80rem |
| 850 | 85rem |
| 900 | 90rem |
| 950 | 95rem |
| 1000 | 100rem |
| 1100 | 110rem |
| 1200 | 120rem |
| 1300 | 130rem |
| 1400 | 140rem |
| 1500 | 150rem |
Base font size and scales #
In Decanter v7, we added five custom classes that give users some flexibility over the base font sizes of their sites. These classes also provide responsive font sizes for smaller breakpoints. Most of the other typography classes and base settings in Decanter use the em units so that they scale appropriately when the base font size changes, e.g., the font size of a default H1 would be larger at all breakpoints if you use the basefont-23 class compared to the basefont-19 class for the document.
Other than using these classes in the root HTML tag, one could also use them within regions or components, e.g., to set the base font size of a card, or a form. Below are the five classes available:
Note: The HTML root font size is set to 10px in Decanter’s base configuration, thus, 1rem = 10px.
basefont-19- XS to SM: 1.6rem
- MD to XL: 1.8rem
- 2XL: 1.9rem
basefont-20- XS to SM: 1.8rem
- MD to XL: 1.9rem
- 2XL: 2rem
basefont-21- XS to SM: 1.8rem
- MD to XL: 1.9rem
- 2XL: 2.1rem
basefont-22- XS to SM: 1.8rem
- MD to XL: 2rem
- 2XL: 2.2rem
basefont-23
(This is the setting we use for the Alumni homesite and Giving websites)- XS to SM: 1.8rem
- MD to XL: 2.1rem
- 2XL: 2.3rem
Modular typography #
Modular typography provides a convenient way to scale font sizes and keep them proportional for all breakpoints. The “modular” part comes from the modular scale concept, which is a set of numbers that increase by a fixed ratio or multiplier between them. If this multiplier is bigger, the series of numbers increases faster, i.e., each step is further apart.
In Decanter, the modular typography classes use the em unit and we set type-0 (type stands for typography) to equal 1em, meaning if you use the basefont-23 class (see previous section on base font size) in the root, type-0 would be 2.3rem or 23px. From then on, we provide 9 typography steps from type-1 to type-9 with a fixed ratio (modular scale multiplier) between each step.
We also realize that font sizes should go up at a different rate between mobile, tablet and desktop breakpoints. It makes sense to have really large “splash” typography in the hero banner on the desktop version of a site that is e.g., 160px, which would look enormous on a phone screen. For this reason, we have 3 different modular scale multipliers for the different device sizes as below:
- Mobile (XS-SM): 1.15
- Tablet (MD): 1.2
- Desktop (LG to 2XL): 1.25
What does this all mean? Let’s look at an example. Let’s say we using the class type-7 for a hero banner headline, below would be the rendered font sizes at each breakpoint range assuming one uses the basefont-23 class (18px for XS-SM, 21px for MD-XL, 23px for 2XL) in root:
- Mobile: 18px * 1.157 = 48px (base font size for mobile multiply by 1.15 7 times since we’re on step #7)
- Tablet: 21px * 1.27 = 75px
- Desktop between LG to XL = 21px * 1.257 = 100px
- Desktop from 2XL breakpoint and up: 23px * 1.257 = 109px
As you can see, by applying the single modular typography class type-7 to the headline, you get an appropriately sized typography element for all breakpoint ranges.
Other typography styles #
displaycard-paragraphbig-paragraphintro-textsplashcaptioncredit
Icons #
We use Heroicons for many of our projects that use Decanter v7. Heroicons is developed by the Tailwind CSS team and we found it to pair well with the Tailwind utilities, e.g., you can use classes like text-cardinal-red or w-30 to style the icons. We also use FontAwesome in some of our projects for a larger variety of icons as well as social media/brand icons.
Accessibility #
Screen readers
Use the sr-only class to hide an element visually without hiding it from screen readers.
Interactive elements
Other than using the hover: Tailwind modifier (e.g., hover:underline) to add hover styles for interactive elements, please remember to also use the focus: modifier (e.g., focus:text-lagunita) to add focus styles for keyboard users. You can use the custom hocus: modifier (e.g., hocus:bg-plum) for styles that have the same hover and focus states.