diff --git a/.changeset/README.md b/.changeset/README.md
index 4f3b76b..a1622eb 100644
--- a/.changeset/README.md
+++ b/.changeset/README.md
@@ -6,3 +6,20 @@ find the full documentation for it [in our repository](https://github.com/change
We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/master/docs/common-questions.md)
+
+## npm Trusted Publishing
+
+The release workflow uses GitHub Actions OIDC. In the npm settings for each
+published `@precursor/*` package, configure a GitHub Actions trusted publisher
+for owner `danieldelcore`, repository `precursor`, and workflow `release.yml`.
+Allow direct npm publishing and leave the environment field blank. In the
+repository's Actions settings, allow GitHub Actions to create pull requests.
+
+Once the release PR is merged, the workflow publishes the updated packages.
+Use the Release workflow's manual dispatch on `master` to retry a release.
+
+For new packages such as `@precursor/divider`, `@precursor/bleed`, and `@precursor/popup`, an npm
+maintainer must publish an initial version before the package can be configured
+for Trusted Publishing. Use a bootstrap version below the planned release
+version and a separate dist-tag so the version selected by Changesets remains
+available for the first CI release.
diff --git a/.changeset/config.json b/.changeset/config.json
index 09890ec..ea58bd3 100644
--- a/.changeset/config.json
+++ b/.changeset/config.json
@@ -1,5 +1,5 @@
{
- "$schema": "https://unpkg.com/@changesets/config@1.0.1/schema.json",
+ "$schema": "https://unpkg.com/@changesets/config@4.1.0/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"access": "public",
diff --git a/.changeset/four-theme-slots.md b/.changeset/four-theme-slots.md
new file mode 100644
index 0000000..ba7edab
--- /dev/null
+++ b/.changeset/four-theme-slots.md
@@ -0,0 +1,37 @@
+---
+'@precursor/badge': patch
+'@precursor/bleed': minor
+'@precursor/blockquote': patch
+'@precursor/button': patch
+'@precursor/checkbox': patch
+'@precursor/code': patch
+'@precursor/divider': minor
+'@precursor/grid': patch
+'@precursor/heading': minor
+'@precursor/inline': patch
+'@precursor/input': patch
+'@precursor/keyboard': patch
+'@precursor/label': patch
+'@precursor/lozenge': patch
+'@precursor/message': patch
+'@precursor/modal': patch
+'@precursor/panel': patch
+'@precursor/radio': patch
+'@precursor/range': patch
+'@precursor/select': patch
+'@precursor/skeleton': patch
+'@precursor/spinner': patch
+'@precursor/stack': patch
+'@precursor/tabs': patch
+'@precursor/text': minor
+'@precursor/textarea': patch
+'@precursor/theme': major
+'@precursor/toggle': patch
+'@precursor/tokens': major
+---
+
+Generate theme variants at build time with Style Dictionary. Select color, spacing, shape, and typography through ThemeProvider's `selection` prop. For synchronous SSR, prepare `initialTheme` with `loadTheme`. The color slot has independent light and dark palettes. The separate `colorMode` setting defaults to `auto` and follows the browser preference before hydration.
+
+Grid, Stack, Inline, Text, and Heading now use the generated tokens. Divider and Bleed are available as new primitives. The component catalog uses the new token contract through the existing exports.
+
+Use `--spacing-gap-*` for margins and gaps and `--spacing-inset-*` for padding. The previous step spacing tokens are removed. Use `--spacing-inline` between inline elements. Squish remains available as `--spacing-inset-squish`.
diff --git a/.changeset/full-width-grid-rows.md b/.changeset/full-width-grid-rows.md
new file mode 100644
index 0000000..e3ff44d
--- /dev/null
+++ b/.changeset/full-width-grid-rows.md
@@ -0,0 +1,5 @@
+---
+'@precursor/grid': patch
+---
+
+Span each Row across the parent Grid and align its columns with the parent tracks. A single child fills the row by default.
diff --git a/.changeset/native-overlays-and-variants.md b/.changeset/native-overlays-and-variants.md
new file mode 100644
index 0000000..a175eea
--- /dev/null
+++ b/.changeset/native-overlays-and-variants.md
@@ -0,0 +1,10 @@
+---
+'@precursor/button': minor
+'@precursor/checkbox': minor
+'@precursor/modal': minor
+'@precursor/popup': minor
+'@precursor/tabs': minor
+'@precursor/tokens': minor
+---
+
+Add pill tabs, a monospace typography theme, and a themed checkbox with native form behavior. Add Popup using the native Popover API and support popover targets on Button. Modal now uses the native modal dialog API for focus and dismissal.
diff --git a/.changeset/static-precursor-styles.md b/.changeset/static-precursor-styles.md
new file mode 100644
index 0000000..e92a319
--- /dev/null
+++ b/.changeset/static-precursor-styles.md
@@ -0,0 +1,35 @@
+---
+'@precursor/avatar': major
+'@precursor/badge': major
+'@precursor/blockquote': major
+'@precursor/button': major
+'@precursor/checkbox': major
+'@precursor/code': major
+'@precursor/emoji': major
+'@precursor/grid': major
+'@precursor/heading': major
+'@precursor/image': major
+'@precursor/inline': major
+'@precursor/input': major
+'@precursor/keyboard': major
+'@precursor/label': major
+'@precursor/list': major
+'@precursor/lozenge': major
+'@precursor/message': major
+'@precursor/modal': major
+'@precursor/overlay': major
+'@precursor/panel': major
+'@precursor/radio': major
+'@precursor/range': major
+'@precursor/select': major
+'@precursor/skeleton': major
+'@precursor/spinner': major
+'@precursor/stack': major
+'@precursor/tabs': major
+'@precursor/text': major
+'@precursor/textarea': major
+'@precursor/theme': major
+'@precursor/toggle': major
+---
+
+Require React 19 and ship styles compiled by Trousers 4. Browser-aware bundlers load the styles with each component. For server-rendered apps, include the generated CSS in the client bundle. Render a ThemeProvider around styled components to supply the default or a custom theme.
diff --git a/.changeset/trousers-named-insets.md b/.changeset/trousers-named-insets.md
new file mode 100644
index 0000000..9bdf397
--- /dev/null
+++ b/.changeset/trousers-named-insets.md
@@ -0,0 +1,37 @@
+---
+'@precursor/avatar': patch
+'@precursor/badge': patch
+'@precursor/bleed': patch
+'@precursor/blockquote': patch
+'@precursor/button': patch
+'@precursor/checkbox': patch
+'@precursor/code': patch
+'@precursor/divider': patch
+'@precursor/grid': patch
+'@precursor/heading': patch
+'@precursor/image': patch
+'@precursor/inline': patch
+'@precursor/input': patch
+'@precursor/keyboard': patch
+'@precursor/label': patch
+'@precursor/list': patch
+'@precursor/lozenge': patch
+'@precursor/message': patch
+'@precursor/modal': patch
+'@precursor/panel': patch
+'@precursor/popup': patch
+'@precursor/radio': patch
+'@precursor/range': patch
+'@precursor/select': patch
+'@precursor/skeleton': patch
+'@precursor/spinner': patch
+'@precursor/stack': patch
+'@precursor/tabs': patch
+'@precursor/text': patch
+'@precursor/textarea': patch
+'@precursor/theme': patch
+'@precursor/toggle': patch
+'@precursor/tokens': minor
+---
+
+Update the Trousers runtime and compiler to 4.1.0. Add a large inset token and use Trousers named inset variants in the Storybook layout examples.
diff --git a/.changeset/workspace-package-exports.md b/.changeset/workspace-package-exports.md
new file mode 100644
index 0000000..cd732e0
--- /dev/null
+++ b/.changeset/workspace-package-exports.md
@@ -0,0 +1,7 @@
+---
+'@precursor/copy-to-clipboard': patch
+'@precursor/tokens': patch
+'@precursor/types': patch
+---
+
+Publish JavaScript and types for both ESM and CommonJS consumers. Remove a trailing semicolon from the default font-family token so it can be applied as an inline style.
diff --git a/.eslintrc.js b/.eslintrc.js
deleted file mode 100644
index 28be629..0000000
--- a/.eslintrc.js
+++ /dev/null
@@ -1,37 +0,0 @@
-module.exports = {
- root: true,
- parser: '@typescript-eslint/parser',
- extends: [
- 'plugin:react/recommended',
- 'plugin:@typescript-eslint/recommended',
- 'prettier/@typescript-eslint',
- 'plugin:prettier/recommended',
- 'plugin:jsx-a11y/recommended',
- ],
- plugins: ['import', 'jsx-a11y', 'react', 'react-hooks'],
- parserOptions: {
- ecmaVersion: 2018,
- sourceType: 'module',
- project: './tsconfig.json',
- ecmaFeatures: {
- jsx: true,
- },
- },
- rules: {
- 'react-hooks/rules-of-hooks': 'error',
- 'react-hooks/exhaustive-deps': 'warn',
- 'react/prop-types': 'off',
- 'react/display-name': 'off',
- '@typescript-eslint/explicit-function-return-type': 'off',
- '@typescript-eslint/no-explicit-any': 'off',
- '@typescript-eslint/explicit-member-accessibility': 'off',
- '@typescript-eslint/no-non-null-assertion': 'off',
- '@typescript-eslint/no-parameter-properties': 'off',
- },
- settings: {
- react: {
- version: 'detect',
- },
- },
- ignorePatterns: ['dist', 'node_modules'],
-};
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 6ffc4d5..8512603 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -2,33 +2,33 @@ name: Release
on:
push:
- branches:
- - master
+ branches: [master]
+ workflow_dispatch:
+
+concurrency:
+ group: release-${{ github.ref }}
+ cancel-in-progress: false
jobs:
release:
- name: Release
+ if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
+ permissions:
+ contents: write
+ pull-requests: write
+ id-token: write
steps:
- - name: Checkout Repo
- uses: actions/checkout@master
+ - uses: actions/checkout@v7
with:
- # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0
-
- - name: Setup Node.js 12.x
- uses: actions/setup-node@master
+ persist-credentials: false
+ - uses: actions/setup-node@v6
with:
- node-version: 12.x
-
- - name: Install Dependencies
- run: yarn
-
- - name: Create Release Pull Request or Publish to npm
- uses: changesets/action@master
+ node-version-file: .node-version
+ - run: npm install --global corepack@0.36.0
+ - run: corepack enable
+ - run: yarn install --immutable
+ - uses: changesets/action@v2.1.2
with:
- # this expects you to have a script called release which does a build for your packages and calls changeset publish
- publish: yarn release
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
+ version-script: yarn version:packages
+ publish-script: yarn release
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
deleted file mode 100644
index 81a1566..0000000
--- a/.github/workflows/test.yml
+++ /dev/null
@@ -1,27 +0,0 @@
-name: Test
-
-on:
- push:
- branches: [master]
- pull_request:
- branches: [master]
-
-jobs:
- build:
- runs-on: ubuntu-latest
-
- strategy:
- matrix:
- node-version: [12.x]
-
- steps:
- - uses: actions/checkout@v2
- - name: Use Node.js ${{ matrix.node-version }}
- uses: actions/setup-node@v1
- with:
- node-version: ${{ matrix.node-version }}
- - run: npm install -g yarn
- - run: yarn install --frozen-lockfile
- - run: yarn test
- env:
- CI: true
diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml
index 5a53604..d5dee42 100644
--- a/.github/workflows/validate.yml
+++ b/.github/workflows/validate.yml
@@ -6,22 +6,19 @@ on:
pull_request:
branches: [master]
+permissions:
+ contents: read
+
jobs:
- build:
+ validate:
runs-on: ubuntu-latest
-
- strategy:
- matrix:
- node-version: [12.x]
-
steps:
- - uses: actions/checkout@v2
- - name: Use Node.js ${{ matrix.node-version }}
- uses: actions/setup-node@v1
+ - uses: actions/checkout@v7
+ - uses: actions/setup-node@v6
with:
- node-version: ${{ matrix.node-version }}
- - run: npm install -g yarn
- - run: yarn install --frozen-lockfile
+ node-version-file: .node-version
+ - run: npm install --global corepack@0.36.0
+ - run: corepack enable
+ - run: yarn install --immutable
- run: yarn validate
- env:
- CI: true
+ - run: yarn storybook build
diff --git a/.gitignore b/.gitignore
index 8fa0575..586dfe9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,10 @@ lib
dist
.site
.DS_Store
-.vscode
+**/.vscode/*
+!/.vscode/settings.json
+!/.vscode/extensions.json
storybook-static
tsconfig.tsbuildinfo
+.yarn/install-state.gz
+/packages/theming/tokens/theme-registry.generated.ts
diff --git a/.node-version b/.node-version
new file mode 100644
index 0000000..a45fd52
--- /dev/null
+++ b/.node-version
@@ -0,0 +1 @@
+24
diff --git a/.oxfmtrc.json b/.oxfmtrc.json
new file mode 100644
index 0000000..a815363
--- /dev/null
+++ b/.oxfmtrc.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "./node_modules/oxfmt/configuration_schema.json",
+ "singleQuote": true,
+ "tabWidth": 4,
+ "printWidth": 80,
+ "ignorePatterns": [
+ "**/dist/**",
+ "storybook-static/**",
+ "coverage/**",
+ "**/CHANGELOG.md"
+ ]
+}
diff --git a/.oxlintrc.json b/.oxlintrc.json
new file mode 100644
index 0000000..2f81429
--- /dev/null
+++ b/.oxlintrc.json
@@ -0,0 +1,9 @@
+{
+ "$schema": "./node_modules/oxlint/configuration_schema.json",
+ "plugins": ["typescript", "react", "jsx-a11y"],
+ "ignorePatterns": ["**/dist/**", "storybook-static/**", "coverage/**"],
+ "rules": {
+ "react/rules-of-hooks": "error",
+ "react/exhaustive-deps": "error"
+ }
+}
diff --git a/.prettierignore b/.prettierignore
deleted file mode 100644
index 1521c8b..0000000
--- a/.prettierignore
+++ /dev/null
@@ -1 +0,0 @@
-dist
diff --git a/.prettierrc.js b/.prettierrc.js
deleted file mode 100644
index 773948a..0000000
--- a/.prettierrc.js
+++ /dev/null
@@ -1,7 +0,0 @@
-module.exports = {
- semi: true,
- trailingComma: 'all',
- singleQuote: true,
- printWidth: 80,
- tabWidth: 4,
-};
diff --git a/.storybook/addons.js b/.storybook/addons.js
deleted file mode 100644
index e69de29..0000000
diff --git a/.storybook/config.js b/.storybook/config.js
deleted file mode 100644
index b7a148a..0000000
--- a/.storybook/config.js
+++ /dev/null
@@ -1,6 +0,0 @@
-import { configure } from '@storybook/react';
-
-configure(
- require.context('../examples', true, /\.(js|jsx|ts|tsx|md|mdx)$/),
- module,
-);
diff --git a/.storybook/main.ts b/.storybook/main.ts
new file mode 100644
index 0000000..fc73cda
--- /dev/null
+++ b/.storybook/main.ts
@@ -0,0 +1,59 @@
+import { relative, resolve, sep } from 'node:path';
+import type { StorybookConfig } from '@storybook/react-vite';
+import { mergeConfig, type Plugin } from 'vite';
+import { buildPackage } from '../scripts/build.mjs';
+import { buildTokens } from '../scripts/build-tokens.mjs';
+
+function watchPackages(): Plugin {
+ return {
+ name: 'precursor-workspaces',
+ configureServer(server) {
+ let pending = Promise.resolve();
+ server.watcher.on('change', (file) => {
+ const path = relative(process.cwd(), file).split(sep).join('/');
+ const match =
+ /^(packages\/[^/]+\/[^/]+|fixtures)\/[^/]+\.tsx?$/.exec(
+ path,
+ );
+ const isTokenSource =
+ /^packages\/theming\/tokens\/themes\/(?:[^/]+\/)+[^/]+\.json$/.test(
+ path,
+ );
+ if ((!match && !isTokenSource) || path.endsWith('.spec.tsx'))
+ return;
+
+ pending = pending
+ .then(() =>
+ isTokenSource ? buildTokens() : buildPackage(match![1]),
+ )
+ .then(() => server.ws.send({ type: 'full-reload' }))
+ .catch((error) =>
+ server.config.logger.error(String(error)),
+ );
+ });
+ },
+ };
+}
+
+export default {
+ framework: '@storybook/react-vite',
+ stories: ['../examples/**/*.stories.tsx'],
+ staticDirs: ['../assets'],
+ typescript: { reactDocgen: false },
+ core: { disableTelemetry: true },
+ async viteFinal(config, { configType }) {
+ await buildPackage('fixtures');
+
+ return mergeConfig(config, {
+ resolve: {
+ alias: [
+ {
+ find: /^\.\.\/fixtures$/,
+ replacement: resolve('fixtures/dist/browser.mjs'),
+ },
+ ],
+ },
+ plugins: configType === 'DEVELOPMENT' ? [watchPackages()] : [],
+ });
+ },
+} satisfies StorybookConfig;
diff --git a/.storybook/webpack.config.js b/.storybook/webpack.config.js
deleted file mode 100644
index b59c7cd..0000000
--- a/.storybook/webpack.config.js
+++ /dev/null
@@ -1,17 +0,0 @@
-module.exports = ({ config }) => {
- config.module.rules.push({
- test: /\.(ts|tsx)$/,
- use: [
- {
- loader: require.resolve('ts-loader'),
- options: {
- transpileOnly: true,
- },
- },
- ],
- });
-
- config.resolve.extensions.push('.ts', '.tsx');
-
- return config;
-};
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
new file mode 100644
index 0000000..9d5eb3d
--- /dev/null
+++ b/.vscode/extensions.json
@@ -0,0 +1,3 @@
+{
+ "recommendations": ["oxc.oxc-vscode"]
+}
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..1d9dd69
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,34 @@
+{
+ "editor.detectIndentation": false,
+ "editor.insertSpaces": true,
+ "editor.tabSize": 4,
+ "editor.formatOnSave": true,
+ "editor.formatOnSaveMode": "file",
+ "[css]": {
+ "editor.defaultFormatter": "oxc.oxc-vscode"
+ },
+ "[javascript]": {
+ "editor.defaultFormatter": "oxc.oxc-vscode"
+ },
+ "[javascriptreact]": {
+ "editor.defaultFormatter": "oxc.oxc-vscode"
+ },
+ "[json]": {
+ "editor.defaultFormatter": "oxc.oxc-vscode"
+ },
+ "[jsonc]": {
+ "editor.defaultFormatter": "oxc.oxc-vscode"
+ },
+ "[markdown]": {
+ "editor.defaultFormatter": "oxc.oxc-vscode"
+ },
+ "[typescript]": {
+ "editor.defaultFormatter": "oxc.oxc-vscode"
+ },
+ "[typescriptreact]": {
+ "editor.defaultFormatter": "oxc.oxc-vscode"
+ },
+ "[yaml]": {
+ "editor.defaultFormatter": "oxc.oxc-vscode"
+ }
+}
diff --git a/.yarnrc.yml b/.yarnrc.yml
new file mode 100644
index 0000000..52ee0b7
--- /dev/null
+++ b/.yarnrc.yml
@@ -0,0 +1,10 @@
+nodeLinker: node-modules
+
+npmPublishRegistry: 'https://registry.npmjs.org'
+
+npmPublishProvenance: true
+
+packageExtensions:
+ 'storybook@11.0.0':
+ peerDependencies:
+ react: '^18.0.0 || ^19.0.0'
diff --git a/README.md b/README.md
index 2295959..b860db7 100644
--- a/README.md
+++ b/README.md
@@ -4,45 +4,147 @@
# Precursor
-Start your projects with a minimalistic, composable, lightweight and themable component library.
-
-## Layout & Composability π
-
-## Theming π
+Precursor provides design tokens and React primitives for building interfaces.
+Grid, Stack, Inline, Text, Heading, Divider, and Bleed are available as
+individual packages. See the [implementation brief](docs/theming-brief.md)
+for the full design.
+
+## Component design rules
+
+- **Control appearance through variants.** Expose supported visual options as
+ variants and keep `className` out of the public styling API. This keeps each
+ visual combination within the component's design constraints.
+- **Use purpose-built layout primitives.** Keep generic `Box` primitives out of
+ the library. A catch-all component with arbitrary styling props turns into a
+ CSS-in-JS API. Compose Grid, Stack, Inline, and Bleed for layout.
+
+## Theming
+
+Use React 19 and render a `ThemeProvider` around Precursor components. Each
+provider selects color, spacing, shape, and typography independently. Its
+tokens apply to its descendants, including Precursor modals in a portal.
+
+```tsx
+import Button from '@precursor/button';
+import { ThemeProvider } from '@precursor/theme';
+
+
+
+;
+```
+
+Choose light and dark palettes independently under `selection.color`.
+`selection.colorMode` controls which slot is shown. It defaults to `auto`,
+which follows the browser's color preference before and after hydration.
+Explicit `light` or `dark` keeps the corresponding slot active and loads
+only its palette. The other slots default to comfortable spacing, rounded
+shapes, and sans-serif typography. The previous selection stays active
+until the new styles load. Use `onLoadError(error, retry)` to handle failures.
+
+Replace the old `theme` object prop and token-object imports with named
+variants. Edit the JSON token sources in `packages/theming/tokens/themes` to
+define or change variants. Keep color palettes in `color/light` and `color/dark`.
+Style Dictionary generates the published styles
+and loaders at the start of `yarn build`. Storybook and releases use that
+same build.
+
+Precursor extracts CSS at build time using [Trousers 4](https://github.com/danieldelcore/trousers).
+Bundlers that resolve the browser export include the styles for each imported
+component and its styled dependencies. If your bundler uses a server export
+for the client build, enable browser resolution or import the required styles
+from `@precursor//styles.css` in the client entry.
+
+## Component variants and overlays
+
+Set `` to style a tab group as pills. Select
+`typography: 'monospace'` in the theme selection to use the monospace theme.
+
+Use `Popup` for non-modal content and give a `Button` the matching
+`popoverTarget`. The browser manages toggling, Escape, and outside dismissal.
+Use `Modal` for content that requires modal focus and an inert background.
## Iconography πΎ
Precursor does not export its own set of iconography in order to try to remain agnostic.
However, it does make use of a few icons from the wonderful [Feather Icons](https://feathericons.com/) project.
-## SSR π€
+## Server rendering
+
+For synchronous SSR, call `loadTheme(selection)` on the server before
+rendering. Pass the result as `initialTheme` on the server and on the first
+client render. Serialize that result with your framework's ordinary
+serialization mechanism. The provider reuses the inline styles on hydration.
+For streaming SSR, the provider can resolve the initial selection through
+Suspense. Keep the themed content inside the same Suspense boundary as the
+provider.
+
+```tsx
+import { loadTheme, ThemeProvider } from '@precursor/theme';
+
+const selection = { colorMode: 'auto', typography: 'serif' } as const;
+const initialTheme = await loadTheme(selection);
+
+
+
+;
+```
-Under the hood, precursor uses [trousers π](https://github.com/danieldelcore/trousers) for styling. Trousers requires that you do some configuration to enable SSR. Please follow the guide there for more information: [Server side rendering with trousers](https://github.com/danieldelcore/trousers#server-side-rendering-ssr-)
+The inline styles contain the theme variables. Include the client bundle's
+component CSS in your HTML so each component has its layout styles before
+hydration. The inline CSS for auto color covers both light and dark.
## Folder structure π
-Precursor uses [yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces/) as the base of the monorepo. Each component can be found as it's own stand-alone package, allowing installation of a sub-set of the components you might need for your project.
+Precursor uses [yarn workspaces](https://yarnpkg.com/features/workspaces) as the base of the monorepo. Each component can be found as it's own stand-alone package, allowing installation of a sub-set of the components you might need for your project.
Components are categorized into several 'groups':
-- `packages/common`: Shared utilities
-- `packages/components`: Stand-alone components
-- `packages/elements`: Primitive components intended for use in new compositions
-- `packages/layout`: Primitives for arranging components together
-- `packages/theming`: Themes, tokens and other APIs indended for customization
+- `packages/common`: Shared utilities
+- `packages/components`: Stand-alone components
+- `packages/elements`: Primitive components intended for use in new compositions
+- `packages/layout`: Primitives for arranging components together
+- `packages/theming`: Themes, tokens and other APIs intended for customization
+
+## Development
+
+Use Node.js 24.15 or later in the 24.x line. The `.node-version` file selects
+Node 24 for version managers such as fnm. With fnm, run `fnm install` and
+`fnm use` from the repository root.
+
+```sh
+corepack enable
+yarn --version
+yarn install --immutable
+yarn start:stories
+```
+
+`yarn --version` should print `4.19.0`. If your shell still resolves a global
+Yarn 1 executable, run `corepack yarn start:stories` to use the pinned version
+directly.
+
+Use `yarn validate` for the build, types, lint,
+formatting, workspace checks, and tests. Run `yarn format` to fix formatting,
+`yarn start` to open the component palette in Storybook, or `yarn stories:build`
+to produce a static Storybook build.
## Inspired by β€οΈ
-- [Atlassian Design System](https://atlassian.design/)
-- [chakra-ui](https://chakra-ui.com/)
-- [zeit.co/design/](https://zeit.co/design/)
-- [Github Primer](https://primer.style/components)
-- [braid design system](https://seek-oss.github.io/braid-design-system)
-- [react-ui.dev](https://react-ui.dev)
-- [fannypack](https://v5.fannypack.style/)
+- [Atlassian Design System](https://atlassian.design/)
+- [chakra-ui](https://chakra-ui.com/)
+- [zeit.co/design/](https://zeit.co/design/)
+- [Github Primer](https://primer.style/components)
+- [braid design system](https://seek-oss.github.io/braid-design-system)
+- [react-ui.dev](https://react-ui.dev)
+- [fannypack](https://v5.fannypack.style/)
## Built with...
-- [trousers π](https://github.com/danieldelcore/trousers)
-- [changesets π¦](https://github.com/atlassian/changesets)
-- [manypkg βοΈ](https://github.com/Thinkmill/manypkg)
+- [trousers π](https://github.com/danieldelcore/trousers)
+- [changesets π¦](https://github.com/atlassian/changesets)
+- [manypkg βοΈ](https://github.com/Thinkmill/manypkg)
diff --git a/docs/theming-brief.md b/docs/theming-brief.md
new file mode 100644
index 0000000..99791d1
--- /dev/null
+++ b/docs/theming-brief.md
@@ -0,0 +1,61 @@
+# Precursor theming and primitives
+
+Make Precursor a theming and primitives library. Refactor the existing theming
+package in place. Adapt Grid, Stack, Inline, Text, and Heading, and add Divider
+and Bleed. Migrate the current component catalog to the new tokens through its
+existing packages and exports. Use logical axes for layout and let consumers
+choose a heading's semantic level independently of its visual size.
+
+## Design tokens
+
+Use Style Dictionary as the token compiler. Keep the source definitions in the
+tokens workspace and generate one CSS file per variant and a typed registry
+with separate variant loaders. Run generation first in the ordinary package
+build, before TypeScript and bundling. Storybook development, the static
+Storybook build, and release packaging all use that build. Published packages
+include the generated assets. ThemeProvider applies those assets at runtime.
+
+| Slot | Initial variants | Default |
+| ----------- | ---------------------------------- | ------------- |
+| Light color | Light palette | Light palette |
+| Dark color | Dark palette | Dark palette |
+| Spacing | Compact, comfortable, and spacious | Comfortable |
+| Shape | Rounded and sharp | Rounded |
+| Typography | Sans-serif, serif, and monospace | Sans-serif |
+
+Use a foundation-specific token path based on
+`[foundation].[category].[variant].[state]`. Represent defaulted segments
+with the literal `[default]` key and omit those segments from the CSS variable.
+For example, `color.brand.bold.[default]` emits `--color-brand-bold` and
+`color.brand.bold.hovered` emits `--color-brand-bold-hovered`. Fail generation
+on normalized-name collisions or variants that disagree on their slot's
+token contract.
+
+Use gap tokens such as `--spacing-gap-s` for margins and layout gaps.
+Use `--spacing-inline` for spacing between inline elements and inset tokens such
+as `--spacing-inset-s` for padding.
+`--spacing-inset-squish` combines a smaller block inset with a larger inline inset.
+
+## ThemeProvider
+
+Scope provider selections to their descendants. Keep one active variant per
+slot. Load new variants on demand and apply a whole selection once its styles
+are ready. Deduplicate concurrent loads and retain successfully mounted
+styles for reuse. The previous selection stays active on failure, and the
+request can be retried. Stale requests cannot replace a newer selection.
+
+The separate `colorMode` setting selects the light or dark color slot. Each slot can have multiple palette variants. Mode and palette selections can change independently.
+
+Inline initial styles during SSR and reuse the styles in the document head
+during hydration. For auto mode, include the selected palette for both color slots initially and
+let `prefers-color-scheme` choose which applies before JavaScript runs.
+Explicit light and dark selections stay fixed.
+
+## Acceptance
+
+Show all seven primitives together in Storybook with independent controls
+for each slot. Verify first paint, hydration, system color changes, async
+switching and retry, stylesheet reuse, and multiple provider scopes. Verify
+that packaged consumers receive the generated assets and that the browser
+loads other variants only when selected. Document the ThemeProvider migration
+and include release notes.
diff --git a/examples/0_Palette.tsx b/examples/Palette.stories.tsx
similarity index 80%
rename from examples/0_Palette.tsx
rename to examples/Palette.stories.tsx
index 5b847de..1a23e41 100644
--- a/examples/0_Palette.tsx
+++ b/examples/Palette.stories.tsx
@@ -1,8 +1,5 @@
-/* eslint-disable jsx-a11y/accessible-emoji */
-/** @jsx jsx */
-import { storiesOf } from '@storybook/react';
-import { useState } from 'react';
-import { jsx } from '@trousers/core';
+import type { Meta, StoryObj } from '@storybook/react-vite';
+import { Suspense, useId, useState } from 'react';
import Avatar from '@precursor/avatar';
import Blockquote from '@precursor/blockquote';
import Text from '@precursor/text';
@@ -10,6 +7,7 @@ import Button from '@precursor/button';
import Badge from '@precursor/badge';
import Lozenge from '@precursor/lozenge';
import Checkbox from '@precursor/checkbox';
+import Popup from '@precursor/popup';
import Code from '@precursor/code';
import Heading from '@precursor/heading';
import Input from '@precursor/input';
@@ -29,22 +27,186 @@ import Spinner from '@precursor/spinner';
import Skeleton from '@precursor/skeleton';
import Grid, { Column, Row } from '@precursor/grid';
import Inline from '@precursor/inline';
-import Toggle from '@precursor/Toggle';
+import Toggle from '@precursor/toggle';
import { Tabs, Tab, TabList, TabPanel } from '@precursor/tabs';
import List, { ListItem } from '@precursor/list';
-import { theme as baseTheme, Theme, ThemeProvider } from '@precursor/theme';
-import deepObject from 'object-deep-key';
-import { Box, Container, ThemeEditor, themeSchema } from '../fixtures';
+import {
+ defaultTheme,
+ themeVariants,
+ ThemeProvider,
+ useTheme,
+ type ThemeSelection,
+} from '@precursor/theme';
+import { gapSizes } from '@precursor/tokens';
+import Bleed from '@precursor/bleed';
+import Divider from '@precursor/divider';
+import { Box, Container } from '../fixtures';
+
+function ThemeSelect({
+ name,
+ label,
+ options,
+ value,
+ onChange,
+}: {
+ name: string;
+ label: string;
+ options: readonly Value[];
+ value: Value;
+ onChange: (value: Value) => void;
+}) {
+ const id = useId();
+
+ return (
+
+
+
+
+ );
+}
+
+function ThemeControls({
+ requested,
+ onChange,
+}: {
+ requested: ThemeSelection;
+ onChange: (selection: ThemeSelection) => void;
+}) {
+ const active = useTheme();
+ return (
+
+ Theme
+
+
+ onChange({ ...requested, colorMode })
+ }
+ />
+
+ onChange({
+ ...requested,
+ color: { ...requested.color, light },
+ })
+ }
+ />
+
+ onChange({
+ ...requested,
+ color: { ...requested.color, dark },
+ })
+ }
+ />
+ {(['spacing', 'shape', 'typography'] as const).map((slot) => (
+
+ onChange({ ...requested, [slot]: value })
+ }
+ />
+ ))}
+
+