Color Swatch
Color sample square with a label, for token docs.
<arc-color-swatch>Overview
ColorSwatch shows a square of color with a label under it, for token docs, palettes and theme previews. color is applied as an inline background-color, so it takes any CSS color: hex, rgb, hsl or a name. Without a label, the swatch shows the color value itself.
The sizes sm, md and lg are 32px, 48px and 64px squares, with corners of --radius-sm, --radius-md and --radius-lg. The square has role="img" and an aria-label of "Color: " followed by the label.
Guidelines
Do
- Lay swatches out in a flex or grid row to show a palette
- Give each swatch a readable label in token docs, such as "Primary"
- Use lg for a large palette display and sm in token tables
- Group swatches by kind: accents, neutrals, semantic colors
- Use hex values throughout token reference docs
Don't
- Don't use it to pick a color. It only displays one. Use ColorPicker
- Don't show a transparent or semi-transparent color without a visible background behind it
- Don't mix swatch sizes in one row
- Don't write labels longer than about 10 characters. Longer ones are cut off
Features
- The label is monospace at the small text size, at most 80px wide, and cut off with an ellipsis
- On hover the border brightens and an accent-primary glow appears
Preview
Blue
Violet
Success
Warning
Error
Usage
<arc-color-swatch color="#4d7ef7" label="Primary"></arc-color-swatch>
<arc-color-swatch color="#8b5cf6" label="Violet"></arc-color-swatch>import { ColorSwatch } from '@arclux/arc-ui-react';
export default function Example() {
return (
<>
<ColorSwatch color="#4d7ef7" label="Primary" />
<ColorSwatch color="#8b5cf6" label="Violet" />
</>
);
}<script setup>
import { ColorSwatch } from '@arclux/arc-ui-vue';
</script>
<template>
<ColorSwatch color="#4d7ef7" label="Primary" />
<ColorSwatch color="#8b5cf6" label="Violet" />
</template><script>
import { ColorSwatch } from '@arclux/arc-ui-svelte';
</script>
<ColorSwatch color="#4d7ef7" label="Primary" />
<ColorSwatch color="#8b5cf6" label="Violet" />import { Component } from '@angular/core';
import { ColorSwatch } from '@arclux/arc-ui-angular';
@Component({
imports: [ColorSwatch],
template: `
<arc-color-swatch color="#4d7ef7" label="Primary"></arc-color-swatch>
<arc-color-swatch color="#8b5cf6" label="Violet"></arc-color-swatch>
`,
})
export class MyComponent {}import { ColorSwatch } from '@arclux/arc-ui-solid';
export default function Example() {
return (
<>
<ColorSwatch color="#4d7ef7" label="Primary" />
<ColorSwatch color="#8b5cf6" label="Violet" />
</>
);
}import { ColorSwatch } from '@arclux/arc-ui-preact';
export default function Example() {
return (
<>
<ColorSwatch color="#4d7ef7" label="Primary" />
<ColorSwatch color="#8b5cf6" label="Violet" />
</>
);
}<!-- Auto-generated by @arclux/prism — do not edit manually -->
<!-- arc-color-swatch — requires color-swatch.css + base.css (or arc-ui.css) -->
<span class="arc-color-swatch">
<div class="swatch">
<div
class="swatch__color"
style="background-color:Color"
role="img"
></div>
<span class="swatch__label"></span>
</div>
</span><!-- Auto-generated by @arclux/prism — do not edit manually -->
<!-- arc-color-swatch — self-contained, no external CSS needed -->
<style>
.arc-color-swatch .swatch__color:hover { border-color: rgb(51, 51, 64);
box-shadow: 0 0 12px rgba(77, 126, 247, 0.1); }
</style>
<span class="arc-color-swatch" style="display: inline-flex">
<div class="swatch" style="display: flex; flex-direction: column; align-items: center; gap: 8px">
<div
class="swatch__color" style="border-radius: 10px; border: 1px solid rgb(34, 34, 41)"
style="background-color:Color"
role="img"
></div>
<span style="font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 11px; color: rgb(124, 124, 137); text-align: center; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap"></span>
</div>
</span>API
colorstring'#4d7ef7'- Any valid CSS color value applied as the swatch background
labelstring''- Display label below the swatch; falls back to the color value if empty
size'sm' | 'md' | 'lg''md'- Controls swatch dimensions: sm (32px), md (48px), lg (64px)