Skip to main content

Customize

CSS variables

felt-css is plain CSS: every colour, radius, space and shadow is a custom property. Override them to make the toolkit yours — no Sass, no build.

View page source on GitHub

Naming#

Like Bootstrap's --bs-*, every public variable of felt-css starts with --felt-, so it doesn't collide with your own --primary or --border:

  • Global variables on :root: --felt-primary, --felt-radius, --felt-body-bg … (on this page).
  • Component variables on the component, named after Bootstrap's: .btn has --felt-btn-bg where Bootstrap has --bs-btn-bg. Each component page lists them under “CSS”.
  • Felt variables that only act in the felt look carry a material word: texture, sheet, nap, wool, patch, groove, seam, thread or stitch (--felt-thread-strength, --felt-patch-shadow). A plain word like --felt-shadow is always a variable of both looks. See Felt.
  • --_name variables are internal: they may change in any release.

The tables below are generated from the same source as felt.css; the Bootstrap column names the Bootstrap variable each one stands for.

Overriding#

All global variables live in @layer tokens. Any unlayered rule of yours wins over them, so overriding is just redefining:

:root {
  --felt-font: "Atkinson Hyperlegible", system-ui, sans-serif;
  --felt-radius: 6px;
  --felt-container-max: 1200px;
}

Variables can also be overridden on any element for that part of the page, like Bootstrap's component variables:

Badge
<div style="--felt-primary: var(--felt-moss); --felt-primary-ink: #fff">
  <button type="button" class="btn btn-primary">Moss instead of denim</button>
  <span class="badge text-bg-primary">Badge</span>
</div>

Variables that differ between the looks (most colours, the radii) are set on :root for clean and again on :root[data-look="felt"]. To change a value for one look only, override it there: :root[data-look="felt"] { --felt-radius: 16px; }.

Colors#

Theme colours and the palette are on Color. Body, surfaces and text:

