Components Library Operations TokenSwatchGrid

TokenSwatchGrid

Grouped theme-token swatches with usage notes and contrast labels.

Live demo

01

Theme tokens

Token swatch grid

chrome

#ffffff

surface

--surface

Primary app panels

AA
#f8fafc

surface 2

--surface-2

Inset surfaces

AA

brand

#0f766e

brand primary

--brand-primary

Primary actions

AA
#be123c

brand accent

--brand-accent

Visual QA accents

AA

semantic

#dcfce7

status pass

--status-pass

Passing gates

AA
#fef3c7

status review

--status-review

Needs review

AA

Implementation

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

03

What 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 label

Props 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
PropTypeDescription
tokensTokenSwatch[]Token rows with group, value, and usage.
titlestringGrid heading.