Components Library Operations TokenSwatchGrid
TokenSwatchGrid
Grouped theme-token swatches with usage notes and contrast labels.
Live demo
01Theme tokens
Token swatch grid
chrome
#ffffff
surface
--surface Primary app panels
AA#f8fafc
surface 2
--surface-2 Inset surfaces
AAbrand
#0f766e
brand primary
--brand-primary Primary actions
AA#be123c
brand accent
--brand-accent Visual QA accents
AAsemantic
#dcfce7
status pass
--status-pass Passing gates
AA#fef3c7
status review
--status-review Needs review
AAImplementation
02 TokenSwatchGrid.svelte
<script lang="ts">
import TokenSwatchGrid from '$lib/components/TokenSwatchGrid.svelte';
</script>
β
<TokenSwatchGrid {tokens} />TokenSwatchGrid groups tokens by purpose and calculates simple contrast labels for hex values. It is a lightweight review surface for design-system inventory before full theme inspection.
Logic explainer
03What Does It Do? (Plain English)
TokenSwatchGrid displays theme tokens as grouped swatches with usage notes and quick contrast labels. It is useful before or beside ThemeTokenInspector when teams need to review the actual design-token inventory.
How It Works (Pseudo-Code)
receive token swatches
group tokens by chrome, brand, semantic
calculate optional contrast ratio
render color cards with token name, value, usage, and labelProps Reference
| Prop | Type | Default | Description |
|---|---|---|---|
tokens |
TokenSwatch[] |
Required | Token definitions with name, color value, group, and usage. |
title |
string |
"Token swatch grid" |
Heading above the swatches. |
Dependencies
No external dependencies.
API
04| Prop | Type | Description |
|---|---|---|
tokens | TokenSwatch[] | Token rows with group, value, and usage. |
title | string | Grid heading. |