TokenValueBootstrapUsed for
--felt-body-bglight-dark(#f6f7f9, #212529)
felt light-dark(#dbcdb7, #242220)
--bs-body-bgPage background
--felt-body-colorlight-dark(#1f2633, #dee2e6)
felt light-dark(var(--felt-navy), #efe7da)
--bs-body-colorBody text
--felt-emphasis-colorlight-dark(#000, #fff)
felt light-dark(#0e1526, #fffaf2)
--bs-emphasis-colorStrongest text (.text-body-emphasis)
--felt-secondary-colorlight-dark(#677084, #a2aab4)
felt light-dark(#564f41, #b8ad9c)
--bs-secondary-colorSecondary text (.text-body-secondary, .text-muted, form text)
--felt-tertiary-colorlight-dark(#8a92a3, #7d858f)
felt light-dark(#8d8574, #8f8676)
--bs-tertiary-colorTertiary text: disabled links and items, placeholders' neighbours (.text-body-tertiary)
--felt-surfacelight-dark(#fff, #2b3035)
felt light-dark(#faf5ee, #34312d)
Cards, list groups, accordions, toasts
--felt-surface-sunklight-dark(#f1f3f5, #1c1f23)
felt light-dark(#ece4d4, #2d2a27)
--bs-secondary-bgWells, code blocks, readonly fields
--felt-surface-raisedlight-dark(#f8f9fa, #343a40)
felt light-dark(#fffcf7, #413c37)
--bs-tertiary-bgSlightly raised surfaces: light buttons, .alert-light, .table-light
--felt-surface-overlaylight-dark(#fff, #343a40)
felt light-dark(#fdf9f2, #48423c)
Dropdowns, popovers, modals, offcanvas: never darker than what they lie on
--felt-surface-hoverlight-dark(#eef0f3, color-mix(in oklab, var(--felt-body-color) 8%, var(--felt-surface)))
felt light-dark(rgb(90 70 40 / .07), rgb(255 240 220 / .06))
Hover on neutral surfaces (felt: a translucent shade, so the fibres run through)
--felt-surface-pressedlight-dark(#d4d9e0, color-mix(in oklab, var(--felt-body-color) 18%, var(--felt-surface)))
felt light-dark(rgb(90 70 40 / .18), rgb(255 240 220 / .14))
Pressed and chosen neutral surfaces
--felt-fieldlight-dark(#fff, #212529)
felt light-dark(#fffdf8, #2b2724)
Inputs and selects
--felt-field-addonlight-dark(#f1f3f5, #2b3035)
felt light-dark(#f3eee4, #3a3530)
Input-group addons and the file button: a step lighter than the field in dark mode
--felt-field-disabledlight-dark(#e9ecef, #343a40)
felt light-dark(#e4dac7, #3a3631)
Disabled fields, a step past readonly (--felt-surface-sunk)
--felt-field-invalidvar(--felt-field)
felt light-dark(#fdf3ee, #3a2823)
Invalid fields
--felt-border-width1px--bs-border-widthHairlines
--felt-border-stylesolid--bs-border-styleHairlines
--felt-border-colorlight-dark(#e2e5ea, #41474f)
felt light-dark(#c9bba3, #48423b)
--bs-border-colorHairlines (felt: hidden under the seams, but they keep their width)
--felt-border-color-stronglight-dark(#858f9e, #737b84)
felt light-dark(#847b6a, #857a6c)
Control outlines that reach 3:1 (checkboxes, radios)
--felt-link-decorationunderline--bs-link-decorationLinks
--felt-link-colorlight-dark(var(--felt-primary), #8fb2e8)
felt light-dark(#2e5085, #8fb2e8)
--bs-link-colorLinks; .link-* set it too
--felt-tracklight-dark(#e3e7ec, #3a4047)
felt light-dark(rgb(90 70 40 / .16), rgb(0 0 0 / .36))
The empty part of progress bars, ranges and the off switch; use it for tracks of your own. Felt: one groove pressed into the felt, translucent
--felt-backdroplight-dark(rgb(16 24 40 / .45), rgb(0 0 0 / .6))
felt light-dark(rgb(50 35 15 / .26), rgb(10 8 5 / .5))
--bs-backdrop-bg
--bs-modal-backdrop-bg
--bs-offcanvas-backdrop-bg
Modal and offcanvas backdrops
--felt-highlight-bgvar(--felt-warning-subtle)
felt light-dark(#f0d8a2, color-mix(in oklab, var(--felt-warning) 35%, var(--felt-surface)))
--bs-highlight-bg<mark> and .mark
--felt-highlight-colorinherit--bs-highlight-colorText in <mark>
--felt-code-colorvar(--felt-danger-emphasis)--bs-code-colorInline <code>

Interaction#

TokenValueBootstrapUsed for
--felt-hover-inklight-dark(#000, #fff)What fills are mixed with on hover
--felt-press-ink#000What fills are mixed with when pressed
--felt-hover-mix8%How much of it a hovered fill takes
--felt-active-mix14%How much of it a pressed fill takes
--felt-select-mix18%A neutral button pressed or chosen: a clear step past its hover
--felt-disabled-opacity.55 dark .45Disabled controls in the clean look (felt pieces fade into the page instead)
--felt-focus-ring-colorlight-dark(color-mix(in oklab, var(--felt-link-color) 80%, transparent), color-mix(in oklab, var(--felt-link-color) 60%, transparent))--bs-focus-ring-colorFocus rings, 3:1 or more against the page; .focus-ring-* set it too
--felt-focus-ring-width.25rem--bs-focus-ring-widthFocus rings of fields and .focus-ring
--felt-focus-ring-x0.focus-ring: horizontal offset
--felt-focus-ring-y0.focus-ring: vertical offset
--felt-focus-ring-blur0.focus-ring: blur

Type#

TokenValueBootstrapUsed for
--felt-fontsystem-ui, -apple-system, "Segoe UI", Roboto, sans-serif--bs-body-font-family
--bs-font-sans-serif
Body font
--felt-font-headingvar(--felt-font)Headings
--felt-font-monoui-monospace, SFMono-Regular, Menlo, Consolas, monospace--bs-font-monospaceCode
--felt-body-font-size1rem--bs-body-font-sizeBody text
--felt-body-font-weight400--bs-body-font-weightBody text
--felt-body-line-height1.5--bs-body-line-heightBody text
--felt-heading-colorinherit--bs-heading-colorHeadings
--felt-body-text-alignstartBody text

Spacing, radius and shadows#

TokenValueBootstrapUsed for
--felt-space-1.25remSpacer 1, the same scale as the spacing utilities
--felt-space-2.5remSpacer 2, the same scale as the spacing utilities
--felt-space-31remSpacer 3, the same scale as the spacing utilities
--felt-space-41.5remSpacer 4, the same scale as the spacing utilities
--felt-space-53remSpacer 5, the same scale as the spacing utilities
--felt-container-max1080pxWidth of .container
--felt-breakpoint-xs0--bs-breakpoint-xsBreakpoint xs (for scripts; media queries can't read it)
--felt-breakpoint-sm576px--bs-breakpoint-smBreakpoint sm (for scripts; media queries can't read it)
--felt-breakpoint-md768px--bs-breakpoint-mdBreakpoint md (for scripts; media queries can't read it)
--felt-breakpoint-lg992px--bs-breakpoint-lgBreakpoint lg (for scripts; media queries can't read it)
--felt-breakpoint-xl1200px--bs-breakpoint-xlBreakpoint xl (for scripts; media queries can't read it)
--felt-breakpoint-xxl1400px--bs-breakpoint-xxlBreakpoint xxl (for scripts; media queries can't read it)
--felt-radius-sm6px
felt 5px
--bs-border-radius-smCorner radius sm
--felt-radius10px
felt 12px
--bs-border-radiusCorner radius
--felt-radius-lg14px
felt 18px
--bs-border-radius-lgCorner radius lg
--felt-radius-xl20px
felt 24px
--bs-border-radius-xlCorner radius xl
--felt-radius-xxl32px
felt 36px
--bs-border-radius-2xl
--bs-border-radius-xxl
Corner radius xxl
--felt-radius-pill999px--bs-border-radius-pillPills
--felt-shadow-sminset 0 1px 0 light-dark(transparent, rgb(255 255 255 / .04)), 0 1px 2px light-dark(rgb(16 24 40 / .06), rgb(0 0 0 / .3))--bs-box-shadow-smClean-look shadows, darker in dark mode
--felt-shadowinset 0 1px 0 light-dark(transparent, rgb(255 255 255 / .04)), 0 1px 3px light-dark(rgb(16 24 40 / .08), rgb(0 0 0 / .35)), 0 1px 2px light-dark(rgb(16 24 40 / .04), rgb(0 0 0 / .2))--bs-box-shadowClean-look shadow of cards
--felt-shadow-lg0 12px 32px -8px light-dark(rgb(16 24 40 / .22), rgb(0 0 0 / .6)), 0 2px 6px light-dark(rgb(16 24 40 / .08), rgb(0 0 0 / .3))--bs-box-shadow-lgClean-look shadow of what floats: menus, modals, toasts

Images#

TokenValueBootstrapUsed for
--felt-gradientlinear-gradient(180deg, rgb(255 255 255 / .15), rgb(255 255 255 / 0))
felt var(--felt-texture), var(--felt-patch-dome)
--bs-gradient.bg-gradient: a sheen from the top; on felt the felt keeps its texture and swells like a patch
--felt-select-chevronvar(--_chevron-clean) dark var(--_chevron-clean-dark)
felt var(--_chevron-felt) dark var(--_chevron-felt-dark)
--bs-form-select-bg-imgThe select's arrow: an image, so one per look and colour mode