@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

CommandDoesNeeds
sorb-seed resolveThin 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 idKindOutput
SORB_SET_META (sorb/set-meta)ParserLifts 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)FormatA nested JS object of var(--kebab, fallback) strings, for a styled-components theme.
SORB_ALIASES (sorb/aliases-css)FormatA legacy CSS alias layer mapping old custom-property names onto new DTCG ids during a migration.
SORB_TOKENSET (sorb/tokenset-esm)FormatThe flat committed TokenSet module SorbProvider bundles — @sorb/leaf's React + Bootstrap target.
SORB_TAILWIND (sorb/tailwind-theme)FormatTailwind v4 @theme inline { … } of var(--token) references.
SORB_TAILWIND_V3 (sorb/tailwind-v3-preset)FormatA CommonJS Tailwind v3 preset whose theme.extend values are var(--token) references.
SORB_MANTINE_VARS (sorb/mantine-vars)FormatOverrides Mantine v7's --mantine-* vars with var(--token) !important references.
SORB_SHADCN (sorb/shadcn-theme)Formatshadcn/ui's :root{} semantic-var map, chained onto Sorb vars via the role contract.
SORB_MUI_VARS (sorb/mui-vars)FormatOverrides MUI v6's --mui-* vars; requires options.seedValues for MUI's contrast/tonal computation.
SORB_MAT_SYS_VARS (sorb/mat-sys-vars)FormatOverrides ~30 of Angular Material 20's M3 --mat-sys-* vars.
SORB_PRIMEVUE_PRESET (sorb/primevue-preset)FormatThe 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:

ExportSignatureWhat it does
detectHardcoded(source, filename) => AdaptSite[]Parse one file's source (Babel AST) and return every detected hardcoded style site.
propToRole(prop) => AdaptRoleMap a CSS/JSX property name to a matcher role (bg/text/border/radius/null).
parseSource(source) => babel.NodeParse source into a Babel AST (jsx + typescript plugins, error-recovering).
mapToToken(site, index, resolved?) => AdaptMappingMap 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?) => stringLook up (or derive) a token id's --css-var.
normalizeColor / normalizeDimension / classifyColorThe same value normalizers the capture binder uses, so a value the matcher would bind is exactly a value adapt flags — no drift.

Exports

