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

Data color

API and Development

View SourceOpens in a new tabSubmit IssueOpens in a new tab
Import toDataColor and the DataColor type from @prepared911/ui/data-color. There is no React component: the entry point brands strings at the data boundary.
toDataColor
NameTypeDefaultDescription
valuestringrequiredRaw color from third-party data. Trimmed for validation; returned unchanged when valid.
returnsDataColor | undefined—Branded color, or undefined when validation fails.
Example
DataColor
Opaque branded string. Do not cast arbitrary strings; use toDataColor. Components re-validate at paint time.
Storybook
No dedicated stories ship on this entry point; see Shape and Swatch for painted examples.
Enforcement
DataColor extends string, so plain string props do not block it at compile time. Enforcement targets where paint is allowed:
  • Type tests reject DataColor on color-semantic props (Box background, Text foreground, Icon foreground): packages/ui/src/components/data-color/scope.type-test.ts
  • Scope scan: only Shape, Swatch, vector-paint, and the model may reference DataColor for paint: packages/ui/tests/data-color-scope.test.ts
  • Oxlint: design-system/to-data-color-call (warn): calls to toDataColor from any @prepared911/ui entry point and as DataColor casts, in apps, remotes and packages
Previous
Data color / Usage
Next
Data color / Accessibility
On this page
toDataColor
Example
DataColor
Storybook
Enforcement