## Summary
Rebuilds Webstudio’s color system, migrates the entire Builder to it,
and introduces a complete dark theme.
A small set of theme colors and contrast controls now drives the
interface through relative CSS colors:
```text
Theme colors and contrast
↓
Light/dark derivation bounds
↓
Derived color families
↓
Reusable semantic colors
↓
Component composition
↓
Builder interface
```
CSS is the runtime source of truth. Light and dark modes share the same
theme inputs, so changing a theme color automatically updates its
surfaces, content, borders, states, and component presentation. The
refactor turns dark mode into a first-class Builder theme rather than a
separately maintained palette.
This is an atomic migration. Legacy color names and compatibility
aliases will not remain after all consumers have moved.
## Scope
- The color source, derivation model, semantic vocabulary, validation,
typing, and Storybook overview.
- Every design-system component.
- Builder, dashboard, authentication, shared UI, Query Builder, stories,
and tests that consume the legacy color scale.
- Removal of the legacy Stitches color scale after its final consumer is
migrated.
- A complete dark theme across application UI while keeping authored
canvas content independent.
- Complete light and dark visual verification.
- Unified browser-test infrastructure: Vitest Browser Mode for Design
System browser contracts and standard Playwright Test for all Builder
E2E workflows.
Literal colors remain only where color is the actual content or belongs
to a deliberately separate system, such as user-authored values,
external previews, brand artwork, data visualization, functional canvas
overlays, and source assets. Every remaining exception must have an
explicit owner.
## Architecture decisions
- Theme authors control six color families and three bounded contrast
controls.
- Relative CSS colors derive the rest of the system.
- Dark mode changes derivation bounds instead of maintaining a second
independent palette.
- Components consume a small reusable semantic vocabulary.
- Component states and exceptional presentation are composed inside
components.
- Builder-specific categorical meaning uses focused composite recipes,
not intent semantics or a larger global vocabulary.
- TypeScript validates public semantic CSS-variable names but does not
generate runtime colors.
- No token-manager dependency, compatibility aliases, or
component-specific public color tokens.
- A new semantic or theme variable is added only when existing semantics
and local composition cannot represent a reusable cross-feature
decision.
## Todo
### Color-system foundation
- [x] Establish direct CSS as the runtime source of truth.
- [x] Define bounded theme colors and contrast controls.
- [x] Derive light and dark modes from the same theme inputs.
- [x] Reduce the semantic inventory to reusable decisions and explicit
accessibility pairs.
- [x] Generate only TypeScript names for public semantic CSS variables.
- [x] Validate layers, references, cycles, consumption, naming,
generated types, and browser-computed contrast.
- [x] Add the Storybook color-system overview and theme controls.
- [x] Document the architecture and its relationship to the public Craft
specification.
### Design-system migration
- [x] Replace every active legacy color consumer in design-system
components and Storybook chrome.
- [x] Compose component states locally without component-specific public
tokens.
- [x] Preserve intentional preview and sample-content colors.
- [x] Add complete positive, negative, warning, informative, and accent
accessibility pairings.
- [x] Validate light and dark scheme-bound references independently.
- [x] Verify the design-system package with typecheck, lint, formatting,
Storybook, and 222 tests.
### Inventory and contract
- [x] Inventory all 319 legacy references across 107 Builder, Query
Builder, story, test, and design-system files.
- [x] Classify every reference as a direct semantic replacement, local
composite recipe, documented literal exception, or removable code.
- [x] Record the intentional authored-content, external-preview,
functional-preview, data-visualization, brand, and source-asset
exceptions.
- [x] Treat the public semantic vocabulary as closed by default and
justify any proposed addition by cross-feature reuse and accessibility
need.
- [x] Keep Builder code limited to typed public variables accepted by
`cssVar()`.
### Theme infrastructure
- [x] Add `system` (default), `light`, and `dark` application
preferences.
- [x] Persist the preference in existing client settings and resolve
`system` through `matchMedia`.
- [x] Apply the resolved scheme before paint and respond to
operating-system changes.
- [x] Expose the persisted theme control under **View → Color scheme**.
- [x] Keep authored canvas documents independent from the application
theme.
- [x] Ensure portals, overlays, embedded surfaces, and third-party
controls receive the correct interface scheme.
### Generic interface migration
- [x] Migrate shared dialogs, project settings, notifications, controls,
and Query Builder.
- [x] Migrate dashboard, authentication, publishing, and shared
application UI.
- [x] Migrate the Builder loading state, topbar, sidebars, navigator,
workspace, footer, settings, pages, alerts, and menus.
- [x] Replace fixed interface literals alongside their owning surfaces.
- [x] Remove the old scrollbar variable and hardcoded loading color.
### Style panel and style-source recipes
- [x] Migrate ordinary style-panel inputs, labels, layouts, spacing,
alignment, menus, property states, and value editors.
- [x] Model style-source provenance, kind, interaction, and error as
separate axes.
- [x] Compose categorical style-source colors from neutral and
accent-relative colors.
- [x] Use negative semantics only for actual errors, not overwritten
provenance.
- [x] Reuse one feature-owned recipe across style-source controls,
badges, menus, and values without adding global tokens.
### Canvas and editors
- [x] Migrate canvas selection, reusable outlines, grid guides, resize
handles, labels, badges, and overlays.
- [x] Keep collaborator colors as data visualization while guaranteeing
readable labels.
- [x] Prevent Builder theme values from leaking into authored content.
- [x] Migrate editor surfaces, selections, autocomplete, lint states,
and tooltips.
- [x] Derive syntax visualization from neutral and accent-relative
colors; reserve intent colors for diagnostics.
### Explicit color domains
- [x] Isolate external search and social previews from the application
scheme.
- [x] Preserve user-authored CSS values, functional color previews, and
checkerboards.
- [x] Review brand surfaces independently in both schemes.
- [x] Document every retained literal in the exception ledger.
### Stories, tests, and legacy removal
- [x] Migrate all affected Builder stories and tests.
- [x] Replace the design-system test that intentionally references the
legacy scale.
- [x] Add theme-preference and scheme-resolution behavior tests.
- [x] Remove the legacy `design-tokens.color` registry.
- [x] Remove the Stitches `colors` scale and `rawTheme.colors`.
- [x] Remove color-name conversion code that exists only for the legacy
scale.
- [x] Add a focused repository check that rejects legacy references.
- [x] Confirm no compatibility mappings or deprecated aliases remain.
### Browser-test infrastructure
- [x] Run pure Design System tests in Node and browser-dependent tests
in Vitest Browser Mode with Playwright Chromium.
- [x] Migrate all 79 Builder E2E workflows from the custom harness to
standard Playwright Test.
- [x] Replace filename-based shard discovery with standard Playwright
sharding.
- [x] Preserve clean-backend shard retries and upload Playwright failure
artifacts in CI.
- [x] Remove the custom runner, registry, and timeout infrastructure.
### Verification and documentation
- [x] Compare light-mode visual regressions directly with `main`; review
every difference rather than accepting snapshots wholesale.
- [x] Add representative dark coverage for dashboard, Builder shell,
style panel, dialogs, editors, canvas tools, and status states.
- [x] Test default and extreme custom-theme presets.
- [x] Verify semantic and categorical-recipe contrast.
- [x] Test first paint, persistence, system changes, portals, and canvas
isolation.
- [x] Run affected tests, typechecks, lint, formatting, and Storybook
checks.
- [x] Review fixture impact; no fixture inputs or generated outputs are
affected.
- [x] Review authoritative `docs/` content and update it where needed.
- [x] Review the final diff and make this checklist reflect delivered
scope.
## Current verification
- Design-system typecheck and generated-type freshness: passed.
- Design-system tests: 222 passed, including the full theme-parameter
contrast sweep and browser component coverage.
- Builder typecheck and production build: passed.
- Theme preference and scheme-resolution tests: 10 passed.
- Scoped Oxlint, formatting, and diff checks: passed.
- Design-system Storybook build and representative light/dark visual
review: passed.
- Builder E2E: 80/80 Playwright entries passed (setup plus 79
workflows).
Ref #3818
Closes #6267
15 KiB
description, icon
| description | icon |
|---|---|
| Craft is the standard for building maintainable and reusable projects with Webstudio. | ruler-triangle |
Craft
Craft is the universal standard for building maintainable, reusable, and portable projects with Webstudio. It defines how to name and use CSS variables, Tokens, and Local styles so that people and shared Marketplace resources can work together without introducing incompatible conventions.
Craft is recommended, but not mandatory. A project can extend Craft for its domain without turning those extensions into requirements for every Craft project.
{% hint style="info" %} Contribute changes to Craft by commenting on this GitHub Discussion. {% endhint %}
{% embed url="https://youtu.be/EeLoBZvlygI" %}
Specification language
Craft uses the following terms to distinguish requirements from guidance:
- Must identifies a requirement for Craft conformance.
- Should identifies a recommendation that may be ignored when a project has a documented reason.
- May identifies an optional feature or extension.
Architecture
Craft has three layers:
Theme variables
↓
Semantic variables
↓
Composite Tokens
Theme variables
Theme variables contain the values that make one theme different from another. They may contain literal values or reference palette variables such as those provided by Open Props.
A theme implementation may use private derivation variables to normalize, bound, or transform its public theme inputs. These variables are implementation details of the theme layer: composite Tokens must not consume them directly, and reusable resources must not require them.
Craft does not require every project to use the same number of theme variables. A project must document its theme variables when it publishes reusable resources or a theme for other projects.
Semantic variables
Semantic variables describe why a value is used rather than what the value
looks like. For example, use --foreground-negative for an error message
instead of consuming a red palette value directly.
Semantic variables must reference public theme variables, private derivation variables within the theme layer, or other semantic variables. They should not contain standalone literal design values.
Composite tokens
A Webstudio Token packages multiple style declarations. Craft calls these composite Tokens to distinguish them from individual values stored in CSS variables.
Composite Tokens must consume semantic variables when a suitable variable exists. They should not consume palette or theme variables directly.
Components, utilities, variants, and sizes are purposes of composite Tokens, not additional layers in the architecture.
Local styles
Use Local for values and declarations that belong to one instance. Move a decision into a CSS variable or composite Token when it becomes reusable.
CSS variables
Craft projects may use Open Props, an MIT-licensed collection of CSS variables, for palettes and scales. Open Props variables are optional theme inputs and utilities; they are not replacements for Craft semantic variables.
Define variables that are shared across a project on Global Root. Define a variable on a closer common ancestor when its meaning is intentionally local to one page, section, or component subtree.
Naming variables
CSS variable names must:
- Use kebab-case.
- Use complete words unless an abbreviation is part of the approved Craft vocabulary.
- Describe purpose rather than visual appearance at the semantic layer.
Semantic color variables use this grammar:
--{category}-{purpose}[-{state}]
- Category is exactly one of
foreground,background,border, oroverlay. - Purpose is one or more kebab-case terms that describe the color's reusable
meaning. Compound purposes place a variation after its base purpose, such as
negative-subtle. - State is an optional final
hover,pressed,selected,disabled, orfocussuffix. Treat the final term as a state only when the project's documented registry declares that name as a state variable. For example,--overlay-interaction-pressedis a pressed interaction overlay, while--foreground-disabledis a registered purpose.
The core color variable list is the registry of universal purposes. Extensions must document their additional names and whether the final term is a purpose or state. An extension may introduce a compound purpose but must not reinterpret a registered core name.
Examples:
--foreground-primary
--overlay-interaction-hover
--border-negative
--overlay-scrim
Palette and scale variables use numbers:
--blue-10
--size-4
Do not encode a literal value in a semantic name:
/* Avoid */
--foreground-gray
--background-blue-hover
/* Prefer */
--foreground-muted
--background-accent
Semantic colors
Craft organizes interface colors into four categories:
- Foreground for text, icons, and other marks drawn over a background.
- Background for canvases, surfaces, controls, and filled states.
- Border for boundaries, separators, and focus indicators.
- Overlay for translucent interaction layers and scrims.
Common purpose and state terms include:
Emphasis purposes: primary, secondary, muted, disabled, inverse
Intent purposes: accent, positive, negative, warning, informative
Purpose variation: subtle
State: hover, pressed, selected, disabled, focus
This vocabulary is not a matrix. Define a semantic variable only for a reusable decision that multiple composite Tokens consume or for an explicit accessibility pairing. Do not generate every combination of category, intent, variation, and state.
Core color variables
The universal baseline is intentionally small:
/* Foreground */
--foreground-primary
--foreground-secondary
--foreground-disabled
/* Background */
--background-primary
--background-secondary
--background-disabled
/* Border */
--border-default
--border-focus
/* Overlay */
--overlay-scrim
Projects extend this baseline as their composite Tokens establish reusable needs. Shared Marketplace resources must declare which variables they require and must not silently depend on undocumented project-specific variables.
Intent extensions commonly use matching foreground, background, border, and paired foreground names:
--foreground-negative
--background-negative
--background-negative-subtle
--border-negative
--foreground-on-negative
Use paired foreground-on-* variables for content placed on a strong semantic
background. The pair remains explicit even when several pairings resolve to
the same value because each pairing defines an independently verifiable
contrast contract.
Compose component states from existing semantic variables inside the composite Token. Shared translucent overlays can express hover and pressed states without creating a resolved state color for every background:
--overlay-interaction-hover
--overlay-interaction-pressed
--overlay-on-inverse-hover
--overlay-on-inverse-pressed
Promote a state color to the semantic layer only when it is independently reusable and composition cannot express the decision. Component-specific color variables are not part of the default Craft architecture. Introduce one only when a component intentionally exposes it as a public theming contract.
For example, checked, on, and current commonly compose a selected
presentation; invalid commonly composes negative foreground and border
colors. These component states do not require new global colors by themselves.
Deriving colors
Semantic colors should remain connected to the theme. Prefer aliases and relative color expressions over duplicated literals:
:root {
color-scheme: light dark;
--seed-neutral: oklch(50% 0.01 250);
--seed-accent: oklch(50% 0.2 255);
--theme-background: light-dark(
oklch(from var(--seed-neutral) 98% 0.002 h),
oklch(from var(--seed-neutral) 17% 0.012 h)
);
--theme-foreground: light-dark(
oklch(from var(--seed-neutral) 20% 0.015 h),
oklch(from var(--seed-neutral) 94% 0.006 h)
);
--theme-accent: light-dark(
oklch(from var(--seed-accent) 54% c h),
oklch(from var(--seed-accent) 72% calc(c * 0.82) h)
);
--background-primary: var(--theme-background);
--foreground-primary: var(--theme-foreground);
--background-accent: var(--theme-accent);
--overlay-interaction-hover: oklch(
from var(--theme-foreground) l c h / 6%
);
}
Define a hue seed once and derive its scheme-specific result. light-dark() may
select between derived expressions when the project supports native
color-scheme. A project may instead override a small shared transformation
profile for each scheme. Do not maintain independent light and dark copies of
the semantic layer.
The example does not prescribe a fixed number of seeds or theme variables. It demonstrates the required separation between authoring inputs, theme colors, and semantic outputs.
Other core variables
Craft retains a small vocabulary for reusable layout, focus, and motion values:
--gap-xs
--gap-s
--gap-m
--gap-l
--spacing-default
--focus-width
--focus-offset
--duration-default
--easing-default
These variables follow the same architecture: their semantic values should derive from documented theme or scale inputs where appropriate.
Interaction states
Use these semantic states consistently:
| State | Meaning |
|---|---|
hover |
A pointing device is over an interactive target. |
pressed |
A target is being activated. CSS :active maps to pressed. |
selected |
An option or item is chosen, current, checked, or switched on. |
disabled |
An interaction is unavailable. |
focus |
A target has visible keyboard focus. |
States such as open, pending, invalid, and application-specific statuses
may affect several properties. Express them with composite Token variants and
reuse the closest semantic colors rather than automatically creating a global
color for each state name.
Accessibility
Craft conformance requires WCAG 2.2 Level AA. Themes and extensions must preserve accessible semantic pairings.
- Normal text must have a contrast ratio of at least 4.5:1 against its background.
- Large text must have a contrast ratio of at least 3:1 against its background.
- Meaningful non-text interface graphics must have a contrast ratio of at least 3:1 against adjacent colors.
- Keyboard focus must remain visible.
- Color must not be the only way to communicate status or state.
- Disabled styling may be subtle, but must not obscure information required to understand the interface.
- Every supported theme must satisfy the same requirements.
Craft additionally recommends meeting the WCAG 2.2 Level AAA Focus Appearance criterion: a custom focus indicator should provide at least a 3:1 change of contrast and an area at least equivalent to a 2 CSS pixel perimeter.
See the WCAG 2.2 criteria for text contrast, non-text contrast, use of color, focus visibility, and focus appearance.
Composite tokens
Composite Tokens combine reusable declarations. Their values should reference CSS variables so a theme can change without editing the Token.
| Purpose | Naming | Examples |
|---|---|---|
| Utility | Kebab-case | margin-auto, flex-gap-small |
| Component | Kebab-case | button, input, card |
| Semantic | Title case | Pricing Card, Team Member |
| Variant | is-{base}-{name} |
is-button-secondary |
| Size | {base}-{size} |
button-small, button-large |
A variant must be used with its base Token. A size Token should contain only the declarations needed to change size.
Prefer a composite Token when a reusable decision needs multiple declarations or coordinated states. Prefer a CSS variable for one reusable value. Use Local for an instance-specific exception.
When multiple Tokens set the same property, the rightmost style source wins. Place Local last when an instance needs to override a Token.
Extensions and exceptions
A project may extend Craft when the core vocabulary cannot express a reusable domain concept.
An extension must:
- Follow the same naming grammar.
- Describe purpose rather than a specific visual value.
- Reuse or derive from existing theme and semantic variables when possible.
- Introduce a new theme value only when an existing value cannot preserve the intended distinction.
- Document its meaning, supported states, accessibility pairings, and theme behavior when it is shared outside the project.
Literal colors are appropriate when the color belongs to user content, an external representation, data visualization, or a functional preview that must not change with the interface theme. Document shared exceptions so they are not mistaken for missing semantic variables.
Project-specific extensions do not become Craft core automatically. Promote an extension only when the same semantic need is reusable across unrelated projects.
Conformance
A project conforms to Craft when:
- Shared composite Tokens use semantic variables where suitable.
- Semantic variables derive from the theme layer or other semantic variables.
- Theme changes do not require editing composite Tokens.
- Variable and Token names follow the Craft grammar.
- Required foreground and background pairings meet the accessibility rules.
- Shared extensions and literal exceptions are documented.
- Reusable resources declare their required Craft variables and extensions.
Conformance does not require every project to define every variable in the reference list. It requires every consumed variable and extension to follow the contract.
Related
- Use Craft – Apply the specification in a Webstudio project
- Craft changelog – Review changes to the standard
- Design tokens – Create and manage reusable composite Tokens
- CSS variables – Define and scope reusable values
- States and selectors – Style interaction states