Introduction
WovenUI core is a human-readable, utility-first CSS framework written in SCSS, and the foundation layer of a design system: design tokens, light, dark, inverse and high-contrast themes, utility classes, the same utilities as apply() mixins, and a compiler that stops on mistakes. SCSS goes in, plain CSS comes out, and no JavaScript ships to the browser.
One card, three ways
Section titled “One card, three ways”The same card, written three ways. All three render the same, and every value is a --wu-* token, so the card follows the active theme without extra code.
1. Utility classes
Section titled “1. Utility classes”<article class="p-4 p-6@md bg-surface text-regular border rounded-lg shadow-sm hover:shadow-md"> <h3 class="text-lg font-semibold">Invoice #1042</h3> <p class="mt-2 text-muted">Due in 5 days. Hover the card for a deeper shadow.</p></article>2. apply()
Section titled “2. apply()”Every class is also a mixin. apply() takes them in one call, with the state or breakpoint written after the utility.
@use "@wovenui/core" as *;
.card { @include apply(p(4), p(6) md, bg(surface), text-color(regular), border(1), rounded(lg), shadow(sm), shadow(md) hover);}.card__title { @include apply(font-size(lg), font(semibold));}.card__text { @include apply(mt(2), text-color(muted));}.card { padding: var(--wu-space-4); background-color: var(--wu-bg-surface); color: var(--wu-text-regular); border-width: var(--wu-border-width-1); border-style: var(--wu-border-style); border-color: var(--wu-border-regular); --wu-border-style: solid; border-radius: var(--wu-radius-lg); box-shadow: var(--wu-shadow-sm);}.card:hover { box-shadow: var(--wu-shadow-md);}@media (min-width: 768px) { .card { padding: var(--wu-space-6); }}
.card__title { font-size: var(--wu-font-size-lg); font-weight: var(--wu-font-weight-semibold);}
.card__text { margin-top: var(--wu-space-2); color: var(--wu-text-muted);}3. Plain SCSS with token()
Section titled “3. Plain SCSS with token()”token() returns the custom property for a token name and checks the name at compile time.
@use "@wovenui/core" as *;
.card { padding: token(space-4); background-color: token(bg-surface); color: token(text-regular); border: token(border-width-1) solid token(border-regular); border-radius: token(radius-lg); box-shadow: token(shadow-sm);
&:hover { box-shadow: token(shadow-md); }
@include media-up(md) { padding: token(space-6); }}.card__title { font-size: token(font-size-lg); font-weight: token(font-weight-semibold);}.card__text { margin-top: token(space-2); color: token(text-muted);}.card { padding: var(--wu-space-4); background-color: var(--wu-bg-surface); color: var(--wu-text-regular); border: var(--wu-border-width-1) solid var(--wu-border-regular); border-radius: var(--wu-radius-lg); box-shadow: var(--wu-shadow-sm);}.card:hover { box-shadow: var(--wu-shadow-md);}@media (min-width: 768px) { .card { padding: var(--wu-space-6); }}
.card__title { font-size: var(--wu-font-size-lg); font-weight: var(--wu-font-weight-semibold);}
.card__text { margin-top: var(--wu-space-2); color: var(--wu-text-muted);}Use classes to prototype, apply() for semantic class names in your own stylesheets, and token() where you write plain CSS properties. They share one scale and one set of tokens.
What you get
Section titled “What you get”Tokens follow the theme
Section titled “Tokens follow the theme”Colors, spacing, radii, type, shadows, z-index and motion are --wu-* custom properties. Theme tokens are redefined per theme, so the same bg-surface is white in light and dark gray in dark.
:root, [data-theme=light] { --wu-bg-surface: #fff; --wu-text-regular: #1a1a1a;}[data-theme=dark], [data-theme=inverse] { --wu-bg-surface: #2e2e2e; --wu-text-regular: #f1f1f1;}- Any element.
data-theme="light"ordata-theme="dark"re-themes that element and everything inside it. - Inverse.
data-theme="inverse"is always the opposite of the page: dark on a light page, light on a dark page. - Operating system. Leave
data-themeoff the root and the tokens followprefers-color-scheme. - High contrast. Set
$high-contrast-lightand$high-contrast-darkwith the tokens to change; they apply underdata-contrast="high".
<div class="flex wrap gap-4"> <div data-theme="light" class="grow p-4 bg-surface text-regular border rounded-lg">Light</div> <div data-theme="dark" class="grow p-4 bg-surface text-regular border rounded-lg">Dark</div> <div data-theme="inverse" class="grow p-4 bg-surface text-regular border rounded-lg">Inverse</div></div>apply() takes any value
Section titled “apply() takes any value”A unitless number is a configured key; a value with a unit is used as written. States and breakpoints follow the utility.
@use "@wovenui/core" as *;
.hero { @include apply(p(1.5rem), max-width(42rem), rounded(12px), bg(brand-subtle), shadow(md) hover, p(3rem) lg);}.hero { padding: 1.5rem; max-width: 42rem; border-radius: 12px; background-color: var(--wu-brand-subtle);}.hero:hover { box-shadow: var(--wu-shadow-md);}@media (min-width: 1024px) { .hero { padding: 3rem; }}Mistakes stop the build
Section titled “Mistakes stop the build”Core checks keys, colors, tokens and modifiers at compile time. The error names the valid options instead of writing broken CSS.
.card { @include apply(p(7)); }Error: "p: 7 is not a configured key. Valid keys: 0, 1, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24, 32, 40, 48, 56, 64. Write a unit for a custom value (7px, 7rem).".card { @include apply(bg(primary)); }Error: "bg(primary): unknown color. Use a role (brand, success, danger, warning, info), a palette name (gray, red, blue, green, yellow, purple, pink), a theme word (base, surface, alternate, raised, hover, selected, disabled), a hex color, a CSS color name, a color function (rgb(), hsl(), hwb(), lab(), lch(), oklab(), oklch(), color(), color-mix(), light-dark()), a keyword (currentcolor, inherit, initial, unset, revert, revert-layer) or var()."Component styles add only their own rules
Section titled “Component styles add only their own rules”Each CSS module or component <style> block is a separate compile. Load @wovenui/core/mixins there: it has the same apply(), mixins, functions and configuration, and outputs no CSS of its own. Load @wovenui/core once, in the global stylesheet, for the tokens and base styles.
@use "@wovenui/core/mixins" as *;
.card { @include apply(p(4), p(6) md, bg(surface), text-color(regular), border(1), rounded(lg), shadow(sm), shadow(md) hover);}Same .card, compiled through |
Expanded | Compressed |
|---|---|---|
@wovenui/core/mixins |
467 bytes | 403 bytes |
@wovenui/core |
49,173 bytes | 43,390 bytes |
The mixins output is the .card rules shown in apply() and nothing else.
Right to left through logical utilities
Section titled “Right to left through logical utilities”Logical utilities (ps, me, ms-auto, border-start, text-start) write inline-start and inline-end properties, so one rule mirrors with dir="rtl".
<div class="flex x-center gap-2 ps-4 py-2 border-s-4 border-brand text-start"> <span>Inbox</span> <span class="ms-auto">12</span></div>.nav-item { @include apply(flex, x-center, gap(2), ps(4), py(2), border-start(4, solid, brand), text-start);}.nav-item__count { @include apply(ms-auto);}Accessible defaults
Section titled “Accessible defaults”- Focus ring. Base buttons and fields show an outline on
:focus-visible, from the focus tokens. - Screen reader text.
.sr-onlyhides text visually and keeps it in the accessibility tree. - Contrast.
text-on-{role}picks the higher-contrast text color for each role fill, and warns at compile time when it falls below 4.5:1.
@layer base { button:focus-visible, input[type=submit]:focus-visible, input[type=button]:focus-visible, input[type=reset]:focus-visible { outline: var(--wu-border-focus-width) solid var(--wu-border-focus); outline-offset: var(--wu-border-focus-offset); }}<button><svg aria-hidden="true"></svg><span class="sr-only">Close</span></button>Editor support
Section titled “Editor support”The WovenUI extension for VS Code adds completion, hover documentation, color swatches and diagnostics with quick fixes for apply(), utility classes and tokens, read from the core version installed in your project. See VS Code extension.
A guide for AI assistants
Section titled “A guide for AI assistants”/llms-full.txt is the complete WovenUI guide in one file: every mixin, the token system, configuration, errors and a table of wrong and correct names. Drop it into a project so an AI assistant writes valid WovenUI code.
Install
Section titled “Install”npm install -D sass @wovenui/coreCore requires Sass 1.79 or later, below 2.0. Installation covers loading, configuration and the prebuilt CSS.