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

Swatch

API and Development

View SourceOpens in a new tabSubmit IssueOpens in a new tab
Import Swatch, SwatchPattern, and SwatchShape from @prepared911/ui/swatch. Re-exported types: SwatchProps, SwatchMeaningfulProps, SwatchDecorativeProps, and VectorPaint / VectorPaintToken from the swatch entry (vector paint types live in packages/ui/src/parts/vector-paint/types.ts). There is no className, style, or as. Fixed 12×12 box; no size prop. Consumers may pass data-* attributes the same way as on Image and Shape.
Props
NameTypeDefaultDescription
labelLocalizedMessage—Accessible name; renders role="img" and aria-label.
patternSwatchPattern—Which pattern to draw.
shapeSwatchShape—Filled or stroked circle. Filled or stroked square. Horizontal line mark. Pattern family.
decorativeboolean—When omitted or false, the swatch is meaningful and must supply label. Marks the swatch as decorative. Renders aria-hidden="true" and focusable="false".
fillVectorPaint—Fill paint. Circle and Square use fill; Line and Pattern prefer stroke, then fill.
strokeVectorPaint—Stroke paint. Circle and Square outline when set; Line and Pattern use stroke, then fill.
Discriminated shape and pattern
SwatchProps is a union over shape:
  • shape: SwatchShape.Circle | Square | Line: do not pass pattern.
  • shape: SwatchShape.Pattern: pattern: SwatchPattern is required. TypeScript rejects pattern on other shapes.
Meaningful vs decorative is a separate union: either label (and optional decorative?: false) or decorative: true without label.
SwatchShape
MemberSerialized valueDescription
CirclecircleFilled or stroked circle (legend dot).
SquaresquareFilled or stroked square.
LinelineHorizontal line segment (series line).
PatternpatternNon-solid marks; requires pattern.
SwatchPattern
MemberSerialized valueDescription
DasheddashedDashed ring matching chart comparison series swatches.
DotteddottedDotted ring.
HatchedhatchedDiagonal hatch fill.
VerticesverticesOutlined polygon with square corner markers (GIS layer style).
VectorPaint (fill, stroke)
Foreground token (except Inherit) | ChartColor | DataColor. On Circle and Square, fill fills the solid and stroke outlines when set. On Line and Pattern, paint resolves to stroke, then fill for the mark geometry.
Storybook
The registry links the root `Default` story. Open `Swatch/Props` for every shape and pattern, legend row composition, GIS `DataColor` fixtures, and meaningful vs decorative examples.
DefaultOpens in a new tab
Previous
Swatch / Usage
Next
Swatch / Accessibility
On this page
Props
Discriminated shape and pattern
SwatchShape
SwatchPattern
VectorPaint (fill, stroke)
Storybook