npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@softure-ai/ui

v0.3.11

Published

SOFTURE AI design tokens, theme provider and switch, and compiled CSS on the --sft-* tokens.

Downloads

6,331

Readme

@softure-ai/ui

The design foundation every SOFTURE UI stands on: the --sft-* token contract with light and dark defaults, a theme provider, a no-flash theme switch, the UI primitives every module builds its screens from, and compiled CSS that needs no Tailwind in the app (docs/02 §5).

Install and wire up (Next.js App Router)

/* app/globals.css: styles.css first, so its layer order is the one the browser keeps */
@import "@softure-ai/ui/styles.css";
@import "tailwindcss";                  /* optional: only if the app uses Tailwind 4 */
@import "@softure-ai/ui/tailwind.css";  /* optional: bg-accent, text-muted, rounded-card… on the tokens */
// app/layout.tsx
import { SoftureThemeProvider, ThemeScript } from "@softure-ai/ui";

const theme = { light: { "color-accent": "#0b5" } };

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en" suppressHydrationWarning>
      <head>
        <ThemeScript theme={theme} />
      </head>
      <body>
        <SoftureThemeProvider theme={theme}>{children}</SoftureThemeProvider>
      </body>
    </html>
  );
}

<ThemeSwitch /> anywhere renders Light · Dark · System (System is the default). Pass design to ThemeScript and ThemeSwitch too when the provider gets one, so the browser bar colour matches.

Locale. <SoftureThemeProvider locale="de"> (or <UiLocaleProvider locale="de">) sets the locale of the copy and the number notation of every component below it; a component's own locale prop still wins, and without either it is en. Mount it once in the root layout and drop the per-call locale and messages props: every client component below reads the provider (MoneyField and SuggestedAmountField take their number notation from it too). Only server-safe components that render copy without a client part (ServerExternalLink) still take locale by props. Pass messages per call only to change a text for one place.

Own translation. English is the default copy. To change its wording, or ship the components in another language, pass the app's text once: <UiLocaleProvider messages={{ modal: { close: "Dismiss", cancel: "Go back" } }}> (or the same messages on SoftureThemeProvider). It takes any message group of uiMessages.en, partially, and every client component below uses it over the built-in dictionary; a component's own messages prop still wins key by key. Server-safe components without a client part (ServerExternalLink) take messages by props.

Tokens

| Group | Tokens (--sft-…) | Per scheme | | --- | --- | --- | | Colour | color-{background,surface,surface-raised,foreground,muted,border,border-strong,accent,accent-fill,accent-fill-hover,on-accent,danger,success,warning,focus,overlay} | yes | | Shadow | shadow-{1,2} | yes | | Typography | font-{sans,mono,heading}, text-{xs,sm,base,lg,xl,2xl,3xl,display} | no | | Shape and space | radius-{control,card,pill}, space-{1…8} (0.25 rem steps) | no | | Motion | duration-{fast,base,slow} (160/200/240 ms), ease-{out,in-out} | no | | Chart colour | chart-{grid,axis,cursor,flag,on-flag}, chart-series-{1…6} | yes | | Chart size | chart-{line-width,grid-width,dot-size,plot-height} | no |

Chart tokens are read by @softure-ai/charts/styles.css, not by utilities, so the Tailwind bridge does not map them. Their defaults copy today's roles (grid = border, axis = muted, cursor = border-strong, flag = accent-fill). The six series colours are a palette in a fixed order, guarded for contrast and colour-vision distance by @softure-ai/charts (its README, "Series palette", has the order, the measured margins and checkSeriesPalette for an app's override).

The list lives in src/theme/tokens.ts (SCHEME_TOKENS, SHARED_TOKENS, DEFAULT_THEME); every CSS file the package ships is generated from it.

Overriding the theme

