Axon 911 Frontend Docs
    Loading navigation…
U
User
Switch to light mode
  1. Components
  2. Swatch
  3. Usage

Swatch

Usage

Overview
Swatch renders a fixed 12×12 color mark inside a root svg (viewBox="0 0 12 12", layout box from --space-12). Use it as the visual key beside legend text, layer lists, and tooltips. Paint flows through design tokens, ChartColor, or DataColor; there is no className, style, or as. Chart internals reuse the same geometry through ChartSwatch, a thin wrapper that paints with currentColor instead of vector-paint props. There is no size prop in v1: every instance is 12×12 user units on screen.
When to use
  • Chart or dashboard legend rows (dot, line, dashed comparison series, hatch, GIS-style vertices).
  • Layer or series keys in lists and tooltips where the mark must match series paint.
  • Marks that need third-party colors via DataColor on fill or stroke.
When not to use
NeedUse instead
Custom silhouette or arbitrary path in user spaceShape
Online, degraded, or severity presence beside a label (not a data series)Status dot
Product-owned emphasis without a legend keyForeground on Text or Icon
Raster, URL, or inline SVGR artworkImage
Arbitrary styling escape hatchesNot supported on Swatch
SwatchShape
ShapeWhat is drawnWhen to choose
CircleSolid circle (r="6" centered in the 12×12 box).Default legend dot; filled area series.
SquareSolid 12×12 rectangle filling the view box.Area or category marks that read as a tile.
LineHorizontal segment (strokeWidth 2) across the box.Line series in a legend.
PatternOne of SwatchPattern (see below). Requires pattern.Comparison series, hatch fills, or GIS polygon symbology without a custom path.
pattern is a type error unless shape is Pattern.
SwatchPattern
Only valid with shape={SwatchShape.Pattern}.
PatternWhat is drawnWhen to choose
DashedRing with stroke-dasharray="3 2" (same geometry chart uses for dashed comparison series).Secondary or comparison line that must differ from a solid dot without changing hue.
DottedRing with stroke-dasharray="1 2" and round caps.Lighter or tertiary series distinction.
HatchedRect filled with a diagonal hatch pattern in defs.Area fills that need texture, not only hue.
VerticesOutlined square (polyline) plus square corner markers (path).GIS layer styles that show an outlined polygon with vertex handles.
Paint (fill and stroke)
fill and stroke accept VectorPaint: Foreground tokens (except Inherit), ChartColor, or DataColor. See Data color for the prefer palette rule: tokens and ChartColor for anything Axon 911 owns; DataColor only when third-party data cannot be mapped (for example ESRI layer colors).
Shape familyChannel behavior
Circle, Squarefill paints the solid; optional stroke outlines the shape with a 1-unit ring drawn inside the 12×12 box, so the mark keeps its size.
Line, PatternGeometry uses stroke, falling back to fill when stroke is omitted (stroke ?? fill). fill on the props is not painted as a separate fill channel for these shapes, except Vertices, whose corner squares are filled with the same paint.
Omitted paint on a channel resolves to none at render time. Invalid DataColor re-validates at paint time and falls back to none.
Legend row composition
Pair a decorative swatch with visible series copy. The text carries the name; the swatch carries color and shape.
Use decorative: true for this pattern. Reserve label for swatches that must stand alone without adjacent text (see Accessibility).
Meaningful vs decorative
Same union as Shape and Image inline SVG:
  • Meaningful: label (LocalizedMessage) → role="img" and aria-label on the root svg.
  • Decorative: decorative: true → aria-hidden="true" and focusable="false".
  • Passing neither or both is a type error.
Related
  • Data color
  • Shape
  • Status dot
Previous
Stepper / Accessibility
Next
Swatch / API and Development
On this page
Overview
When to use
When not to use
SwatchShape
SwatchPattern
Paint (fill and stroke)
Legend row composition
Meaningful vs decorative
Related