@sorb/seed reference
When you finish this page you know the sorb-seed CLI, the Style
Dictionary formats it registers, and the library exports for scripting your
own token pipeline or hardcoded-style scan. You need Node 20 and, for
resolve, a style-dictionary config; capture additionally needs a
running Storybook and Playwright's Chromium.
npm install -D @sorb/seed style-dictionary
capture needs Playwright's Chromium browser separately —
npm install playwright && npx playwright install chromium — an optional
peer dependency so a plain resolve-only install stays light.
CLI commands
| Command | Does | Needs |
|---|---|---|
sorb-seed resolve | Thin wrapper around Style Dictionary: builds .sorb/resolved.json (and CSS vars, theme, etc.) from your DTCG token sets. Default when no command is given. | sorb.config.json with styleDictionaryConfig (default sd.config.js) |
sorb-seed capture [--changed] [--only=<pattern>] [--storybook-url=<url>] | Visits every Storybook story with Playwright, captures the rendered DOM, annotates it against the resolved map, writes <Component>.sorb.json next to each story and .sorb/index.json. | A running Storybook; the resolved map from resolve |
sorb-seed adapt [--src <glob>] [--resolved <path>] [--mode report|shim|codemod] [--write] | Scans an existing app for hardcoded color/dimension literals and maps each to the nearest resolved token — see below. | The resolved map |
sorb-seed variant <add|deprecate> <id> --from/--replaced-by <variant> [--tokens-dir] [--sd-dir] | Adds or deprecates a component variant in the DTCG source and bumps $version. | A component.json token source |
sorb-seed --help / -h prints usage; --version / -v prints the
installed version. There is no annotate command — annotateTree is the
internal binder capture calls, not a CLI verb.
The smallest sd.config.js
resolve reads whatever style-dictionary config your sorb.config.json
points at (default sd.config.js). The smallest one that produces a resolved
map:
// sd.config.js
import StyleDictionary from 'style-dictionary'
import { SORB_RESOLVED, sorbResolved, SORB_SET_META, sorbSetMeta } from '@sorb/seed'
StyleDictionary.registerParser(sorbSetMeta)
StyleDictionary.registerFormat({ name: SORB_RESOLVED, format: sorbResolved })
export default {
source: ['tokens/primitive.json', 'tokens/semantic.json', 'tokens/component.json'],
parsers: [SORB_SET_META],
platforms: {
sorb: {
transformGroup: 'css',
buildPath: '.sorb/',
files: [{ destination: 'resolved.json', format: SORB_RESOLVED }],
},
},
}
sorb dev (from @sorb/juice) serves the resulting .sorb/resolved.json at
GET /tokens/resolved; the Sorb plugin's Sync Variables button and
capture's annotator both read it. A real app's sd.config.js — lifted
verbatim from the reference app — also emits variables.css, a
styled-components theme, and the framework format(s) below; see
sorb-demo/sd.config.js.
Style Dictionary formats
Every format below is a StyleDictionary.registerFormat({ name, format })
call (or registerParser for the one parser); reference it in a
platforms.<key>.files[] entry the same way as any other Style Dictionary
format.
| Format id | Kind | Output |
|---|---|---|
SORB_SET_META (sorb/set-meta) | Parser | Lifts each token file's root $version before the tiers merge; feeds SORB_VERSIONS. |
SORB_RESOLVED (sorb/resolved-map) | Format | .sorb/resolved.json — the resolved bindable map, one {id,cssVar,value,tier,type} per token. |
SORB_VERSIONS (sorb/versions) | Format | .sorb/versions.json — the per-tier $version values lifted by the set-meta parser. |
SORB_THEME_NESTED (sorb/theme-nested) | Format | A nested JS object of var(--kebab, fallback) strings, for a styled-components theme. |
SORB_ALIASES (sorb/aliases-css) | Format | A legacy CSS alias layer mapping old custom-property names onto new DTCG ids during a migration. |
SORB_TOKENSET (sorb/tokenset-esm) | Format | The flat committed TokenSet module SorbProvider bundles — @sorb/leaf's React + Bootstrap target. |
SORB_TAILWIND (sorb/tailwind-theme) | Format | Tailwind v4 @theme inline { … } of var(--token) references. |
SORB_TAILWIND_V3 (sorb/tailwind-v3-preset) | Format | A CommonJS Tailwind v3 preset whose theme.extend values are var(--token) references. |
SORB_MANTINE_VARS (sorb/mantine-vars) | Format | Overrides Mantine v7's --mantine-* vars with var(--token) !important references. |
SORB_SHADCN (sorb/shadcn-theme) | Format | shadcn/ui's :root{} semantic-var map, chained onto Sorb vars via the role contract. |
SORB_MUI_VARS (sorb/mui-vars) | Format | Overrides MUI v6's --mui-* vars; requires options.seedValues for MUI's contrast/tonal computation. |
SORB_MAT_SYS_VARS (sorb/mat-sys-vars) | Format | Overrides ~30 of Angular Material 20's M3 --mat-sys-* vars. |
SORB_PRIMEVUE_PRESET (sorb/primevue-preset) | Format | The only JS-emitting target: an ESM module exporting a definePreset(...) PrimeVue v4 preset. |
Semantic-role contract. Every framework format (SORB_MANTINE_VARS,
SORB_SHADCN, SORB_MUI_VARS, SORB_MAT_SYS_VARS, SORB_PRIMEVUE_PRESET)
resolves a canonical set of role ids (color.brand, radius.control, …)
through an optional options.roleMap, defaulting to identity for a kit that
already uses the canonical ids as its own token ids. See
@sorb/core's role-id contract
and each format's options typedef in the types table below.
SORB_MUI_VARS additionally requires options.seedValues (a literal
fallback per role) — MUI's createTheme({ cssVariables: true }) needs a real
color to compute contrast/tonal variants.
Adapt: find hardcoded styles and map them to tokens
sorb-seed adapt scans an existing React codebase for hardcoded
color/dimension style literals (JSX inline style={{ }}, styled-components
template literals, plain style objects) and maps each one to the nearest
token in your resolved map — the on-ramp for a codebase that predates Sorb. A
value already written as var(--…) is never flagged.
sorb-seed adapt # report mode, default glob
sorb-seed adapt --mode codemod --write # rewrite matched sites in place
Each detected site scores auto (one unambiguous on-role candidate),
review (bound but ambiguous — off-role or multiple candidates), or
unmapped (no token matched), via the single AUTO_THRESHOLD (0.9) cut.
--mode codemod only ever rewrites auto-status sites.
Library exports for scripting the adapter:
| Export | Signature | What it does |
|---|---|---|
detectHardcoded | (source, filename) => AdaptSite[] | Parse one file's source (Babel AST) and return every detected hardcoded style site. |
propToRole | (prop) => AdaptRole | Map a CSS/JSX property name to a matcher role (bg/text/border/radius/null). |
parseSource | (source) => babel.Node | Parse source into a Babel AST (jsx + typescript plugins, error-recovering). |
mapToToken | (site, index, resolved?) => AdaptMapping | Map one detected site to its nearest resolved token + a confidence score. |
statusFor | (mapping) => 'auto'|'review'|'unmapped' | Turn a mapping's confidence into a report status via AUTO_THRESHOLD. |
resolveCssVar | (tokenId, resolved?) => string | Look up (or derive) a token id's --css-var. |
normalizeColor / normalizeDimension / classifyColor | — | The same value normalizers the capture binder uses, so a value the matcher would bind is exactly a value adapt flags — no drift. |
Exports
| Export | Kind | Description | Source |
|---|---|---|---|
buildTokenIndex | function | Build value→[token] indexes (colors, dims) from the resolved bindable map. | src/annotateTokens.js:155 |
annotateTree | function | Walk a captured LayerNode tree and stamp a sorb annotation (bound token ids + candidates) on every node whose fill, stroke, radius or effect value matches an indexed token. | src/annotateTokens.js:227 |
matchColor | function | Return the tokens in the index whose normalized color equals value, preferring the given role (bg/text/border) and then the most specific tier. | src/annotateTokens.js:214 |
matchDimension | function | Return the tokens in the index whose normalized dimension equals value, preferring the given role and then the most specific tier. | src/annotateTokens.js:219 |
tierOfFile | function | Derive the token tier from the source file a token came from. | src/emit/sorbFormat.js:22 |
SORB_RESOLVED | value | Format id sorb/resolved-map: the resolved bindable map .sorb/resolved.json, one { id, cssVar, value, tier, type } entry per token. | src/emit/sorbFormat.js:32 |
SORB_THEME_NESTED | value | Format id sorb/theme-nested: a nested JS object of var(--kebab, fallback) strings for a styled-components theme. | src/emit/sorbFormat.js:33 |
SORB_ALIASES | value | Format id sorb/aliases-css: a legacy alias layer that maps old custom-property names onto new DTCG ids during a migration. | src/emit/sorbFormat.js:34 |
SORB_VERSIONS | value | Format id sorb/versions: the per-tier $version values lifted by the set-meta parser, written as .sorb/versions.json. | src/emit/sorbFormat.js:35 |
SORB_SET_META | value | Parser id sorb/set-meta: lifts each token file's root $version before Style Dictionary merges the tiers. | src/emit/sorbFormat.js:36 |
SORB_TAILWIND | value | Format id sorb/tailwind-theme: a Tailwind v4 @theme inline block of var(--token) references. | src/emit/sorbFormat.js:37 |
SORB_TAILWIND_V3 | value | Format id sorb/tailwind-v3-preset: a CommonJS Tailwind v3 preset whose theme.extend values are var(--token) references. | src/emit/sorbFormat.js:38 |
SORB_TOKENSET | value | Format id sorb/tokenset-esm: the flat committed TokenSet module (export const tokens = {...}) that SorbProvider bundles. | src/emit/sorbFormat.js:39 |
sorbSetMeta | value | The Style Dictionary parser behind SORB_SET_META: removes a file's root $version from the tree and remembers it by tier. | src/emit/sorbFormat.js:49 |
sorbVersions | function | format: sorb/versions — { primitive, semantic, component } → version. | src/emit/sorbFormat.js:63 |
sorbTokenSet | function | Flat TokenSet ESM module for @sorb/leaf's SorbProvider — one entry per token, keyed by the CSS-var name WITHOUT the leading -- (leaf's applyTokens re-adds it via setProperty('--' + key, value)). | src/emit/sorbFormat.js:82 |
sorbResolved | function | The Style Dictionary format behind SORB_RESOLVED: emits the resolved bindable map and warns about deprecated tokens. | src/emit/sorbFormat.js:90 |
sorbAliases | function | format: sorb/aliases-css — legacy back-compat layer (migration window). | src/emit/sorbFormat.js:121 |
sorbThemeNested | function | format: sorb/theme-nested Emits a nested object of var(--kebab, <fallback>) strings so a styled-components theme can read theme.color.action.primary. | src/emit/sorbFormat.js:145 |
tailwindThemeEntry | function | Map one Sorb token to a Tailwind v4 @theme entry: { key, ref }. | src/emit/sorbFormat.js:179 |
sorbTailwind | function | format: sorb/tailwind-theme Emits a Tailwind v4 @theme inline { … } block — one entry per resolved token, each value a var(--token) reference. | src/emit/sorbFormat.js:218 |
tailwindV3Slot | function | Classify one Sorb token into a Tailwind v3 theme.extend slot. | src/emit/sorbFormat.js:256 |
sorbTailwindV3 | function | format: sorb/tailwind-v3-preset Emits a Tailwind v3 preset (CommonJS) — theme.extend.{colors,borderRadius, spacing,fontSize,fontWeight} whose leaves are var(--token) strings grouped by tier/role. | src/emit/sorbFormat.js:287 |
SORB_MANTINE_VARS | value | Format id sorb/mantine-vars: a CSS file that overrides Mantine v7's --mantine-* variables with var(--token) references. | src/emit/sorbMantine.js:45 |
MANTINE_VAR_MAP | value | role id (JJ id when unmapped) → Mantine CSS var name. | src/emit/sorbMantine.js:53 |
sorbMantineVars | function | format: sorb/mantine-vars Emits a CSS file that redeclares the mapped --mantine-* vars as var(--<kit-token>) !important refs. | src/emit/sorbMantine.js:89 |
SORB_SHADCN | value | @type {'sorb/shadcn-theme'} | src/emit/sorbShadcn.js:18 |
sorbShadcn | function | format: sorb/shadcn-theme Emits ONE CSS artifact: shadcn's :root{} semantic-var map (chained onto Sorb tokens via the role contract) followed by the @theme inline{} Tailwind-utility binding block — reproducing what sorb-demo-tailwind/src/tokens/shadcn-map.css + shadcn-theme.css hand- authored. | src/emit/sorbShadcn.js:162 |
shadcnRootLines | function | Build the :root{} shadcn-var → Sorb-token map, resolving roles through options.roleMap (defaulting to identity — the JJ reference kit already uses canonical role ids). | src/emit/sorbShadcn.js:105 |
shadcnThemeInlineLines | function | The fixed @theme inline{} block lines (mechanical; no roleMap input). | src/emit/sorbShadcn.js:137 |
SORB_MUI_VARS | value | Format id sorb/mui-vars: a CSS file that overrides MUI v6's --mui-* variables with var(--token) references (with !important). | src/emit/sorbMui.js:68 |
MUI_VAR_MAP | value | role id (JJ id when unmapped) → MUI CSS var name. | src/emit/sorbMui.js:76 |
sorbMuiVars | function | format: sorb/mui-vars Emits a CSS file that redeclares the mapped --mui-* vars as var(--<kit-token>, <seed-fallback>) !important refs. | src/emit/sorbMui.js:114 |
SORB_MAT_SYS_VARS | value | Format id sorb/mat-sys-vars: a CSS file that overrides Angular Material 20's --mat-sys-* system variables with var(--token) references. | src/emit/sorbMatSys.js:52 |
MAT_SYS_MAP | value | Angular Material --mat-sys-* CSS var name → role id (JJ id when unmapped). | src/emit/sorbMatSys.js:64 |
sorbMatSysVars | function | format: sorb/mat-sys-vars Emits a CSS file that redeclares the mapped --mat-sys-* vars as var(--<kit-token>) !important refs. | src/emit/sorbMatSys.js:128 |
SORB_PRIMEVUE_PRESET | value | Format id sorb/primevue-preset: a JS module exporting a PrimeVue v4 preset whose roots reference var(--token). | src/emit/sorbPrimevue.js:58 |
PRIMEVUE_ROLE_TREE | value | Structural role tree describing the PrimeVue definePreset shape this format generates, mirroring jjPreset.js's hand-authored nesting exactly. | src/emit/sorbPrimevue.js:66 |
sorbPrimevuePreset | function | format: sorb/primevue-preset Emits a JS/ESM module string: import { definePreset } from '@primeuix/themes'; import Aura from '@primeuix/themes/aura'; export const preset = definePreset(Aura, { semantic: {...}, components: {...} }); Every leaf is a var(--kebab-token-id) string — the live-preview invariant, same as every other Sorb format (no baked literals). | src/emit/sorbPrimevue.js:214 |
detectHardcoded | function | Detect hardcoded color/dimension style sites in source. | src/adapt/detectHardcoded.js:166 |
propToRole | function | Map a CSS/JSX property name → matcher role. | src/adapt/detectHardcoded.js:28 |
parseSource | function | Parse source into a Babel AST. | src/adapt/detectHardcoded.js:74 |
normalizeColor | function | Normalize any CSS color to canonical #rrggbbaa, or null if not a color. | src/annotateTokens.js:112 |
normalizeDimension | function | Normalize a CSS length to a px number, or null. | src/annotateTokens.js:115 |
classifyColor | function | Classify a value as a color. | src/annotateTokens.js:83 |
mapToToken | function | Map one detected site → its nearest resolved token + confidence. | src/adapt/mapToToken.js:51 |
statusFor | function | Map a confidence score to a report status using the single AUTO_THRESHOLD cut. | src/adapt/mapToToken.js:75 |
resolveCssVar | function | Look up a token's cssVar from the resolved map (so the report carries the --var for the codemod/shim). | src/adapt/mapToToken.js:87 |
AUTO_THRESHOLD | value | Confidence cut (0.9) between auto and review in an adapt report: a mapping at or above it is applied automatically. | src/adapt/mapToToken.js:23 |
buildTokenIndex
const buildTokenIndex = (resolved)
Build value→[token] indexes (colors, dims) from the resolved bindable map.
Returns { colors: Map, dims: Map, dropped: {id, value, reason: [] }} dropped (REC-1/2/6) records every token whose value normalized to null — unresolved-alias / cycle / unparseable-color / no-match — so a silent vanish becomes observable. Backward-compatible: {colors, dims} destructure still works.
tierOfFile
const tierOfFile = (filePath = '')
Derive the token tier from the source file a token came from.
| Parameter | Type | Description |
|---|---|---|
filePath | string |
Returns 'primitive'\|'semantic'\|'component'\|'unknown'.
sorbTokenSet
const sorbTokenSet = ({ dictionary })
Flat TokenSet ESM module for @sorb/leaf's SorbProvider — one entry per token, keyed by the CSS-var name WITHOUT the leading -- (leaf's applyTokens re-adds it via setProperty('--' + key, value)). This is the committed token set bundled into the app at build time: export const tokens = { 'color-action-primary': '#0f65ef', ... } Same names/values as variables.css and resolved.json (one source, many surfaces). Consumed by main.jsx / src/sorbConfig.js.
sorbAliases
const sorbAliases = ({ dictionary, options })
format: sorb/aliases-css — legacy back-compat layer (migration window). Reads options.aliases ({ legacyName: "new.dtcg.id" }) and emits --legacyName: var(--new-dtcg-id); Each target is validated against the built tokens; unknown targets warn and are skipped. Drop this platform once nothing references the legacy names.
sorbThemeNested
const sorbThemeNested = ({ dictionary })
format: sorb/theme-nested Emits a nested object of var(--kebab, <fallback>) strings so a styled-components theme can read theme.color.action.primary. The fallback is the committed value, so with no preview active rendering is unchanged.
tailwindThemeEntry
const tailwindThemeEntry = (t)
Map one Sorb token to a Tailwind v4 @theme entry: { key, ref }. key is the theme variable name — its prefix picks the Tailwind utility family (--color-*→bg/text/border, --radius-*→rounded, --spacing-*→ p/m/gap/w/h, --text-*→font-size, --font-weight-*→font weight). ref is always var(<the token's own --css-var>) so the value stays a reference to the same runtime-swappable var the bridge overrides — never a baked literal. Because Sorb already names color vars --color-* (colliding with Tailwind's own namespace), the format emits @theme inline, where Tailwind uses the ref expression directly in utilities instead of redefining the key in :root.
| Parameter | Type | Description |
|---|---|---|
t | {path: string[], $type?: string, type?: string} |
Returns {key: string, ref: string: }
sorbTailwind
const sorbTailwind = ({ dictionary })
format: sorb/tailwind-theme Emits a Tailwind v4 @theme inline { … } block — one entry per resolved token, each value a var(--token) reference. Pair it with variables.css (which defines those vars) so Tailwind utilities resolve through the exact CSS vars the bridge swaps at runtime → live preview works with zero Tailwind-specific bridge code. Duplicate theme keys are skipped (warned).
tailwindV3Slot
const tailwindV3Slot = (t)
Classify one Sorb token into a Tailwind v3 theme.extend slot. Returns the category (colors|borderRadius|spacing|fontSize|fontWeight), the nested key path within it (Tailwind v3 flattens nested keys with -, so colors.action.primary → utility bg-action-primary), and the var() ref. Returns null for token types with no v3 utility family.
| Parameter | Type | Description |
|---|---|---|
t | {path: string[], $type?: string, type?: string} |
Returns {category: string, keyPath: string[], ref: string: |null}
sorbTailwindV3
const sorbTailwindV3 = ({ dictionary })
format: sorb/tailwind-v3-preset Emits a Tailwind v3 preset (CommonJS) — theme.extend.{colors,borderRadius, spacing,fontSize,fontWeight} whose leaves are var(--token) strings grouped by tier/role. Consumer: presets: [require('./tailwind-sorb-preset.cjs')]. Same live-preview behavior as v4 — utilities reference the runtime-swappable Sorb vars.
MANTINE_VAR_MAP
const MANTINE_VAR_MAP
role id (JJ id when unmapped) → Mantine CSS var name. Left side is resolved through options.roleMap at format time (identity when the kit uses these ids directly — the JJ reference); right side is the Mantine v7 documented variable it overrides.
sorbMantineVars
const sorbMantineVars = ({ dictionary, options })
format: sorb/mantine-vars Emits a CSS file that redeclares the mapped --mantine-* vars as var(--<kit-token>) !important refs. options.roleMap (role id → kit token id) lets a non-JJ kit reuse this format unmodified; defaults to the canonical/JJ ids (identity resolution) when omitted.
| Parameter | Type | Description |
|---|---|---|
args | {dictionary: {allTokens: Array}, options?: {roleMap?: Record<string,string>}} |
Returns string: the generated CSS.
sorbShadcn
const sorbShadcn = ({ dictionary, options } = {})
format: sorb/shadcn-theme Emits ONE CSS artifact: shadcn's :root{} semantic-var map (chained onto Sorb tokens via the role contract) followed by the @theme inline{} Tailwind-utility binding block — reproducing what sorb-demo-tailwind/src/tokens/shadcn-map.css + shadcn-theme.css hand- authored. Pair with variables.css (defines the Sorb vars this format references) in the consumer's CSS import order: @import "tailwindcss"; @import "./variables.css"; sorb tokens — the bridge swaps these live @import "./shadcn-theme.css"; this file
| Parameter | Type | Description |
|---|---|---|
args | {dictionary: {allTokens: Array<{path: string[]}>}, options?: {roleMap?: Record<string,string>, destructiveForeground?: string, radiusRole?: string}} |
Returns string.
shadcnRootLines
const shadcnRootLines = (options = {}, knownTokenIds)
Build the :root{} shadcn-var → Sorb-token map, resolving roles through options.roleMap (defaulting to identity — the JJ reference kit already uses canonical role ids).
| Parameter | Type | Description |
|---|---|---|
[options] | {roleMap?: Record<string,string>, destructiveForeground?: string, radiusRole?: string} | |
[knownTokenIds] | Set<string> | when provided, unknown resolved ids are warned (not skipped — CSS still emits, just points at an undefined var). |
Returns string[]: lines
MUI_VAR_MAP
const MUI_VAR_MAP
role id (JJ id when unmapped) → MUI CSS var name. Left side is resolved through options.roleMap at format time (identity when the kit uses these ids directly — the JJ reference); right side is the MUI v6 documented cssVariables:true var it overrides.
sorbMuiVars
const sorbMuiVars = ({ dictionary, options })
format: sorb/mui-vars Emits a CSS file that redeclares the mapped --mui-* vars as var(--<kit-token>, <seed-fallback>) !important refs. options.roleMap (role id → kit token id) lets a non-JJ kit reuse this format unmodified; defaults to the canonical/JJ ids (identity resolution) when omitted. options.seedValues (role id → literal fallback) is REQUIRED to avoid baking any one kit's hex values into the public format — a role with no seedValues entry emits var(--kit-token) with no fallback.
| Parameter | Type | Description |
|---|---|---|
args | {dictionary: {allTokens: Array}, options?: {roleMap?: Record<string,string>, seedValues?: Record<string,string>}} |
Returns string: the generated CSS.
MAT_SYS_MAP
const MAT_SYS_MAP
Angular Material --mat-sys-* CSS var name → role id (JJ id when unmapped). The role id is resolved through options.roleMap at format time (identity when the kit uses these ids directly — the JJ reference). Semantic-tier-first per the field corrections carried from P2/P4: only the handful of system roots Material's own components actually cascade from — not every --mat-sys-* var Material defines (many, e.g. per-component elevation/state-layer opacities, aren't part of the kit's vocabulary and are intentionally left at Material's own defaults).
sorbMatSysVars
const sorbMatSysVars = ({ dictionary, options })
format: sorb/mat-sys-vars Emits a CSS file that redeclares the mapped --mat-sys-* vars as var(--<kit-token>) !important refs. options.roleMap (role id → kit token id) lets a non-JJ kit reuse this format unmodified; defaults to the canonical/JJ ids (identity resolution) when omitted.
| Parameter | Type | Description |
|---|---|---|
args | {dictionary: {allTokens: Array}, options?: {roleMap?: Record<string,string>}} |
Returns string: the generated CSS.
PRIMEVUE_ROLE_TREE
const PRIMEVUE_ROLE_TREE
Structural role tree describing the PrimeVue definePreset shape this format generates, mirroring jjPreset.js's hand-authored nesting exactly. Every leaf is a role id (a dot-path token id, canonical-or-JJ) resolved through options.roleMap before becoming a var(--kebab-id) ref.
sorbPrimevuePreset
const sorbPrimevuePreset = ({ dictionary, options })
format: sorb/primevue-preset Emits a JS/ESM module string: import { definePreset } from '@primeuix/themes'; import Aura from '@primeuix/themes/aura'; export const preset = definePreset(Aura, { semantic: {...}, components: {...} }); Every leaf is a var(--kebab-token-id) string — the live-preview invariant, same as every other Sorb format (no baked literals). Pure function of {dictionary, options}; zero style-dictionary dep.
| Parameter | Type | Description |
|---|---|---|
args | {dictionary: {allTokens: Array}, options?: {roleMap?: Record<string,string>, basePreset?: string}} |
Returns string: the generated ESM module source.
detectHardcoded
function detectHardcoded(source, filename)
Detect hardcoded color/dimension style sites in source.
| Parameter | Type | Description |
|---|---|---|
source | string | The file's source text. |
filename | string | The file path (recorded on each site). |
Returns import('./types.js').AdaptSite[].
propToRole
const propToRole = (prop)
Map a CSS/JSX property name → matcher role. Accepts both kebab-case (CSS, styled-components) and camelCase (JSX inline style). Non-roled props → null (still detected, matched tier-only).
| Parameter | Type | Description |
|---|---|---|
prop | string |
Returns import('./types.js').AdaptRole.
parseSource
const parseSource = (source)
Parse source into a Babel AST. jsx + typescript plugins so .jsx AND .tsx both parse (we parse a consumer's TS source; we never emit TS).
| Parameter | Type | Description |
|---|---|---|
source | string |
classifyColor
const classifyColor = (value)
Classify a value as a color.
Returns { hex: string\|null, status: 'ok'\|'no-match'\|'unparseable': } - ok: parsed → canonical hex - no-match: a clean value that just isn't a color (e.g. '4px', a dimension) - unparseable: looks color-ish (a #… / rgb(…) / named shape) but is malformed
mapToToken
function mapToToken(site, index, resolved)
Map one detected site → its nearest resolved token + confidence.
| Parameter | Type | Description |
|---|---|---|
site | import('./types.js').AdaptSite | |
index | {colors:Map, dims:Map} | from buildTokenIndex(resolved) |
[resolved] | import('@sorb/core').ResolvedToken[] | optional, to resolve cssVar |
Returns import('./types.js').AdaptMapping.
statusFor
function statusFor(mapping)
Map a confidence score to a report status using the single AUTO_THRESHOLD cut.
| Parameter | Type | Description |
|---|---|---|
mapping | import('./types.js').AdaptMapping |
Returns 'auto'\|'review'\|'unmapped'.
resolveCssVar
function resolveCssVar(tokenId, resolved)
Look up a token's cssVar from the resolved map (so the report carries the --var for the codemod/shim). Falls back to deriving it from the id when the resolved map isn't supplied.
| Parameter | Type | Description |
|---|---|---|
tokenId | string | |
[resolved] | import('@sorb/core').ResolvedToken[] |
Types
JSDoc typedefs. Import them in your own JSDoc with import('@sorb/seed').Name.
AdaptRole
A CSS property "role" the matcher understands. Drives property affinity in matchColor/matchDimension (annotateTokens.js). null ⇒ tier-only match.
type AdaptRole = 'bg'|'text'|'border'|'radius'|null
Source: src/adapt/types.js:7
AdaptSite
A single detected hardcoded style site in consumer source.
| Property | Type | Description |
|---|---|---|
file | string | Source file path (as passed to detect). |
loc | {line:number, column:number} | 1-based line, 0-based column (Babel loc.start). |
prop | string | The CSS/JSX property name as written (e.g. 'backgroundColor', 'border-radius'). |
raw | string | The raw literal value as written (e.g. '#0F65EF', '4px', '4'). |
role | AdaptRole | Property→role mapping (bg/text/border/radius) or null. |
group (optional) | string | Block identity (0.5.1): obj@{start} for a style-object property, tpl@{start}:b{N} for a template-literal block (b0 = top level). Sites sharing a group sit in the same rule. |
parent (optional) | string | The enclosing block's group, when nested. |
label (optional) | string | Readable block label (style, styled.button, &:hover). |
Source: src/adapt/types.js:13
AdaptMapping
The result of mapping one site to the nearest resolved token.
| Property | Type | Description |
|---|---|---|
tokenId | string|null | Resolved token id, or null when unmapped. |
cssVar | string|null | The token's --css-var, or null. |
confidence | number | 0..1 confidence score (see mapToToken). |
candidates | string[] | All token ids that matched the value. |
offRole | boolean | True when the pick fell back off-role (low confidence). |
Source: src/adapt/types.js:28
AdaptRow
A fully scored report row (detect → map → score). Emitted to .sorb/adapt-report.json.
| Property | Type | Description |
|---|---|---|
file | string | |
loc | {line:number, column:number} | |
prop | string | |
raw | string | |
tokenId | string|null | |
cssVar | string|null | |
confidence | number | |
candidates | string[] | |
status | 'auto'|'review'|'unmapped' |
Source: src/adapt/types.js:38
DetectHardcodedResult
Return value of detectHardcoded(source, filename) — every hardcoded color/dimension style site found in one source file.
type DetectHardcodedResult = AdaptSite[]
Source: src/types.js:15
MapToTokenResult
Return value of mapToToken(site, index, resolved) — one detected site mapped to its nearest resolved token plus a confidence score. Identical shape to AdaptMapping; named for the function that produces it.
type MapToTokenResult = AdaptMapping
Source: src/types.js:21
RoleMapOptions
options accepted by every role-resolved framework format (sorb/mantine-vars, sorb/shadcn-theme, sorb/mat-sys-vars, and the base case of sorb/mui-vars / sorb/primevue-preset). Omit entirely for a kit that already uses the canonical role ids as its own token ids (identity mapping).
| Property | Type | Description |
|---|---|---|
roleMap (optional) | Record<string,string> | Canonical role id -> your kit's token id. |
Source: src/types.js:28
MuiFormatOptions
options for sorb/mui-vars. MUI's createTheme({ cssVariables: true }) needs a real literal to compute contrast/tonal variants, so seedValues is REQUIRED — a role with no entry emits var(--token) with no fallback.
| Property | Type | Description |
|---|---|---|
roleMap (optional) | Record<string,string> | Canonical role id -> your kit's token id. |
seedValues | Record<string,string> | Canonical role id -> seed/fallback literal (e.g. { 'color.brand': '#1976d2' }). |
Source: src/types.js:37
PrimevueFormatOptions
options for sorb/primevue-preset. roleMap here maps PrimeVue's own role tree (PRIMEVUE_ROLE_TREE) entries -> your kit's token ids, not the generic color/radius/shadow/typography roles.
| Property | Type | Description |
|---|---|---|
roleMap (optional) | Record<string,string> | PrimeVue role path -> your kit's token id. |
basePreset (optional) | 'Aura'|'Material'|'Lara'|'Nora' | Base PrimeVue theme to extend (default 'Aura'). |
Source: src/types.js:46
Next
@sorb/core— the role-id contract the framework formats resolve against.@sorb/leaf—SORB_TOKENSET's consumer,SorbProvider.- The bridge — how
sorb devserves the resolved map this package builds.
Works with Figma. Not affiliated with, or endorsed by, Figma. Figma is a trademark of Figma, Inc.