ExportKindDescriptionSource
buildTokenIndexfunctionBuild value→[token] indexes (colors, dims) from the resolved bindable map.src/annotateTokens.js:155
annotateTreefunctionWalk 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
matchColorfunctionReturn 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
matchDimensionfunctionReturn the tokens in the index whose normalized dimension equals value, preferring the given role and then the most specific tier.src/annotateTokens.js:219
tierOfFilefunctionDerive the token tier from the source file a token came from.src/emit/sorbFormat.js:22
SORB_RESOLVEDvalueFormat id sorb/resolved-map: the resolved bindable map .sorb/resolved.json, one &#123; id, cssVar, value, tier, type &#125; entry per token.src/emit/sorbFormat.js:32
SORB_THEME_NESTEDvalueFormat id sorb/theme-nested: a nested JS object of var(--kebab, fallback) strings for a styled-components theme.src/emit/sorbFormat.js:33
SORB_ALIASESvalueFormat 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_VERSIONSvalueFormat 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_METAvalueParser id sorb/set-meta: lifts each token file's root $version before Style Dictionary merges the tiers.src/emit/sorbFormat.js:36
SORB_TAILWINDvalueFormat id sorb/tailwind-theme: a Tailwind v4 @theme inline block of var(--token) references.src/emit/sorbFormat.js:37
SORB_TAILWIND_V3valueFormat id sorb/tailwind-v3-preset: a CommonJS Tailwind v3 preset whose theme.extend values are var(--token) references.src/emit/sorbFormat.js:38
SORB_TOKENSETvalueFormat id sorb/tokenset-esm: the flat committed TokenSet module (export const tokens = &#123;...&#125;) that SorbProvider bundles.src/emit/sorbFormat.js:39
sorbSetMetavalueThe 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
sorbVersionsfunctionformat: sorb/versions — { primitive, semantic, component } → version.src/emit/sorbFormat.js:63
sorbTokenSetfunctionFlat 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
sorbResolvedfunctionThe Style Dictionary format behind SORB_RESOLVED: emits the resolved bindable map and warns about deprecated tokens.src/emit/sorbFormat.js:90
sorbAliasesfunctionformat: sorb/aliases-css — legacy back-compat layer (migration window).src/emit/sorbFormat.js:121
sorbThemeNestedfunctionformat: sorb/theme-nested Emits a nested object of var(--kebab, &lt;fallback&gt;) strings so a styled-components theme can read theme.color.action.primary.src/emit/sorbFormat.js:145
tailwindThemeEntryfunctionMap one Sorb token to a Tailwind v4 @theme entry: { key, ref }.src/emit/sorbFormat.js:179
sorbTailwindfunctionformat: sorb/tailwind-theme Emits a Tailwind v4 @theme inline &#123; … &#125; block — one entry per resolved token, each value a var(--token) reference.src/emit/sorbFormat.js:218
tailwindV3SlotfunctionClassify one Sorb token into a Tailwind v3 theme.extend slot.src/emit/sorbFormat.js:256
sorbTailwindV3functionformat: sorb/tailwind-v3-preset Emits a Tailwind v3 preset (CommonJS) — theme.extend.&#123;colors,borderRadius, spacing,fontSize,fontWeight&#125; whose leaves are var(--token) strings grouped by tier/role.src/emit/sorbFormat.js:287
SORB_MANTINE_VARSvalueFormat 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_MAPvaluerole id (JJ id when unmapped) → Mantine CSS var name.src/emit/sorbMantine.js:53
sorbMantineVarsfunctionformat: sorb/mantine-vars Emits a CSS file that redeclares the mapped --mantine-* vars as var(--&lt;kit-token&gt;) !important refs.src/emit/sorbMantine.js:89
SORB_SHADCNvalue@type {'sorb/shadcn-theme'}src/emit/sorbShadcn.js:18
sorbShadcnfunctionformat: sorb/shadcn-theme Emits ONE CSS artifact: shadcn's :root&#123;&#125; semantic-var map (chained onto Sorb tokens via the role contract) followed by the @theme inline&#123;&#125; Tailwind-utility binding block — reproducing what sorb-demo-tailwind/src/tokens/shadcn-map.css + shadcn-theme.css hand- authored.src/emit/sorbShadcn.js:162
shadcnRootLinesfunctionBuild the :root&#123;&#125; 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
shadcnThemeInlineLinesfunctionThe fixed @theme inline&#123;&#125; block lines (mechanical; no roleMap input).src/emit/sorbShadcn.js:137
SORB_MUI_VARSvalueFormat 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_MAPvaluerole id (JJ id when unmapped) → MUI CSS var name.src/emit/sorbMui.js:76
sorbMuiVarsfunctionformat: sorb/mui-vars Emits a CSS file that redeclares the mapped --mui-* vars as var(--&lt;kit-token&gt;, &lt;seed-fallback&gt;) !important refs.src/emit/sorbMui.js:114
SORB_MAT_SYS_VARSvalueFormat 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_MAPvalueAngular Material --mat-sys-* CSS var name → role id (JJ id when unmapped).src/emit/sorbMatSys.js:64
sorbMatSysVarsfunctionformat: sorb/mat-sys-vars Emits a CSS file that redeclares the mapped --mat-sys-* vars as var(--&lt;kit-token&gt;) !important refs.src/emit/sorbMatSys.js:128
SORB_PRIMEVUE_PRESETvalueFormat id sorb/primevue-preset: a JS module exporting a PrimeVue v4 preset whose roots reference var(--token).src/emit/sorbPrimevue.js:58
PRIMEVUE_ROLE_TREEvalueStructural role tree describing the PrimeVue definePreset shape this format generates, mirroring jjPreset.js's hand-authored nesting exactly.src/emit/sorbPrimevue.js:66
sorbPrimevuePresetfunctionformat: 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
detectHardcodedfunctionDetect hardcoded color/dimension style sites in source.src/adapt/detectHardcoded.js:166
propToRolefunctionMap a CSS/JSX property name → matcher role.src/adapt/detectHardcoded.js:28
parseSourcefunctionParse source into a Babel AST.src/adapt/detectHardcoded.js:74
normalizeColorfunctionNormalize any CSS color to canonical #rrggbbaa, or null if not a color.src/annotateTokens.js:112
normalizeDimensionfunctionNormalize a CSS length to a px number, or null.src/annotateTokens.js:115
classifyColorfunctionClassify a value as a color.src/annotateTokens.js:83
mapToTokenfunctionMap one detected site → its nearest resolved token + confidence.src/adapt/mapToToken.js:51
statusForfunctionMap a confidence score to a report status using the single AUTO_THRESHOLD cut.src/adapt/mapToToken.js:75
resolveCssVarfunctionLook 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_THRESHOLDvalueConfidence 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: &#123;colors, dims&#125; destructure still works.

tierOfFile

const tierOfFile = (filePath = '')

Derive the token tier from the source file a token came from.

ParameterTypeDescription
filePathstring

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, &lt;fallback&gt;) 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(&lt;the token's own --css-var&gt;) 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.

ParameterTypeDescription
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 &#123; … &#125; 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.

ParameterTypeDescription
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.&#123;colors,borderRadius, spacing,fontSize,fontWeight&#125; 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(--&lt;kit-token&gt;) !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.

ParameterTypeDescription
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&#123;&#125; semantic-var map (chained onto Sorb tokens via the role contract) followed by the @theme inline&#123;&#125; 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

ParameterTypeDescription
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&#123;&#125; shadcn-var → Sorb-token map, resolving roles through options.roleMap (defaulting to identity — the JJ reference kit already uses canonical role ids).

ParameterTypeDescription
[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(--&lt;kit-token&gt;, &lt;seed-fallback&gt;) !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.

ParameterTypeDescription
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(--&lt;kit-token&gt;) !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.

ParameterTypeDescription
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 &#123;dictionary, options&#125;; zero style-dictionary dep.

ParameterTypeDescription
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.

ParameterTypeDescription
sourcestringThe file's source text.
filenamestringThe 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).

ParameterTypeDescription
propstring

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).

