Epic CSS / Documentation

Colors and palettes

Choose colors by their role in your design. Text and background utilities are separate, so one palette can change the appearance of the same markup.

Text and backgrounds

Compare the primary and secondary text/background pairs side by side. Text color and background color each need their own class.

clr-primary
clr-primary-bg
clr-secondary
clr-secondary-bg
HTML
<div class="grid w-100" style="grid-template-columns: repeat(2, minmax(0, 1fr))">
  <div class="py-40 flex items-center justify-center text-center fs-14 lh-20 clr-primary clr-primary-bg">
    <div>clr-primary<br>clr-primary-bg</div>
  </div>
  <div class="py-40 flex items-center justify-center text-center fs-14 lh-20 clr-secondary clr-secondary-bg">
    <div>clr-secondary<br>clr-secondary-bg</div>
  </div>
</div>

Two equal grid tracks share the available width. This example defines its always-on track pattern inline instead of adding another shared utility. Vertical padding supplies the box height while the flex utilities center the labels.

Buttons

Use btn for an inline-flex button with inherited typography, padding, a border, rounded corners, and a visible keyboard focus outline. Use btn btn-primary for a solid palette fill with white text and modest rounded corners. Use btn btn-secondary for a transparent pill with matching colored text and outline. The base button inherits text color and has a transparent background, so it can also be used inside a colored region.

HTML
<div class="flex flex-wrap gap-16 items-center">
  <button class="btn" type="button">btn</button>
  <button class="btn btn-primary" type="button">btn btn-primary</button>
  <button class="btn btn-secondary" type="button">btn btn-secondary</button>
  <button class="btn btn-primary" type="button" disabled>Unavailable action</button>
</div>

Add btn-sm to either appearance variant for 12px text, 18px line-height, and 6px vertical / 12px horizontal padding. Size and appearance are independent. Without btn-sm, buttons retain inherited typography and default 0.75rem 1rem padding. See the small primary and secondary examples.

These sample buttons demonstrate appearance; they do not run an action. Use a native button for actions and an anchor with a real destination for navigation. Native disabled prevents the unavailable button from activating; it also receives a dimmed appearance. Do not add disabled to an anchor.

Use existing spacing and layout utilities for variations, such as btn btn-primary py-8 px-16. Primary fills use the existing deeper light-mode primary accent in both modes through --btn-primary-bg; single-palette consumers use $clr-primary. Labels use fixed white. Secondary text and outlines use the current mode’s secondary accent. Palette overrides flow through both variants. Check text, borders, focus outlines, and disabled states against their actual surroundings when customizing colors; the named pairs do not guarantee accessible contrast for every palette.

Primary and secondary are persistent visual variants, not selected and unselected states. Keep the same variant class when state changes. A held press (:active), aria-pressed="true", aria-selected="true", or aria-expanded="true" slightly darkens the same primary fill or adds a stronger tinted fill inside the secondary outline. Primary keeps white text and modest rounded corners. Secondary stays pill-shaped with matching text and outline: its idle background is transparent, hover adds a subtle palette tint, and selected or expanded states use a stronger tint. Use the ARIA attribute appropriate to the control: pressed for toggle buttons, selected for tabs, and expanded for disclosures.

Inherited and fixed text colors

This paragraph inherits the body text color.

White text stays white when the palette changes. This example keeps a dark surface in both modes.

HTML
<div class="clr-secondary-bg p-24 border-r-16">
  <p>This paragraph inherits the body text color.</p>
  <p class="clr-white p-16 border-r-4" style="background: #0f172a;">White text stays white when the palette changes. This example keeps a dark surface in both modes.</p>
</div>
UtilitySass palette valueChanges
clr-body-bg$clr-body-bgBackground color
clr-primary$clr-primaryText color
clr-primary-bg$clr-primary-bgBackground
clr-secondary$clr-secondaryText color
clr-secondary-bg$clr-secondary-bgBackground
clr-white$clr-whiteText color

Light and dark palettes

The header's Dark mode button switches the HTML data-theme attribute between dark and light. Dark is the initial default, including when JavaScript or storage is unavailable. A valid saved choice is applied before styles load. The site deliberately does not follow the operating system's color preference; the explicit choice persists locally when storage is available.

In src/my-epic-css/_custom.scss, set $palette-name: "Harbor"; (blue), $palette-name: "Dusk"; (charcoal/lavender), or $palette-name: "Neon"; (black/coral/teal), then rebuild Sass. Dusk uses charcoal-violet surfaces and lavender accents in dark mode, with pale lavender surfaces and deeper violet accents in light mode. Neon uses bright coral and teal on black/charcoal in dark mode, with deeper accents on warm near-white surfaces in light mode. These three presets form the finished set. The runtime button switches light/dark within that compiled preset; there is no runtime palette picker. index.scss imports custom settings before centralized _variables.scss. Keep !default on library values: it means “use this fallback only when no value has been assigned.” The library's purple/green defaults remain separate from the workshop's named presets.

The selected record in the site's $palettes map supplies the eight existing $clr-* defaults and the $color-modes pair. Each named preset contains complete light and dark variants using the same eight roles: body, body-bg, primary, primary-light, primary-bg, secondary, secondary-bg and white. To customize a preset, edit its complete pair inside $palettes and select its exact name with $palette-name. Unknown names or incomplete modes/roles fail compilation. Saved original commented palettes are deliberately retained as references; they do not select the active palette. Every variant keeps the quoted "white": #ffffff role; it is not a semantic body-text alias.

The optional colors module emits default --clr-* properties on :root and mode overrides on html[data-theme="light"] and html[data-theme="dark"]. Existing utilities, base text, links, buttons and SVG currentColor use those properties. Single-palette consumers can leave $color-modes empty. Base rules also have Sass-value fallbacks, so selective imports keep working without the colors module. Import central variables before base or colors.

Paragraph links are underlined by default outside navigation. Navigation links underline only for active or aria-current="page"/aria-current="true", not hover alone. See the Links and buttons examples. Use clr-underline to opt into both primary text color and an underline without relying on paragraph context. Hover uses primary-light and keeps the underline. Navigation still underlines only active/current links, even with this class. clr-primary remains a color-only utility.

$clr-body sets base text. $clr-primary-light sets the accent on a.clr-underline:hover. There are no standalone clr-body or clr-primary-light utilities. Changing modes updates semantic values without adding alternate utility names. Literal artwork and demo gradients keep their own colors.

Run npm start after editing Sass. Check text, links, focus outlines, disabled buttons and code examples in both modes. Fixed white text still needs a dark surface. Active light presets adjust some accent colors from the saved original samples for readability; calculated color-pair checks do not establish accessibility for an entire page.

Stop development watchers before npm run build or npm run validate. The build compiles Sass, filters CSS using source classes, and generates the site. Validation uses temporary output and restores CSS inputs. Preview both modes after filtering.