Repository navigation
The biggest Spruce CSS release so far: design styles (one markup, many looks), a built-in dark mode, new elements, new tokens, more customization options for every element and AI skills. The public Sass API stays compatible with v2: no mixin, function, variable or map key was removed or renamed, and with the default configuration every v2 declaration is still generated. The changes in the default output are listed under Changes in the default output.
Design styles (new)
- NEW Style presets: restyle the same markup with
data-spruce-style="…"on<html>or on any element. Built-in presets:minimal,brutalist,soft,glass,corporate,playful,editorial,terminal. - NEW
$stylesmap (extend or overwrite the presets),$style-presets,$style-shorthands(radius-sm,radius-md,radius-lg,border-width). - NEW
stylessetting (attribute,default,font-path,include) andstylescontent generator (off by default). Set'default'to apply a style at compile time without the attribute. - NEW Style hooks: in custom property mode every component value can be overwritten from any ancestor with a namespaced custom property, like
--spruce-btn-paddingor--spruce-form-control-border-radius. Controlled by the newstyle-hookssetting (default:true). - NEW Presets can ship fonts with a
font-faceslist. The Brutalist preset bundles Archivo and Archivo Black (font/, SIL OFL) with tunedascent-override/descent-override, so uppercase labels are vertically centered; the Editorial preset bundles Fraunces for its headings and uses a sans-serif body. Setfont-pathtonullto skip the@font-facerules. - NEW
generate-style(),generate-style-presets()mixins andstyle-rule-selector()function. Preset rules stop at the boundary of a nested scope with a different style. - NEW
generate-variables()mixin:$hookargument.
Dark mode (new)
- NEW
dark-modecontent generator (off by default): generates the dark color custom properties,color-scheme: darkand the regenerated SVG field icons. - NEW
$default-dark-colorsmap (a complete dark palette); your$dark-colorsmap is deep-merged into it. - NEW
dark-modesetting (selector,light-selector,prefers-color-scheme) to follow the system preference too. - NEW
dark-mode()mixin, which works at the root level and inside a rule. - NEW
generate-field-icons()mixin to regenerate the select, checkbox, radio, switch and validation icons for any color map.
Elements
- NEW
details/summarystyling (detailsgenerator,$detailsmap). - NEW
dialogstyling with backdrop (dialoggenerator,$dialogmap). - NEW
progress(with indeterminate state) andmeterstyling (progressgenerator,$progressmap). The tracks are flat in every browser (Firefox's default gradient on the meter is removed). - NEW
precode block styling andpre codereset,kbdwith border, monospace font stack forcode,kbd,samp,pre. - NEW
videois responsive. - NEW
.sr-only-focusableclass. - NEW Opt-in text utilities (
'utilities': ('text': true)):.text-start,.text-center,.text-end,.text-sm,.text-lg,.text-muted,.text-mono,.text-uppercase,.text-balance,.text-pretty,.text-nowrap,.text-truncate. - NEW Opt-in layout utilities (
'utilities': ('layout': true)):.l-center,.l-stack,.l-cluster,.l-grid,.l-sidebar,.l-switcher,.l-reel, configurable with custom properties.
Buttons
- NEW Variants:
.btn--danger,.btn--outline-danger,.btn--soft-{primary|secondary|danger},.btn--ghost-{primary|secondary|danger},.btn--link. - NEW Modifiers:
.btn--pill,.btn--loading,.btn--disabled/[aria-disabled='true'](it was documented but missing). - NEW
.btn-groupand.btn-group--vertical(btn-groupgenerator,generate-btn-group()mixin). - NEW
btn-variant-soft(),btn-variant-ghost(),btn-variant-link()mixins. - NEW
$btnkeys:box-shadow,disabled-opacity,letter-spacing,line-height. - NEW
generate-btn()mixin:$has-modifiersargument.
Forms
- NEW
.form-range--smand.form-range--lg(they were documented but missing),$form-range-sm,$form-range-lgmaps. - NEW
.form-label--requiredwith therequired-contentandrequired-gapkeys of$form-label;$form-labelline-heightkey. - NEW Read-only state for
.form-control(background-readonlyform color,nullby default). - NEW
$form-controlkeys:box-shadow,letter-spacing.
Tables
- NEW
.table--bordered,.table--middle,.table--sticky-header. - NEW
$tablekeys:border-width,caption-text-align,heading-font-size,heading-font-weight,heading-letter-spacing,heading-text-transform,vertical-align;heading-backgroundtable color.
Tokens, variables and settings
- NEW
$shadowsmap (xs,sm,md,lg,xl,inner), generated as--spruce-shadow-*in custom property mode. - NEW
$z-indexesmap. - NEW
$displaykeys:border-radius-md,border-radius-pill,border-width-base. - NEW
$typographykeys:blockquote-border-width,blockquote-font-size,blockquote-font-style,font-family-mono,font-size-code,font-weight-strong,letter-spacing-base,link-font-weight,link-text-decoration,link-text-decoration-hover,link-text-decoration-thickness,link-text-underline-offset,list-gap,pre-border-radius,pre-padding,text-transform-heading,text-wrap-base,text-wrap-heading. - NEW
$dividerand$mediamaps. - NEW Colors: base
border-strong,focus-ring,kbd-border,muted,overlay,pre-background,pre-foreground,surface,surface-muted; btndanger-*; formbackground-readonly,progress-background,progress-foreground,required; tableheading-background. - NEW Settings:
accent-color,dark-mode,reduced-motion,scroll-margin,style-hooks,styles,utilities.layout,utilities.text. - NEW Generators: content
dark-mode,details,dialog,progress,styles; formbtn-group.
Functions and mixins
- NEW
shadow(),radius(),z-index(),color-alpha(),color-tint()functions. - NEW
breakpoint-down(),breakpoint-between(),container-query()mixins. - NEW
layout-cluster(),layout-switcher(),layout-reel()mixins. - NEW
visually-hidden-focusable(),motion-safe(),motion-reduce(),cover()mixins. - IMPROVEMENT
layout-flex()mixin: accepts the'm:l'gap shorthand. - IMPROVEMENT
visually-hidden()mixin: addsclip-path: inset(50%)next to the deprecatedclip.
AI skills (new)
- NEW The package ships agent skills in the
skills/folder:sprucecss,sprucecss-library(use the Spruce UI components, blocks and pages from the online library),sprucecss-styles,sprucecss-spacing(spacing from the parent),sprucecss-list-layout(lists whose items sit side by side),sprucecss-blocks(block anatomy, components, pages, logical properties),sprucecss-block-rhythm(one background, one padding between the blocks of a page) and one design skill per style preset.
Bug fixes
- FIX
$form-control-lg,$form-control-sm,$form-check-lgused non-existingsize-lg/size-smtypography keys, so theirfont-sizewas alwaysnull. Small and large inputs and large checkboxes now get their intended font sizes. - FIX
.form-check--smand.form-check--lggenerated the$form-control-sm/lgvariables instead of$form-check-sm/lgin custom property mode, so the size modifiers had no effect. - FIX
spacer('xs:m')returned a list with a leadingnull. - FIX The large color input used the physical
heightproperty instead ofblock-sizewithout the custom property mode. - FIX The switch icons used the
'true'string instead of thetrueboolean when getting the raw color. - FIX
config()printed the key name as a separate error before the real error message.
Changes in the default output
These are visual changes with the default configuration; review them when you upgrade.
- Headings use
text-wrap: balance(set'text-wrap-heading': nullin$typographyto turn it off). code,kbd,samp,preuse thefont-family-monostack instead of the browser'smonospace.kbdhas a border and an inset shadow;prehas a background, padding and radius, andpre codeno longer gets the inline code background.details,dialog,progressandmeterare styled. The selectors use:where(), so their specificity is zero and any of your existing styles win. Turn them off with thedetails,dialogandprogressgenerators.htmlgetsaccent-color: color('primary')for native controls (turn it off with theaccent-colorsetting).- The small/large form control and checkbox fixes above change their sizes.
- In custom property mode the component custom properties reference their hooks (
--spruce-padding: var(--spruce-btn-padding, 0.75em 1em));figcaption, links and lists use custom properties. The computed values are the same.
Tooling
- Update every dependency; replace the unmaintained
npm-run-allwithnpm-run-all2. - Replace Jest with the Node.js test runner (
node --test); the Sass test suite works again and covers the new functions. - Add
sassandstyleentry points topackage.json(forpkg:sprucecssimports and CSS bundlers). - NEW
css/spruce.complete.cssandcss/spruce.complete.min.css: a compiled bundle with every opt-in feature (dark mode, style presets, layout and text utilities) for plain CSS and CDN users. - The CI workflow runs the unit tests and the production build.
- The preview got a style switcher, an overview page, a styles comparison page and pages for every new element, layout and utility.