ParameterTypeDescription
sourcestring

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.

ParameterTypeDescription
siteimport('./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.

ParameterTypeDescription
mappingimport('./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.

ParameterTypeDescription
tokenIdstring
[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.

PropertyTypeDescription
filestringSource file path (as passed to detect).
loc{line:number, column:number}1-based line, 0-based column (Babel loc.start).
propstringThe CSS/JSX property name as written (e.g. 'backgroundColor', 'border-radius').
rawstringThe raw literal value as written (e.g. '#0F65EF', '4px', '4').
roleAdaptRoleProperty→role mapping (bg/text/border/radius) or null.
group (optional)stringBlock identity (0.5.1): obj@&#123;start&#125; for a style-object property, tpl@&#123;start&#125;:b&#123;N&#125; for a template-literal block (b0 = top level). Sites sharing a group sit in the same rule.
parent (optional)stringThe enclosing block's group, when nested.
label (optional)stringReadable block label (style, styled.button, &amp;:hover).

Source: src/adapt/types.js:13

AdaptMapping

The result of mapping one site to the nearest resolved token.

PropertyTypeDescription
tokenIdstring|nullResolved token id, or null when unmapped.
cssVarstring|nullThe token's --css-var, or null.
confidencenumber0..1 confidence score (see mapToToken).
candidatesstring[]All token ids that matched the value.
offRolebooleanTrue 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.

PropertyTypeDescription
filestring
loc{line:number, column:number}
propstring
rawstring
tokenIdstring|null
cssVarstring|null
confidencenumber
candidatesstring[]
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).

PropertyTypeDescription
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(&#123; cssVariables: true &#125;) needs a real literal to compute contrast/tonal variants, so seedValues is REQUIRED — a role with no entry emits var(--token) with no fallback.

PropertyTypeDescription
roleMap (optional)Record<string,string>Canonical role id -> your kit's token id.
seedValuesRecord<string,string>Canonical role id -> seed/fallback literal (e.g. &#123; 'color.brand': '#1976d2' &#125;).

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.

PropertyTypeDescription
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/leafSORB_TOKENSET's consumer, SorbProvider.
  • The bridge — how sorb dev serves the resolved map this package builds.

Works with Figma. Not affiliated with, or endorsed by, Figma. Figma is a trademark of Figma, Inc.