Three ways, from the most global:

  1. CSS. Unlayered rules in the app beat the defaults, which sit in @layer softure: [data-theme="dark"] { --sft-color-accent: #8f6; }.
  2. <SoftureThemeProvider theme={{ light, dark, shared }}>. light and dark take colours and shadows, shared takes the rest. Only the tokens you name are written. Values with ;, {, }, <, > or a line break throw.
  3. design.json (Impeccable, schemaVersion: 2): <SoftureThemeProvider design={json}>, or themeFromDesignJson(json), which returns a Result with the theme and the roles it ignored. Role names map to tokens (line-strong → color-border-strong); theme overrides design.

getThemeColors(theme) gives the background of each scheme for Next's viewport.themeColor.

Sections in a fixed scheme. <SoftureThemeProvider schemeScopes={{ dark: [".band-dark"], light: [".band-paper"] }}> (or buildThemeCss(theme, { schemeScopes })) gives every listed selector that scheme's complete tokens, the defaults merged with theme, whatever the page theme is: a dark band in a light page needs every colour, not only the overridden ones. Selectors with ;, {, }, <, > or a comment throw.

Theme switch

  • The choice lives in the cookie sft-theme (light | dark; absent = System). ThemeScript reads it before the first paint and sets data-theme on <html>; the server never reads it, so routes stay static. Use the same cookieName on ThemeScript and ThemeSwitch when you change it, and cookieDomain on the switch to share the choice across subdomains.
  • cookieDomain is a fixed domain, a function of the current hostname called on each change ((hostname) => domain | null), or { apex: "https://example.com" }, which a server component can pass: it shares the cookie when the page is on the apex or one of its subdomains and keeps it host-only elsewhere (localhost, an IP address, another host). The same rule is getThemeCookieDomain(hostname, apex). A domain that is not a hostname throws.
  • An app that already stores the choice keeps it: cookieName="theme" cookieValues={{ light: "bright", dark: "night" }} on both (and on parseThemeCookie, buildThemeCookie, applyThemeChoice). Values must be cookie octets and differ.
  • With an explicit choice the browser bar follows it: ThemeScript recolours every meta[name="theme-color"], also those Next inserts after the document is parsed (streamed metadata), as long as the page lives; after a switch to System, metas inserted later keep their own colour.
  • With a strict CSP pass nonce to ThemeScript.
  • data-theme="light" or "dark" on any element themes that subtree.
  • Slots: classNames={{ root, legend, options, option, input, label }}; unstyled drops the defaults. Copy: locale (en default) and partial messages.

Primitives

| Group | Components and helpers | | --- | --- | | Actions | Button (primary, secondary, ghost, danger, ink, ink-outline; sm, md, lg; pending, pendingLabel), ButtonLink, ButtonAnchor, IconButton (a toggle with aria-pressed="true" shows the pressed look: accent fill and an inset ring), getButtonClass | | Icons | ArrowLeftIcon … ChatIcon, ChildIcon, LoanIcon, EyeIcon / EyeOffIcon for a show / hide toggle, ShareIcon and SquarePlusIcon for the iOS install steps (38, decorative, size and className; IconProps for an app's own icon) | | Surfaces | Card (boxed, lead, flat; step, done, accent, headingLevel, headingSize, collapsible), CardDisclosure, CollapsibleSection, Stat, EmptyState, Hint, FormError, Checklist (onboarding items), DeferredRender (stream a slow part) | | Fields | Field, FieldGroup, TextField, PasswordField, MoneyField, SuggestedAmountField, ColorField + normalizeHexColor, SelectField, CheckboxField (required, requiredMessage), INPUT_CLASS, NUMBER_INPUT_CLASS | | Controls | Select (ARIA listbox), Switch, SwitchControl, Checkbox, SegmentedControl, SEGMENTED_GROUP_CLASS + SEGMENT_ACTIVE_CLASS / SEGMENT_IDLE_CLASS (an app's own segments), CopyButton | | Navigation | AppHeaderBar, AccountMenu, MobileMenu (the app shell), Stepper (multi-step forms), Tabs (ARIA tabs, roving focus), TabPanels (panels for a tab bar of links), SegmentedNav (links drawn as segments, aria-current), getQueryHref, QuerySegmentedNav (in @softure-ai/ui/next), DisclosureMenu + useDisclosure (a panel of links), ExternalLink, ServerExternalLink | | Dialogs and feedback | Modal (form, confirmation, panel; motion), useModalClose, StandingPanel, ModalBody, ModalFooter, ModalForm, ConfirmActionButton, ActionFormModal, ModalTrigger, ToastHost + announceToast, useDismissed (dismiss a banner for N days) | | Progress and app states | ProgressBar (track, hairline; indeterminate without a value), MiniProgress (a share with its figure inside), LaunchScreen, TopLoadingBar, RouteLoading, UpdatePrompt, InstallBar (the screens @softure-ai/pwa names) | | Chat | ChatLog, ChatMessage, ChatComposer, ToolCallCard, ReasoningDisclosure, ChatEmptyState, ChatError (plain props, no AI SDK dependency; see "Chat") | | Forms | ActionForm (server action, value replay, field errors, success toast), ActionResult, MessageActionResult | | Locale | UiLocaleProvider, useUiLocale | | Money and decimals | parseAmount, formatAmountInput, normalizeAmountInput, getAmountErrorMessage, parseDecimal, formatDecimal, normalizeDecimalInput |

Server-safe (no "use client"): Button, ButtonLink, ButtonAnchor, IconButton, icons, Card, Stat, ProgressBar, MiniProgress, LaunchScreen, TopLoadingBar, RouteLoading, UpdatePrompt, InstallBar, EmptyState, FormError, Field, FieldGroup, TabPanels, SegmentedNav, AppHeaderBar, DeferredRender, getQueryHref, the class constants. The rest are client components (Card and Field render their hint and collapsing through small client components).

Shared props

  • Slots. Every component takes classNames with a typed slot list (Card: root, header, titleRow, title, subtitle; Modal: overlay, panel, header, heading, title, subtitle, close; …). An app class is added to the default and wins, because the defaults sit in @layer softure.
  • unstyled. Drops every default class and keeps structure, ARIA and behaviour.
  • Copy. Components with built-in text (Modal, ModalFooter, StandingPanel, ActionForm, ConfirmActionButton, CopyButton, ExternalLink, AccountMenu, MobileMenu, Stepper, Checklist, ColorField picker name, SuggestedAmountField chip, the chat components (chat), Card hint and collapse names, field hint names) take locale (the provider's, else en, any BCP 47 tag) and partial messages for their group in uiMessages. The built-in copy is English only; an app that shows another language passes its own translation as messages (a key it leaves out reads English). Everything else the user reads (labels, titles, button text) comes from the app as props.
  • Links. ButtonLink renders <a> unless you inject your router's link: <ButtonLink LinkComponent={Link} href="/pricing" variant="primary">. The main entry never imports next/*; only the @softure-ai/ui/next subpath does (next is an optional peer dependency). ButtonAnchor is always a plain <a>, for what a router link must not handle: a download (download), an address outside the app, a full page load.
  • className on Button, ButtonLink and ButtonAnchor is added to the root after classNames.root.

Forms

"use client";
import { ActionForm, MoneyField, TextField } from "@softure-ai/ui";

<ActionForm
  action={saveDebt}                       // (formData) => Promise<ActionResult>
  getErrorMessage={(code) => t(code)}     // codes from the server -> the app's copy
  submitLabel="Save"
  successMessage="Saved"                  // toast; render <ToastHost /> once per page
  onCancel={close}                        // optional: lay out as a Modal body and footer
>
  <TextField name="name" label="Name" required />
  <MoneyField name="amount" label="Amount" locale="de" suffix="EUR" />
</ActionForm>

The action returns { ok: true }, ok() or ok(value) (the form does not read the value), or { ok: false, error: "app.code", fieldErrors?: { name: "app.code" } }.

An app whose actions already return user-facing messages leaves out getErrorMessage: the action then returns a MessageActionResult ({ ok: false, error: "Could not save.", fieldErrors?: { name: "Too long." } }) and the form shows the strings as they are. The types keep the two apart: without getErrorMessage the action must return messages, with it codes.

The submit button is primary unless submitVariant says otherwise. An app whose own forms defaulted to secondary passes it on every form it migrates, or the forms turn to the accent fill. While a save runs the button shows pendingLabel (the package's "Saving…" by default) and keeps its width. After a rejected submit the fields show what was typed (React resets the form) and their own errors; PasswordField never replays. The server parses amounts with the same parseAmount(text, locale) the field formats with. Between groups of three digits it accepts a space, a no-break space (U+00A0), a narrow no-break space (U+202F) and a thin space (U+2009); en also accepts a comma.

The notation is the locale's own, read from Intl.NumberFormat: a locale that groups digits with a space (fr, pl) reads 1 234,56 and takes a comma or a dot as the decimal mark; any other reads its own marks (1,234.56 in en, 1.234,56 in de) and spaces between groups. parseAmount is parseDecimal(text, locale, { scale: 2 }) with the amount error codes. Other fixed-point values use the same grammar at another scale and come back as integers: a percent in basis points is parseDecimal("12,5", "de", { scale: 2 }) (1250), a rate in millionths { scale: 6 }. Errors are ui.decimal_invalid (more fraction digits than the scale included) and ui.decimal_out_of_range. formatDecimal(1250, "de", { scale: 2, minFractionDigits: 0 }) writes "12,5"; without minFractionDigits it keeps all scale digits ("12,50"). normalizeDecimalInput is the blur helper for such a field.

TextField and MoneyField are uncontrolled unless given value; a controlled one also needs onValueChange, which receives the text after every edit (a live calculator recomputes from it). A controlled MoneyField shows value as given and, on blur, calls onValueChange with the amount reformatted when it parses. A rejected submit does not replay into a controlled field: its owner keeps the value. Uncontrolled fields take onValueChange too, to observe edits.

const [rate, setRate] = useState("5");
<TextField name="rate" label="Rate" inputMode="decimal" suffix="%" value={rate} onValueChange={setRate} />

CheckboxField renders a Switch (labelAs="setting", the default) or a Checkbox (labelAs="statement") and replays its state after a rejected submit. switchProps (classNames, controlClassNames, hintProps) and checkboxProps (classNames) reach the control it renders, so an app keeps its own look under unstyled:

<CheckboxField name="notify" label="Notify me" hint="…" hintAs="tooltip" unstyled
  switchProps={{ classNames: appSwitch, controlClassNames: appSwitchControl, hintProps: appHint }} />
<CheckboxField name="terms" label="I accept the terms" labelAs="statement" unstyled checkboxProps={{ classNames: appCheckbox }} />

The label is a node, so a statement can link to the terms; the control is named by the label's text. A setting with a node label and a tooltip hint names its "?" with switchProps.hintLabel (a string label names it by itself).

A consent is a required statement: required with requiredMessage replaces the browser's bubble with the message under the box (aria-invalid, aria-describedby) when a submit finds it unchecked, and moves focus to the box when it is the form's first invalid control (an earlier invalid field keeps it). Checking the box clears the message; a server error for name from ActionForm shows in the same place. Without requiredMessage the browser validates as usual; a setting passes required to its switch.

<CheckboxField name="terms" label={<>I accept the <Link href="/terms">terms</Link></>} labelAs="statement"
  required requiredMessage="Accept the terms to create an account." />

ColorField is a hex colour as text (#rrggbb, sent under name) with the browser's colour picker as its swatch; the two follow each other. On blur #abc and ABCDEF become #aabbcc and #abcdef; other text stays as typed for the pattern and the server to reject, and the swatch keeps the last valid colour. normalizeHexColor(text) is the same rule for the server (null when the text is not a colour). presets ({ value, label }[]) adds a row of swatches above the input: a radio group named "Preset colours: {label}" (colorField.presets), each swatch named by its label; a click or an arrow key fills the field with the preset's #rrggbb, and the swatch matching the value is checked. The swatches are buttons, so the form data still holds only name. Slots: the field's, plus presets, preset, row, swatch, input.

SuggestedAmountField is a MoneyField with a chip under it ("Use 1 234,50 PLN", or suggestionLabel) that fills suggestedValue in the locale's notation and focuses the field. It stays a form field: a rejected submit replays what was sent. suggestionVariant="inline" draws the suggestion as one small muted row instead of a chip: "Suggested: 1 234,50 PLN" and a text button "use" (named "Use 1 234,50 PLN" for screen readers). With suggestedValue={null} (or none) there is nothing to take: the row shows "No suggestion" and no button. suggestionHint adds a "?" after the action that explains the number, or why there is none; it is named "Where the suggestion comes from: {label}" or "Why there is no suggestion: {label}" and takes suggestionHintProps (the app's hint classes, gap and width). Every text is a suggestedAmount message (use, suggested, useShort, none, hintLabel, noneHintLabel), overridable by suggestionMessages or the provider. Slots: the field's, plus group, suggestionRow, suggestion (the chip or the text button) and suggestionText.

<ColorField name="accent" label="Accent colour" defaultValue={brand.accent}
  presets={[{ value: "#0ea5e9", label: "Ocean" }, { value: "#f59e0b", label: "Amber" }]} />
<SuggestedAmountField name="budget" label="Monthly budget" suffix="PLN" suggestedValue={lastMonth} />
<SuggestedAmountField
  name="target"
  label="Monthly target"
  suffix="PLN"
  suggestionVariant="inline"
  suggestedValue={plan.monthly ?? null}
  suggestionHint={plan.monthly === undefined ? "Add three months of data first." : "Your plan's monthly amount."}
/>

Number inputs (TextField with inputMode, MoneyField) use NUMBER_INPUT_CLASS: the mono face with tabular-nums and slashed-zero, the placeholder in sans. It and INPUT_CLASS each carry exactly one font family utility, so the two families never compete on one input.

Surfaces, controls and feedback

<Card title="Net worth" subtitle="3 accounts" hint="Assets minus debts" action={<IconButton label="Add">…</IconButton>}>
  <Stat label="Total" value="1,234,567.00" secondary="1,100,000.00 today" size="lg" />
  <Stat label="Debt" value="-12,000.00" tone="danger" />
</Card>
<Card title="Setup" step={2} done accent="success" headingLevel={3} collapsible defaultOpen>…</Card>
<EmptyState title="No goals yet">Add a goal to see your progress.</EmptyState>
<Hint label="About: Rate">Yearly interest rate before tax.</Hint>   {/* label names the "?" button */}
<Hint label="About: Rate" triggerGap={8}>…</Hint>                  {/* px between "?" and bubble; 6 by default */}
<Card title="Rate" hint="…" hintProps={appHint}>…</Card>            {/* appHint: HintAppearance, as the app's own hints */}
<TextField name="rate" label="Rate" hint="…" hintAs="tooltip" hintProps={appHint} />

<Select name="currency" aria-label="Currency" defaultValue="PLN"
  options={[{ value: "PLN", label: "PLN" }, { value: "EUR", label: "EUR" }]} />
<Switch name="included" label="Include in net worth" description="Counted in the total" defaultChecked />
<Switch name="notify" label="Notify me" hint="…" hintProps={appHint} stateText={{ on: "On", off: "Off" }} />
<Switch name="fromRetirement" label="From retirement" aria-label="From retirement: Food" />  {/* aria-label overrides the label as the name */}
<Checkbox name="terms" label="I accept the terms" required />
<SegmentedControl legend="Period" isLegendHidden value={period} onChange={setPeriod}
  options={[{ value: "month", label: "Month" }, { value: "year", label: "Year" }]} />

<Tabs label="Views" items={[{ id: "chart", label: "Chart", content: <Chart /> },
  { id: "draft", label: "Draft", content: <DraftForm />, isAlwaysMounted: true }]} />
<SegmentedNav label="View" current={view} LinkComponent={NoScrollLink}
  items={[{ id: "chart", href: "?view=chart", label: "Chart" }, { id: "table", href: "?view=table", label: "Table" }]} />
<TabPanels active={tab} panels={[{ id: "overview", content: <Overview /> }, { id: "update", content: <Update />, isAlwaysMounted: true }]} />
<CollapsibleSection title="Goal" subtitle="3 of 5 set" headingLevel={2} defaultOpen>…</CollapsibleSection>

<ToastHost />                     {/* once per page, a polite live region */}
<ToastHost regionProps={{ "data-testid": "toast-region" }} />   {/* id and data-* only: an anchor for browser tests */}
announceToast("Saved");           // from any client code; the same text twice shows twice

Select is a select-only combobox: arrows, Home/End, PageUp/PageDown, typing to jump (matched with locale), Enter or Tab to commit, Escape to close without a change; a hidden input sends the value. Inside a container that animates in (a modal), the open list measures its trigger again when the animation or transition ends. Hint opens on hover and focus, pins on click, and closes on an outside press or focus leaving it; Escape closes it however it opened (hover and focus included). Before hydration it already opens on hover and focus, by CSS alone. The bubble resets text-transform and letter-spacing, so a hint inside an uppercase or tracked heading reads normally. Card, Field, the form fields and Switch render their own "?"; hintProps (a HintAppearance: classNames, triggerGap, isWide) gives it the look and gap of the app's standalone hints.

Switch and Field (with hintAs="tooltip") put the "?" inline after the label: the label reserves its room at the end of its last line (pr-5) and the wrapper (hint in Switch, tooltip in Field and the form fields) draws it there with no advance of its own (-ml-5 w-5), so a wrapping label keeps the "?" next to its last word. The row carries the label's font size, so a field's label row is as tall with a "?" as without one. stateText renders both lines and :checked shows one; that switching is behaviour, so under unstyled the root keeps sft:group/switch, state keeps sft:grid and the lines keep their visibility classes, while stateOn and stateOff take the app's look. An app's own group-has-checked/switch: classes need its own group/switch on classNames.root. Ids follow the switch id (generated when omitted): <id>-description for the description and <id>-hint for the hint bubble. Slots: root, control, text, labelRow, label, hint, state, stateOn, stateOff, description; controlClassNames reaches the SwitchControl inside.

Tabs follows the WAI-ARIA tabs pattern: only the selected tab is in the Tab order, arrows move between tabs and wrap, Home and End jump to the ends. activation="automatic" (default) selects the tab an arrow reaches; "manual" moves focus only, and Enter or Space selects. Controlled with value + onChange, or uncontrolled with defaultValue. Only the selected panel renders: a panel whose state must survive a switch (a form half filled) takes isAlwaysMounted and stays in the tree, hidden. Slots: root, list, tab, panel.

When the route picks the tab (a path or a query parameter, so the choice survives a reload and works without JavaScript), draw the bar with SegmentedNav and the content with TabPanels. SegmentedNav renders a named <nav> of links with the segmented look; the current one carries aria-current (page by default, ariaCurrent to change). LinkComponent renders each link: for a query-parameter switch with Next, a wrapper such as (props) => <Link {...props} scroll={false} /> keeps the scroll position. Slots: root, link. TabPanels renders the active panel plus the isAlwaysMounted ones hidden, with data-tab-panel and no tabpanel role.

CollapsibleSection is the CardDisclosure gesture for any section: a framed bar with the arrow, the title and an optional one-line subtitle (a state, such as "3 of 5 set") is the toggle (aria-expanded, aria-controls), and the collapsed content stays mounted (hidden) so typed text survives. headingLevel (2–6) wraps the toggle in a heading. Slots: root, heading, toggle, arrow, title, subtitle, content.

Every text-* size carries Tailwind's default line height (a ratio of the size token); an explicit leading-* still wins.

Menus, confirmations and small interactions

<DisclosureMenu label="Account" icon={<UserIcon />} isLabelHidden closeKey={usePathname()}>
  <ul><li><Link href="/settings">Settings</Link></li><li><Link href="/billing">Billing</Link></li></ul>
</DisclosureMenu>

<ConfirmActionButton label="Delete account" icon={<TrashIcon />} title="Delete this account?"
  description="All data is removed. This cannot be undone." confirmLabel="Delete"
  action={deleteAccount} />                 {/* () => Promise<{ ok: true, message? } | { ok: false, error }> */}

<ModalTrigger label="Add debt" title="New debt" action={addDebt} getErrorMessage={t} submitLabel="Save"
  successMessage="Added">                   {/* "+" IconButton; the dialog closes after a successful save */}
  <TextField name="name" label="Name" />
</ModalTrigger>

<CopyButton value={token} />                {/* or isIconOnly; label, variant, size, resetMs, onCopy */}
<ExternalLink href="https://example.com">Docs</ExternalLink>
<ServerExternalLink href="https://example.com" locale="de">Docs</ServerExternalLink>  {/* no client code */}

const { isDismissed, dismiss } = useDismissed("banner.trial", 7);

DisclosureMenu is the WAI-ARIA disclosure for navigation (no role="menu"): a button with aria-expanded and aria-controls, and a panel that is hidden while closed. Escape closes it and returns focus to the button. A press outside closes it; it is heard on document in the capture phase, so a handler that stops propagation (React 19 does so before hydration) cannot keep it open. A click on a link inside closes it, and so does a new closeKey: pass the route (usePathname()), since the package imports no framework. Focus leaving by keyboard closes it; a pointer moving focus is already the outside press. The outside press is a pointerdown by default; closeOutsideOn="click" waits for the click instead, for a panel in the document flow (a phone menu pushing the content down) whose collapse on pointerdown would move another element under the finger before the click lands. useDisclosure({ closeKey, closeOutsideOn }) gives the same behaviour to an app's own markup (triggerProps on a <button>, panelProps on the panel). Slots: root, trigger, label, panel; align (end by default) picks the edge the panel lines up with. The panel gives plain links its menu-row look (block, padding, foreground colour, hover background). A link with data-variant (ButtonLink) is left alone and keeps its button look, and the panel's link rules have zero specificity, so a class of the app's own on a link wins over them.

ConfirmActionButton opens a confirmation Modal with the stakes (description) and Cancel plus a danger confirm button; the dialog waits for the user, with no timer. While action runs the dialog cannot be dismissed. { ok: true, message } closes it and announces message (else successMessage) through announceToast; { ok: false, error } keeps it open with error above the buttons, and a rejected action shows the package's copy. isIconOnly with icon draws the trigger as a danger IconButton. Slots: trigger, description, confirm, cancel (added to the footer's Cancel button). modalClassNames reaches the dialog's own slots (overlay, panel, close…), so the app's dialog motion and close button apply, as in ActionFormModal.

An action posted as form data (a server action taking FormData) goes in formAction instead of action, with fields as the hidden inputs: the dialog becomes a form whose confirm button submits it, so a row's delete button keeps its (formData) => … action and its hidden id:

<ConfirmActionButton label="Delete" title="Delete this goal?" description="…" confirmLabel="Delete"
  formAction={deleteGoal} fields={{ id: goal.id }} />

ActionFormModal is an ActionForm (all its props) in a Modal (title, subtitle, width, headingLevel, onClose, modalClassNames): it is not dismissible while saving and closes after a successful save. ModalTrigger adds the bordered "+" IconButton (label, icon, triggerClassNames) that opens it; focus comes back to the button when the dialog closes.

CopyButton writes to navigator.clipboard in a secure context and shows "Copied" for resetMs (2 s), also in a polite live region. Without a secure context, or when the browser refuses, it shows "Copy failed" and a read-only field with the value, focused and selected, with a "Press Ctrl+C" hint. writeToClipboard(value) is the same attempt without the button. Slots: root, button, status, fallback, fallbackInput, fallbackHint.

ExternalLink opens a new tab, keeps the app's rel tokens and adds noopener noreferrer, and ends with a visually hidden "(opens in a new tab)" (slot note). It is a client component (it reads the UiLocaleProvider); ServerExternalLink renders the same link with no client directive and no hook, taking locale (en by default) and messages by props, for a page that ships no JavaScript. getExternalRel(rel) lives in that server-safe module, so a server component can call it.

useDismissed(key, days) returns { isDismissed, dismiss, restore }. localStorage[key] holds the local date of the dismissal (YYYY-MM-DD, nothing else); the notice stays hidden until days calendar days have passed. Blocked or full storage never throws: the notice shows, and dismiss still hides it until the page is left. On the server and until hydration isDismissed is true, so a dismissed banner never flashes in. useDismissed(key, days, { initial: "shown" }) reverses that: the prerendered HTML contains the notice (a marker a deploy check looks for), and a stored dismissal hides it after hydration.

A value in another format (an ISO timestamp an app stored before) counts as not dismissed. To keep such dismissals, rewrite the value once, before the hook reads it:

const old = localStorage.getItem("banner.trial");
if (old !== null && !/^\d{4}-\d{2}-\d{2}$/.test(old) && !Number.isNaN(Date.parse(old))) {
  localStorage.setItem("banner.trial", getDismissalDate(new Date(old)));
}

Progress, loading screens and app prompts

<ProgressBar value={40} label="Upload" />                      {/* 0–100, clamped; no value: a third slides across */}
<ProgressBar label="Loading" size="hairline" />                 {/* 2 px, square, no track */}
<MiniProgress value={62} label="6,200" tone="success" aria-label="Saved: Car" />   {/* a share in a table cell */}

ProgressBar is a role="progressbar" on 0–100 with data-state indeterminate, loading or complete; the indicator is full width and moves by translateX. Without a value a third of the track slides across it; with reduced motion it stands still, full and faint. MiniProgress (slots root, indicator, label, labelOnFill) is a 20 px track that carries its figure: the label is drawn in the text colour and again, clipped to the fill, in the fill's text colour (on-accent on the accent, the page background on success, warning, danger), so it reads at any value. A string label is the bar's value text; both drawn copies are hidden from screen readers.

The screens @softure-ai/pwa names (its README shows the wiring), with the props of theme-notion's components one to one, plus classNames and unstyled:

  • LaunchScreen (root, icon, name, bar, indicator, percent): full screen on the background, the app's icon and name, a bar at 0% and the percentage, plus the counter's inline script.
  • TopLoadingBar (root, bar, indicator): a hairline along the top edge, indeterminate until the counter's first value; it never takes the pointer.
  • RouteLoading (classNames.launchScreen, classNames.topLoadingBar): both, streamed; CSS shows the launch screen below md or in an installed app and the top bar in a wide browser tab. That choice stays under unstyled; a class of the app's that sets display on a screen's root would override it.
  • UpdatePrompt and InstallBar (root, panel, icon, title, body, description, action; the bar adds steps, step, close): a polite status floating at the bottom inside the safe-area insets, the action a primary button at least 44 px tall below md, the close button a 44 px IconButton. The iOS offer shows the Share and Add to Home Screen steps instead of the button.

The counter of @softure-ai/pwa drives them through their data-slots (launch-screen, top-loading-bar, progress, progress-indicator, launch-screen-percent); a repository test runs it on this markup.

App shell, steps and checklists

<AppHeaderBar
  brand={<Link href="/">Acme</Link>}
  nav={<SegmentedNav label="Main" items={items} current={section} LinkComponent={Link} />}
  actions={
    <AccountMenu name={user.name} email={user.email} closeKey={pathname}
      footer={<form action={signOut}><Button variant="ghost" type="submit" fullWidth>Sign out</Button></form>}>
      <Link href="/settings">Settings</Link>
    </AccountMenu>
  }
  mobileMenu={<MobileMenu items={links} LinkComponent={Link} closeKey={pathname} />}
/>

<Stepper label="Sign-up steps" steps={[{ id: "account", label: "Account", href: "/start" }, …]} current="profile" showProgress />
<Checklist items={[{ id: "goal", label: "Add a goal", done: false, href: "/goals/new" }]} LinkComponent={Link} />
<DeferredRender data={getHistory(userId)} fallback={<Skeleton />}>{(rows) => <HistoryTable rows={rows} />}</DeferredRender>

AppHeaderBar (server-safe) is a sticky <header> (isSticky={false} lets it scroll away): brand on the left, nav from the md breakpoint (48rem) up, actions on the right and mobileMenu below md. Slots: root, inner, brand, nav, actions, mobileMenu. AccountMenu and MobileMenu are DisclosureMenus (the same closing rules; pass the route as closeKey) named by the appShell messages ("Account", "Menu"). Their panel carries data-state="open" | "closed": it fades in, and on close it stays shown (inert to the pointer) until its transition ends, then gets hidden; under prefers-reduced-motion it hides at once. AccountMenu shows the UserIcon, or trigger in its place (the account's initial in a circle; the button keeps the name "Account"), isLabelShown adds the name; then name and email, the links (children) and footer after a divider. MobileMenu shows the MenuIcon and a <nav> of items (isCurrent gives aria-current="page"), then children. An entry of items can be a group, { heading, items }: its links go in a nested list named by the heading (isMobileMenuGroup tells the two apart). Extra slots: identity, name, email, footer; nav, list, item, link, group, heading, groupList.

<AccountMenu trigger={<span className="initial">{user.name[0]}</span>} name={user.name} closeKey={pathname} />
<MobileMenu
  items={[
    { heading: "App", items: [{ href: "/", label: "Dashboard", isCurrent: true }] },
    { heading: "Account", items: [{ href: "/settings", label: "Settings" }] },
  ]}
  LinkComponent={Link}
  closeKey={pathname}
/>

Stepper is a <nav> (label) holding an ordered list of steps: an icon or the number in a marker, a check once done. The current step has aria-current="step"; a completed one reads "(completed)" and is the only kind that navigates, through its href (with LinkComponent) or onStepSelect(id), so the form goes back but never skips ahead. showProgress adds "Step 2 of 4". Slots: root, progress, list, item, connector, step, marker, label; each <li> carries data-state (done, current, upcoming).

Checklist lists { id, label, done, href?, description? } under "1 of 3 done" (showProgress={false} hides it). An open item with href is a link (linkDone links a done one too, to revisit the step); each item reads "(done)" or "(to do)" after its name, so the state never rests on the check alone. rowLink makes the whole row the link (marker, label, description and trailing), a bigger target on a phone; without it only the label links. trailing is drawn after the body, as a node or (item, { isLink }) => node; keep decorative content aria-hidden (the icons are), or it joins the row link's name:

<Checklist items={steps} LinkComponent={Link} rowLink linkDone
  trailing={(item, { isLink }) => (isLink ? <ChevronRightIcon /> : null)} />

Slots: root, progress, list, item, row (the row link), marker, body, label, link, description, trailing.

DeferredRender (server-safe) streams a slow part: the page starts the query without await and passes the promise as data; fallback is sent at once and children(value) follows in the same response. A rejection reaches the nearest error boundary. In a client component the promise must be stable (created outside render).

Chat

Building blocks of a chat screen on the --sft-* tokens, so every theme that bridges them styles a chat with no code of its own. They are client components with plain props: ui does not depend on ai or @ai-sdk/*, and an app maps its chat state to them (the recipe below for AI SDK UI's useChat).

| Component | What it does | Slots | | --- | --- | --- | | ChatLog | The message list: role="log", aria-busy while isStreaming, not live itself; a polite status region reads announcement once streaming ends | root, log, list, announcer | | ChatMessage | One message (<li>), data-role (user, assistant, system) and data-status (streaming, done, error); a typing indicator while streaming with no content; meta, actions, name | root, label, bubble, typing, meta, actions | | ChatComposer | A labelled textarea: Enter sends the trimmed text, Shift+Enter adds a line, an IME composition never sends; Send turns into Stop while status is submitted or streaming (with onStop), Retry shows on error (with onRetry); controlled (value, onValueChange) or not | root, label, input, actions, send, stop, retry | | ToolCallCard | A tool call: data-state pending (aria-busy), done (shows children, the app's own output component) or error (shows errorText) | root, header, title, status, body, error | | ReasoningDisclosure | The model's reasoning under a native <details>, folded by default; "Thinking…" while isStreaming | root, summary, content | | ChatEmptyState | Before the first message, with prompt suggestions as buttons (onSuggestion) | root, title, description, suggestions, suggestion | | ChatError | A failed answer, role="alert", with Retry when onRetry is given | root, message, retry |

Types: ChatRole, ChatMessageStatus, ChatStatus (the values of useChat().status), ToolCallState, and each component's …Props and …Slot. The copy is the chat group of uiMessages (log name, role names, composer, tool states, reasoning, empty and error texts), overridable per component through messages or for the whole app through UiLocaleProvider. A message's text keeps its line breaks (white-space: pre-wrap); ui renders no Markdown and no HTML. An app that wants Markdown passes a sanitising renderer's output as children, never raw HTML.

Recipe: AI SDK UI's useChat. One client component maps message parts to props. Each tool gets a component from a registry keyed by tool name, which receives the tool's output only once AI SDK has validated it against the tool's outputSchema (on the server, safeValidateUIMessages re-checks the history the client sends back).

"use client";
import { useChat } from "@ai-sdk/react";
import { ChatComposer, ChatEmptyState, ChatError, ChatLog, ChatMessage, ReasoningDisclosure, ToolCallCard, type ToolCallState } from "@softure-ai/ui";
import { DefaultChatTransport, type ToolUIPart } from "ai";
import type { ReactNode } from "react";
import type { AppChatMessage, AppTools } from "./chat-types"; // AppTools = InferUITools<typeof tools>; AppChatMessage = UIMessage<Metadata, UIDataTypes, AppTools>

type ToolName = keyof AppTools & string;

// One entry per tool: its title and how its validated output is drawn. Output is data, never HTML.
const TOOL_VIEWS: { [Name in ToolName]: { readonly title: string; readonly render: (output: AppTools[Name]["output"]) => ReactNode } } = {
  getProjectStatus: { title: "Project status", render: (output) => <ProjectStatus status={output} /> },
};

function getToolState(state: ToolUIPart["state"]): ToolCallState {
  if (state === "output-available") return "done";
  if (state === "output-error" || state === "output-denied") return "error";
  return "pending"; // input-streaming, input-available, approval-requested, approval-responded
}

function renderPart(part: AppChatMessage["parts"][number], key: number): ReactNode {
  if (part.type === "text") return part.text;
  if (part.type === "reasoning") return <ReasoningDisclosure key={key} isStreaming={part.state === "streaming"}>{part.text}</ReasoningDisclosure>;
  if (part.type.startsWith("tool-")) {
    const tool = part as ToolUIPart<AppTools>;
    const name = tool.type.slice("tool-".length) as ToolName;
    const view = TOOL_VIEWS[name];
    const state = getToolState(tool.state);
    return (
      <ToolCallCard key={key} title={view.title} state={state} errorText={state === "error" ? "The tool failed." : undefined}>
        {tool.state === "output-available" ? view.render(tool.output) : null}
      </ToolCallCard>
    );
  }
  return null; // files, sources, data parts: render them explicitly when the app uses them
}

export function Chat() {
  const { messages, sendMessage, status, stop, regenerate, error } = useChat<AppChatMessage>({
    transport: new DefaultChatTransport({ api: "/api/chat" }),
  });
  const isStreaming = status === "submitted" || status === "streaming";
  const last = messages.at(-1);
  const announcement = last?.role === "assistant" ? last.parts.flatMap((part) => (part.type === "text" ? [part.text] : [])).join(" ") : undefined;
  return (
    <>
      {messages.length === 0 ? (
        <ChatEmptyState suggestions={["How is my project going?"]} onSuggestion={(text) => void sendMessage({ text })} />
      ) : (
        <ChatLog isStreaming={isStreaming} announcement={announcement}>
          {messages.map((message) => (
            <ChatMessage key={message.id} role={message.role} status={isStreaming && message === last && message.role === "assistant" ? "streaming" : "done"}>
              {message.parts.map(renderPart)}
            </ChatMessage>
          ))}
          {status === "submitted" ? <ChatMessage role="assistant" status="streaming" /> : null}
        </ChatLog>
      )}
      {error === undefined ? null : <ChatError onRetry={() => void regenerate()} />}
      <ChatComposer status={status} onSend={(text) => void sendMessage({ text })} onStop={() => void stop()} onRetry={() => void regenerate()} />
    </>
  );
}

Notes: the error text shown to the user comes from the app's copy (the route maps failures to codes, as for any route); a tool missing from TOOL_VIEWS fails the type check, so a new tool cannot render as nothing by accident; scrolling the log to the newest message is the app's layout (for example a flex-col-reverse scroller or a scrollIntoView on the last message).

Next.js adapter (@softure-ai/ui/next)

import { QuerySegmentedNav } from "@softure-ai/ui/next";

<Suspense>
  <QuerySegmentedNav label="View" param="view" defaultId="table"
    items={[{ id: "table", label: "Table" }, { id: "chart", label: "Chart" }]} />
</Suspense>

QuerySegmentedNav is a SegmentedNav whose items switch a view through one query parameter: each link sets param and keeps the rest of the query string, defaultId's link removes it, and Next's Link navigates with scroll={false}, so the reader keeps their place. The current item comes from the address (useSearchParams); a value no item has falls back to defaultId. When the server has already parsed the query (an alias, an unknown value mapped to the default), pass its result as active: it wins over the address, so the highlighted item is the view the server rendered. Outside the App Router (the Pages Router, renderToStaticMarkup in a unit test) Next's hooks return null; the query then counts as empty and the links are query-only (?view=chart, ? for defaultId). On a statically rendered route wrap it in <Suspense>, as Next requires for useSearchParams. getQueryHref({ pathname, search, param, value }) in the main entry builds the same addresses for an app's own links.

SegmentedControl marks the checked segment with an inset ring in the text colour as well as the accent fill, and SEGMENT_ACTIVE_CLASS does the same, so the choice reads without colour (WCAG 1.4.11) even with a light accent.

Modal

Render <Modal title onClose> while it is open. It moves focus in, keeps Tab inside, makes the rest of <body> inert (live regions stay reachable), locks the page scroll and returns focus to the opener. Escape closes it unless something inside handled the key first (an open Select list). Pass isDismissible={false} while a save runs (ActionForm onPendingChange). The backdrop is the color-overlay token.

motion="enter-leave" animates the close too. Escape, the backdrop, the close button, ModalFooter's Cancel and useModalClose()(onClose) (an app's own close button inside the dialog) first set data-state="closing" on the overlay and the panel, wait for their transitions or animations to end (at most one second, at once when nothing moves, as with prefers-reduced-motion) and then call the owner's onClose. The default look fades the overlay and slides the panel back; an app's own keyframes key on data-state (open, closing) through classNames. ConfirmActionButton and ActionFormModal pass modalMotion on. A successful save still closes at once.

width="panel" is a full-height sheet from the right (37.5rem, full screen on a phone) with the footer at the bottom. <StandingPanel isOpen title onClose> is that sheet mounted for good: closed, it is hidden and a draft typed inside survives; open, it is the dialog, and Escape from inside it closes it (a confirmation Modal opened from the panel closes on its own Escape first).

Both render the title as h2; headingLevel (1–3) changes the element, not the look. A panel that is the screen (an address of its own) passes headingLevel={1}, or isOpen ? 1 : 2 when it stays mounted closed on a page that has its own h1. The cancel slot of ModalFooter (and of ActionForm with onCancel) is added to the Cancel button's look, like Button's className. ActionForm's submit slot does the same for its submit button, in the page layout and in the modal footer.

A Card with collapsible turns its header into the toggle (its "?" and action stay clickable) and keeps the content mounted while collapsed. step shows a numbered badge (a tick with done), accent a short bar before the title in a semantic colour, headingLevel sets h2–h4 and headingSize="section" the larger title.

Testing helpers (@softure-ai/ui/testing)

Colour guards for tests, plain functions with no test-runner import. Each check returns its failures as values, so a test reads expect(failures).toEqual([]) and a red run lists every failing pair at once.

import { DEFAULT_THEME, mergeThemes } from "@softure-ai/ui";
import { checkThemeContrast, DEFAULT_CONTRAST_PAIRS, findColorCollisions } from "@softure-ai/ui/testing";

it("our theme keeps WCAG AA contrast in both schemes", () => {
  const theme = mergeThemes(DEFAULT_THEME, appTheme);
  expect(checkThemeContrast(DEFAULT_CONTRAST_PAIRS, theme)).toEqual([]);
});

it("our series colours stay apart for colour-blind readers", () => {
  expect(findColorCollisions(["#2563eb", "#d97706", "#0f766e"])).toEqual([]);
});
  • Contrast: contrastRatio(a, b) (WCAG 2, 1–21), getContrastLevel(ratio, use) with use text (AA 4.5, AAA 7), large-text (3, 4.5) or non-text (3, WCAG 1.4.11), WCAG_CONTRAST, relativeLuminance, and blendColors(tint, ground, alpha) for a composited bg-x/10.
  • Themes: checkThemeContrast(pairs, schemes?) measures each { foreground, background, use, level? } in the light and the dark set; background may be { tint, alpha, over }. Without schemes it checks DEFAULT_THEME; it also takes an app's own token names and values. A missing token or a value that is not #rrggbb/#rgb (a var()) is reported, never guessed. DEFAULT_CONTRAST_PAIRS are the pairs this package's components paint; the package runs them on its own tokens, so a token change that breaks contrast fails its tests.
  • Colour vision: simulateColorVision(color, "protan" | "deutan" | "tritan") (Viénot 1999 for protan and deutan, Machado 2009 for tritan), colorDistance(a, b, { metric }) in CIEDE2000 (default) or CIE76, minVisionDistance, labHue, hueDistance, and findColorCollisions(colors, { minDistance, visions, metric }), which reports every pair closer than minDistance (default DEFAULT_MIN_COLOR_DISTANCE, 10 in CIEDE2000) in normal vision or a simulation. CIEDE2000 is the default because CIE76 inflates distances unevenly (1.4× for darks, up to 3.8× for blues), so one CIE76 threshold means something different per hue.

Source guards

Guards an app runs over its own source files, built for readSourceFiles from @softure-ai/testing/guards (any { file, source }[] works). Each returns file:line: … strings. They read code with the TypeScript parser, so typescript must be installed to import @softure-ai/ui/testing (an optional peer dependency, already in every TypeScript app); comments never count.

TypeScript 7.0 ships no compiler API, so the guards need TypeScript 6 (>=5.0.0 <7.0.0). An app on TypeScript 7 keeps tsc from 7 and installs the API side by side, as the TypeScript 7.0 announcement recommends:

{
  "devDependencies": {
    "@typescript/native": "npm:typescript@^7.0.2",
    "typescript": "npm:@typescript/typescript6@^6.0.2"
  }
}
import { readFileSync } from "node:fs";
import { readSourceFiles } from "@softure-ai/testing/guards";
import {
  findHoverOnlyHandlers,
  findNativeTooltips,
  findRestrictedElements,
  findUndefinedTokenClasses,
} from "@softure-ai/ui/testing";

const sources = readSourceFiles("src", { dirs: ["app", "components"] });
const css = [readFileSync("src/app/globals.css", "utf8"), readFileSync("node_modules/@softure-ai/ui/dist/tailwind.css", "utf8")];

it("names only defined tokens in Tailwind classes", () => {
  expect(findUndefinedTokenClasses({ css, sources })).toEqual([]);
});

it("uses Hint, never a native title, and opens nothing on hover only", () => {
  expect(findNativeTooltips(sources)).toEqual([]);
  expect(findHoverOnlyHandlers(sources)).toEqual([]);
});

it("keeps one select and one portal", () => {
  expect(findRestrictedElements(sources, { select: [], createPortal: ["components/modal.tsx"] })).toEqual([]);
});
  • Token classes: findUndefinedTokenClasses({ css, sources, prefix?, allow? }) reads the classes in string and template literals. Colour utilities (bg-, text-, border- and its sides, fill-, stroke-, outline-, with any variants, ! and /opacity) need a --color-* in a @theme block of css, text-<size> a --text-*, ease-<name> an --ease-*; a (--name) value needs --name declared anywhere in css. A named duration-* is always reported: Tailwind 4 has no duration namespace, so duration-fast compiles to nothing (write duration-(--sft-duration-fast)). Arbitrary values, keyword and numeric utilities, and a class glued to a ${…} pass. @import is not followed: pass every file with a @theme. prefix checks only prefix: classes; allow takes classes (strings or patterns) that only look like utilities, such as a data-testid.
  • Tooltips: findNativeTooltips(sources) reports a title attribute on an HTML or SVG element (<span title>); a component's title prop and an SVG <title> child pass. findHoverOnlyHandlers(sources) reports an element with onMouseEnter, onMouseOver, onPointerEnter or onPointerOver and no onFocus; Hint opens on both.
  • One implementation: findRestrictedElements(sources, { select, createPortal }) reports a raw <select> and a createPortal call outside the files listed for each (a path, its end, or a RegExp); a key left out is not checked.

How the CSS is built

npm run build runs tsc, then scripts/build-css.mjs, which compiles the components with the Tailwind 4 CLI into dist/styles.css and writes dist/tailwind.css. It prints the gzip size and fails above 20 kB (NFR-7).

  • Components use Tailwind classes with the sft: prefix (sft:bg-surface, sft:hover:text-foreground). The package theme is @theme inline reference prefix(sft), so every utility reads a --sft-* token and Tailwind emits no variables of its own. Durations have no Tailwind namespace: sft:duration-(--sft-duration-fast).
  • styles.css opens with @layer theme, base, softure, components, utilities;: softure sits above the app's resets and below the app's components and utilities, so an app class always wins. Imported after the app's Tailwind (for example from JavaScript after globals.css), softure would land above the app's utilities; keep the import order shown above.
  • Raw colours are allowed only in src/theme/; tests/architecture.test.ts keeps them out of src/ui/, together with inline copy (JSX text and literal aria-*, title, placeholder, alt, label).
  • A utility whose theme value is missing compiles to nothing, silently. tests/styles.test.ts therefore requires a compiled selector for every sft: class written in src/ui/; the static theme in scripts/build-css.mjs adds the base spacing, one breakpoint, two container widths, line heights (also the one each text size carries), tracking and the spinner animation.