@soroush.design/mcp 0.1.3 → 0.1.4-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.mjs +9 -9
- package/dist/index.cjs +9 -9
- package/dist/index.mjs +9 -9
- package/package.json +1 -1
package/dist/bin.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
// src/content.ts
|
|
6
6
|
const content = {
|
|
7
|
-
"version": "
|
|
7
|
+
"version": "3.0.0-alpha.0",
|
|
8
8
|
"components": [
|
|
9
9
|
{
|
|
10
10
|
"name": "ScrollArea",
|
|
@@ -1322,7 +1322,7 @@ const content = {
|
|
|
1322
1322
|
"id": "installation",
|
|
1323
1323
|
"title": "Installation",
|
|
1324
1324
|
"summary": "Install the packages and their peer dependencies.",
|
|
1325
|
-
"body": "# Installation\n\nInstall the design system and its peer dependencies:\n\n```sh\nnpm i @soroush.tech/design-system react react-dom\n```\n\n
|
|
1325
|
+
"body": "# Installation\n\n## Start a new app\n\nTo start a new app on the design system - a Vike app, prerendered at build time, that then moves\nbetween pages with no reload - in TypeScript or JavaScript:\n\n```sh\nnpx @soroush.design/cli create my-app\n```\n\nIt makes the app in a new folder, with the themes, the providers and a few pages, shows every file\nfirst, and installs it with the package manager you ran it with. Add `--sample-data`, or answer\nyes to its question, for two pages that show how data gets onto a page: a list of sample items,\nand a page for each. Its options are in the\n[command line](/cli/) docs. For an app you already have, use `init`, below.\n\n## Set it up with one command\n\nIn a client-rendered React app - built with Vite, webpack, Rspack, Parcel or Create React App,\nin TypeScript or JavaScript - one command sets the design system up:\n\n```sh\nnpx @soroush.design/cli init\n```\n\nIt shows every change before it makes one, and writes nothing until you say yes:\n\n- `src/theme/themes` - a `light` and a `dark` theme, each a `createTheme(baseTheme, {...})` call\n you make your own;\n- `src/theme/Providers` - the `ThemeProvider` with the base page styles;\n- your root - what it renders is wrapped in `<Providers>`;\n- the install of `@soroush.tech/design-system`, with your own package manager.\n\nIt runs in a git repository with no uncommitted change, never overwrites a file, and takes back\nevery change if a write fails. Run in a workspace's root, it sets up the one app in it. Add\n`--dry-run` to see the changes and exit. In PowerShell, quote the package name, since `@` starts a\nsplat there: `npx '@soroush.design/cli' init`.\n\nEvery option, and what `init` checks first, are in the [command line](/cli/) docs. Next.js, Vike\nand React Router apps are not supported by `init` yet: set those up by hand, below.\n\n## Or set it up by hand\n\nInstall the design system and its peer dependencies:\n\n```sh\nnpm i @soroush.tech/design-system react react-dom\n```\n\nReact 19.2 or later is required.\n\n### Set up the ThemeProvider\n\nEvery component reads its colors, spacing, and typography from the theme. Wrap your app once:\n\n```tsx\nimport { ThemeProvider, baseTheme, createTheme } from '@soroush.tech/design-system/theme'\n\nconst theme = createTheme(baseTheme, {\n // Your brand overrides - palettes, backgrounds, text colors, ...\n})\n\nexport function App() {\n return <ThemeProvider theme={theme}>{/* your app */}</ThemeProvider>\n}\n```\n\n`baseTheme` is a complete dark-schemed default, so an empty override object is a valid start.\nSee [Theming](/design-system/customization/theming/) for building light and dark brand themes.\n\n## Fonts\n\nThe theme's default stacks reference Space Grotesk (body) and JetBrains Mono (code). Self-host\nthem with Fontsource, or swap the `fonts` scale to your own faces:\n\n```sh\nnpm i @fontsource-variable/space-grotesk @fontsource-variable/jetbrains-mono\n```\n\n```ts\nimport '@fontsource-variable/space-grotesk/wght.css'\nimport '@fontsource-variable/jetbrains-mono/wght.css'\n```\n",
|
|
1326
1326
|
"url": "https://docs.soroush.tech/design-system/getting-started/installation/"
|
|
1327
1327
|
},
|
|
1328
1328
|
{
|
|
@@ -1336,21 +1336,21 @@ const content = {
|
|
|
1336
1336
|
"id": "theming",
|
|
1337
1337
|
"title": "Theming",
|
|
1338
1338
|
"summary": "The Theme type, the scales it carries, and how createTheme composes one.",
|
|
1339
|
-
"body": "# Theming\n\nThe theme belongs to you - the package ships defaults, every part is replaceable, and the type system widens with your extensions. This guide covers the full ladder, from using the built-ins to owning every token.\n\n## The ladder\n\n1. **Use the default** - `<ThemeProvider>` with no props renders the built-in `baseTheme` (dark-schemed).\n2. **Override values** - build your theme with `createTheme(base, overrides)` and pass it via `theme`.\n3. **Repoint component defaults** - `theme.defaults` / the provider's `defaults` prop change what components fall back to.\n4. **Extend the type system** - declaration merging adds palette colors, scale keys, and whole scales.\n5. **Customize single components** - `theme.components` (see [customization.md](./customization.md)).\n\n---\n\n## One theme, yours\n\n`ThemeProvider` provides exactly one theme. The package ships a single complete default - `baseTheme` - and you derive every mode from it; switching (dark/light, or ten brand modes) is your state:\n\n```tsx\nimport { ThemeProvider } from '@soroush.tech/design-system/theme'\nimport { baseTheme, createTheme } from '@soroush.tech/design-system/theme'\n\nconst dark = createTheme(baseTheme, { name: 'dark' /* your palettes */ })\nconst light = createTheme(baseTheme, { name: 'light', colorScheme: 'light' /* your palettes */ })\n\nconst [isDark, setIsDark] = useState(true)\n<ThemeProvider theme={isDark ? dark : light}>{app}</ThemeProvider>\n```\n\n## Building themes with `createTheme`\n\n`createTheme(base, overrides)` deep-merges sparse patches onto a base theme:\n\n```ts\nimport { baseTheme, createTheme } from '@soroush.tech/design-system/theme'\n\nexport const brandDark = createTheme(baseTheme, {\n palette: { primary: { main: '#00ff88' } }, // sibling fields (light/dark/contrastText) survive\n radii: { md: '10px' },\n shadows: ['none'], // arrays replace wholesale, never merge\n})\n```\n\nMerge rules: plain objects recurse; arrays (`shadows`, `fontSizes`) and functions replace wholesale; `undefined` values are ignored - keys are added or replaced, never removed. Neither argument is mutated.\n\n## Component defaults (`theme.defaults`)\n\nComponents carry visible literal fallbacks (`size = 'md'`, `variant = 'outside'`, ...) resolved through `themeDefault(theme, key, fallback)`. The optional `theme.defaults` map overrides any of them globally - essential when your theme uses entirely different size or palette keys:\n\n```tsx\n<ThemeProvider defaults={{ size: 'compact', color: 'brand', switchVariant: 'inside' }}>\n```\n\nThe full key table lives in the [README's Theming section](../README.md#component-defaults). The built-in `baseTheme` carries no `defaults` - the literals apply until you say otherwise. For _per-component_ defaults (only Buttons compact), use `theme.components.X.defaultProps` instead ([customization.md](./customization.md)).\n\n## Extending the type system\n\nEvery scale is an open interface owned by `@soroush.tech/design-system/theme` - that module (not Emotion, an internal implementation detail) is the augmentation surface, and it merges reliably across tsdown's chunked d.ts for every consumer:\n\n```ts\nimport type { PaletteEntry, SizeEntry } from '@soroush.tech/design-system/theme'\n\ndeclare module '@soroush.tech/design-system/theme' {\n interface ThemePalette {\n brand: PaletteEntry // new palette color\n }\n interface ThemeBackground {\n tertiary: string // new background token\n }\n interface ThemeSizes {\n xl: SizeEntry // new size step\n }\n interface Theme {\n elevations: Record<'low' | 'mid' | 'high', string> // whole new scale\n }\n}\n```\n\nComponent prop unions derive via `keyof Theme['scale']`, so `color=\"brand\"`, `bg=\"tertiary\"`, and `size=\"xl\"` typecheck everywhere automatically. Then supply the values:\n\n```ts\nconst brand = createTheme(baseTheme, {\n palette: { brand: { main: '#00ff88', light: '#66ffb2', dark: '#00b25f', contrastText: '#000' } },\n background: { tertiary: '#101418' },\n sizes: { xl: { paddingTop: 2, paddingBottom: 2, paddingLeft: 4, paddingRight: 4, fontSize: 2 } },\n elevations: { low: '0 1px 2px', mid: '0 2px 6px', high: '0 6px 18px' },\n defaults: { size: 'xl' }, // components may default to augmented keys\n})\n```\n\nTwo rules: new object-valued keys (like a `PaletteEntry`) must be supplied complete - components read `.main`/`.contrastText` at runtime; and TypeScript cannot verify at runtime that an augmented token was supplied - **always pair an augmentation with the matching override**.\n\n## Breakpoints and layout\n\n`theme.breakpoints` and `theme.layout` hold the page's layout system: where it changes, how many\ncolumns it has, its margins and gutters, its side panels and the top bar. Everything responsive is\nCSS - no component measures the window in JavaScript - so a prerendered page lays out the same\nwith JavaScript off. The design system ships these as tokens and building blocks (`AppBar`,\n`Sidebar`, `Drawer`, `Grid`, `Flex`); each app composes its own pages from them.\n\n### `theme.breakpoints` - window classes\n\nEach key is a range: its value is where the range starts, and it holds until the next key. The\ntheme writes the start because media queries are min-width. `xs` starts at 0, so it applies\neverywhere until `sm` overrides it.\n\n```ts\nbreakpoints: { xs: '0px', sm: '600px', md: '840px', lg: '1200px', xl: '1600px' }\n```\n\n| Key | Range | Material 3 window class |\n| ---- | ----------- | ----------------------- |\n| `xs` | 0-599px | compact |\n| `sm` | 600-839px | medium |\n| `md` | 840-1199px | expanded |\n| `lg` | 1200-1599px | large |\n| `xl` | 1600px+ | extra-large |\n\nThey are window classes, not devices: a class is about the space the window has. Responsive props\nuse them by name - each key from its size up - or by position:\n\n```tsx\n<View display={{ xs: 'none', md: 'block' }} />\n<View p={[2, 3, 4]} /> // xs, sm, md\n<View p={{ xs: 2, cqSm: 4 }} /> // cq keys: container queries on the same sizes\n```\n\nFor hand-written styles, `theme.breakpoints` carries the query helpers (also exported for\n`baseTheme` as `up`, `down`, `only`, `between`, `not` and `containerQueries`):\n\n```ts\nconst Panel = styled.div(({ theme }) => ({\n padding: 16,\n [theme.breakpoints.down('sm')]: { padding: 8 }, // @media (width < 600px)\n [theme.breakpoints.only('md')]: { padding: 24 }, // @media (840px <= width < 1200px)\n}))\n```\n\nEvery form, the container queries, the units and the order blocks are written in are covered in\nthe styled-system [Breakpoints](https://docs.soroush.tech/styled-system/docs/breakpoints/) guide.\n\n### `theme.layout` - layout tokens per window class\n\n`xs` is complete; each later class lists only what changes and is merged over the ones before it.\nWith `baseTheme`:\n\n| Class | Columns | Margin / gutter | Content | Start panel | End panel | Top bar |\n| ----- | ------- | --------------- | ---------- | ----------- | ----------- | ------- |\n| `xs` | 4 | 16 / 16 | fluid | hidden | hidden | 64 |\n| `sm` | 8 | 32 / 16 | fluid | rail 72 | hidden | 64 |\n| `md` | 12 | 24 / 24 | fluid | rail 72 | overlay 360 | 64 |\n| `lg` | 12 | 24 / 24 | fixed 1200 | rail 72 | overlay 412 | 64 |\n| `xl` | 12 | 24 / 24 | fixed 1600 | inline 280 | inline 412 | 64 |\n\n- **Units** - `margin` and `gutter` are `theme.space` keys, so they move with the spacing scale.\n Bar heights, panel widths and `maxWidth` take a space key or any CSS length.\n- **Columns** - 1 to 16. 12 is the default from `md` up.\n- **Panels** - `start` and `end` follow the writing direction (they swap in RTL). `mode` is\n `inline` (beside the content at `width`), `collapsed` (a rail at `railWidth`), `overlay` (over\n the content at `width`) or `hidden`. A panel first declared at a later class needs its `mode`,\n `width` and `railWidth` there.\n- **Bars** - `top` (and an optional `bottom`) heights; `0` removes an inherited bar.\n\nThese are tokens: the app places its own `AppBar`, `Sidebar` and `Drawer` with them, and the\ndesign studio draws them on its frames.\n\n### The `layout` prop - the page frame everywhere, the columns on a Grid\n\n`layout` turns the content tokens into CSS per window class. On any `View`-based component -\n`Flex` included - it is the **frame**: the margin and the max width, and the element keeps its\nown display. `Grid` adds the **columns** on top of that frame:\n\n```tsx\n<View layout>...</View> // the theme's frame\n<Flex layout gap={3}>...</Flex> // the frame, a flex column inside\n<Grid layout>...</Grid> // the frame and the theme's columns\n<Grid layout gap={2}>...</Grid> // its own gutter: 16px at every class\n<Grid layout gap={{ xs: 2, md: 4 }}>...</Grid> // 16px, then 32px from md up\n<Grid layout={{ lg: { columns: 16 } }}>...</Grid> // 16 columns from lg up\n<Grid layout={{ maxWidth: '1280px', md: { columns: 6 } }}>...</Grid> // both\n```\n\n- **The frame** - the full width of its parent (`width: 100%`, border-box) with the margin as\n `padding-inline`; in fixed mode capped by `max-width` and centred. It spans its parent in any\n context - a block, a grid item, a flex column or row - so the frame owns its width: size it\n with `maxWidth`, not `width`.\n- **Grid** - `grid-template-columns: repeat(N, minmax(0, 1fr))` and the gutter as `column-gap`.\n- **The gutter is the grid's `gap`** - its own `gap` or `columnGap` (`columnGap` wins), single,\n per class (`{ md: 4 }`) or as an array, sets `column-gap` at every class it covers; where it is\n not set, the theme's gutter applies. Rows take `gap`'s row half or `rowGap`. On a `Flex` or a\n `View`, `gap` is plain flexbox spacing.\n- **Children take `span`** - how many columns of a grid an element takes, on any `View`-based\n component: `span={6}`, per class `span={{ xs: 4, md: 6 }}`, or `span=\"full\"` for the whole row\n whatever the column count (`grid-column: 1 / -1`, in any grid).\n- A field in the value (`maxWidth: '1280px'`) replaces the theme's at every class; whatever it\n does not set still follows the theme. An entry under a class name replaces it **from that class\n up**, mobile-first like every responsive prop, on top of the fields.\n- **The layout owns the column tracks, inline padding and max width** it writes: an explicit\n `gridTemplateColumns`, padding or `maxWidth` on the same element does not override them from the\n second class up. A grid with tracks of its own leaves `layout` off and sits inside a frame.\n\n### Layout: one way per intent\n\nGenerated code, agents and people write each layout intent one way:\n\n| Intent | Write | Not |\n| ------------------------------------------------ | ----------------------------------------------------------- | --------------------------------------------------------- |\n| Content on the page frame, no columns | `<View layout>`, or `<Flex layout>` for a flex stack or row | `maxWidth` + `mx=\"auto\"` + `px`, a custom frame component |\n| A section on the theme's columns | `<Grid layout>` | hand-written tracks on a page section, `Flex` with widths |\n| The app's layout | `theme.layout`, built with `createTheme` | layout values written on every page |\n| A page's (or a region's) own layout | `<LayoutProvider layout={...}>` around the page | the same `layout` value on each section, a nested theme |\n| A section's own columns, margin or max width | `layout={{ md: { columns: 6 } }}`, `layout={{ maxWidth }}` | helpers that repeat a value per class |\n| A section's own gutter | `gap={2}` / `gap={{ xs: 2, md: 4 }}` on the `Grid` | a `gutter` field, `gap` and `columnGap` both |\n| A child taking N columns | `span={6}` / `span={{ xs: 4, md: 6 }}` | `gridColumn=\"span 6\"` |\n| A child taking the whole row | `span=\"full\"` | `grid-column: 1 / -1`, `style`, column-count objects |\n| Space between rows only | `rowGap` | margins on the children |\n| A grid with tracks of its own (`auto-fill`, ...) | a plain `Grid` without `layout`, inside a frame | `layout` plus `gridTemplateColumns` |\n\nThe same page without the prop needs every value written out - and stops following the theme:\n\n```tsx\n<Grid\n gridTemplateColumns={{\n xs: 'repeat(4, minmax(0, 1fr))',\n sm: 'repeat(8, minmax(0, 1fr))',\n md: 'repeat(12, minmax(0, 1fr))',\n }}\n columnGap={{ xs: 2, md: 3 }}\n px={{ xs: 2, sm: 4, md: 3 }}\n>\n ...\n</Grid>\n```\n\n### Your own breakpoints and layout\n\nOverride values with `createTheme`, like any scale:\n\n```ts\nconst theme = createTheme(baseTheme, {\n breakpoints: { md: '900px' },\n layout: { lg: { content: { maxWidth: '1280px' } } },\n})\n```\n\nThe helpers on `theme.breakpoints` are rebuilt from the merged sizes. `createTheme` merges, so\nit can change values and add a larger breakpoint after the existing ones, but not remove or rename\none. To use your own names, declare them by augmenting `BreakpointOverrides` (`true` adds a name,\n`false` removes a default) and replace the scale and the layout on the base:\n\n```ts\ndeclare module '@soroush.tech/design-system/theme' {\n interface BreakpointOverrides {\n mobile: true\n tablet: true\n web: true\n xs: false\n sm: false\n md: false\n lg: false\n xl: false\n }\n}\n\nconst theme = createTheme(\n {\n ...baseTheme,\n breakpoints: withBreakpointHelpers({ mobile: '0px', tablet: '768px', web: '1280px' }),\n layout: { mobile: { ...a complete entry... }, tablet: { ... }, web: { ... } },\n },\n {}\n)\n```\n\nResponsive props, `cq` keys (`cqTablet`), the helpers and the `layout` keys all follow the new\nnames.\n\n## The scale interfaces\n\n| Scale | Key in Theme | Interface |\n| --------------- | ---------------------- | ------------------------- |\n| Palette | `theme.palette` | `ThemePalette` |\n| Text colors | `theme.text` | `ThemeText` |\n| Backgrounds | `theme.background` | `ThemeBackground` |\n| Borders | `theme.border` | `ThemeBorder` |\n| Space | `theme.space` | `ThemeSpace` |\n| Breakpoints | `theme.breakpoints` | `ThemeBreakpoints` |\n| Layout | `theme.layout` | `ThemeLayout` |\n| Sizes | `theme.sizes` | `ThemeSizes` |\n| Radii | `theme.radii` | `ThemeRadii` |\n| Border widths | `theme.borderWidths` | `ThemeBorderWidths` |\n| Fonts | `theme.fonts` | `ThemeFonts` |\n| Font weights | `theme.fontWeights` | `ThemeFontWeights` |\n| Line heights | `theme.lineHeights` | `ThemeLineHeights` |\n| Letter spacings | `theme.letterSpacings` | `ThemeLetterSpacings` |\n| Typography | `theme.typography` | `ThemeTypographyVariants` |\n| Avatar sizes | `theme.avatar` | `ThemeAvatarSizes` |\n| Icon sizes | `theme.icon` | `ThemeIconSizes` |\n| Switch tokens | `theme.switch` | `ThemeSwitch` |\n| Shadow tokens | `theme.shadow` | `ThemeShadow` |\n\n## The spacing scale\n\n`theme.space` steps on an 8px unit, and every step is a whole pixel. The same steps serve padding,\nmargin, `gap` / `rowGap` / `columnGap`, the `layout` margin and the grid's gutter:\n\n| Step | `0` | `0.125` | `0.25` | `0.5` | `0.75` | `1` | `1.25` | `1.5` | `1.75` | `2` | `3` | `4` | `5` | `6` | `7` | `8` | `9` | `10` |\n| ---- | --- | ------- | ------ | ----- | ------ | --- | ------ | ----- | ------ | --- | --- | --- | --- | --- | --- | --- | --- | ---- |\n| px | 0 | 1 | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 24 | 32 | 40 | 48 | 56 | 64 | 72 | 80 |\n\nBelow 4px, lines are border widths (`theme.borderWidths`). Use `0.125` and `0.25` only for a gap\nthat should be a hairline - a 1px or 2px gap the background shows through, as in a grid of tiles\non a coloured `Grid`: `<Grid layout gap={0.125} bg=\"grid\">`.\n| Defaults | `theme.defaults` | `ThemeDefaults` |\n| Components | `theme.components` | `ThemeComponents` |\n\nThe contract is verified against the real published d.ts by `type-tests/augmentation.ts` (`pnpm test:types`), so it can't silently break in a release.\n",
|
|
1339
|
+
"body": "# Theming\n\nThe theme belongs to you - the package ships defaults, every part is replaceable, and the type system widens with your extensions. This guide covers the full ladder, from using the built-ins to owning every token.\n\n## The ladder\n\n1. **Use the default** - `<ThemeProvider>` with no props renders the built-in `baseTheme` (dark-schemed).\n2. **Override values** - build your theme with `createTheme(base, overrides)` and pass it via `theme`.\n3. **Repoint component defaults** - `theme.defaults` / the provider's `defaults` prop change what components fall back to.\n4. **Extend the type system** - declaration merging adds palette colors, scale keys, and whole scales.\n5. **Customize single components** - `theme.components` (see [customization.md](./customization.md)).\n\n---\n\n## One theme, yours\n\n`ThemeProvider` provides exactly one theme. The package ships a single complete default - `baseTheme` - and you derive every mode from it; switching (dark/light, or ten brand modes) is your state:\n\n```tsx\nimport { ThemeProvider } from '@soroush.tech/design-system/theme'\nimport { baseTheme, createTheme } from '@soroush.tech/design-system/theme'\n\nconst dark = createTheme(baseTheme, { name: 'dark' /* your palettes */ })\nconst light = createTheme(baseTheme, { name: 'light', colorScheme: 'light' /* your palettes */ })\n\nconst [isDark, setIsDark] = useState(true)\n<ThemeProvider theme={isDark ? dark : light}>{app}</ThemeProvider>\n```\n\n## Building themes with `createTheme`\n\n`createTheme(base, overrides)` deep-merges sparse patches onto a base theme:\n\n```ts\nimport { baseTheme, createTheme } from '@soroush.tech/design-system/theme'\n\nexport const brandDark = createTheme(baseTheme, {\n palette: { primary: { main: '#00ff88' } }, // sibling fields (light/dark/contrastText) survive\n radii: { md: '10px' },\n shadows: ['none'], // arrays replace wholesale, never merge\n})\n```\n\nMerge rules: plain objects recurse; arrays (`shadows`, `fontSizes`) and functions replace wholesale; `undefined` values are ignored - keys are added or replaced, never removed. Neither argument is mutated.\n\n## Component defaults (`theme.defaults`)\n\nComponents carry visible literal fallbacks (`size = 'md'`, `variant = 'outside'`, ...) resolved through `themeDefault(theme, key, fallback)`. The optional `theme.defaults` map overrides any of them globally - essential when your theme uses entirely different size or palette keys:\n\n```tsx\n<ThemeProvider defaults={{ size: 'compact', color: 'brand', switchVariant: 'inside' }}>\n```\n\nThe full key table lives in the [README's Theming section](../README.md#component-defaults). The built-in `baseTheme` carries no `defaults` - the literals apply until you say otherwise. For _per-component_ defaults (only Buttons compact), use `theme.components.X.defaultProps` instead ([customization.md](./customization.md)).\n\n## Extending the type system\n\nEvery scale is an open interface owned by `@soroush.tech/design-system/theme` - that module (not the styling engine, an internal implementation detail) is the augmentation surface, and it merges reliably across tsdown's chunked d.ts for every consumer:\n\n```ts\nimport type { PaletteEntry, SizeEntry } from '@soroush.tech/design-system/theme'\n\ndeclare module '@soroush.tech/design-system/theme' {\n interface ThemePalette {\n brand: PaletteEntry // new palette color\n }\n interface ThemeBackground {\n tertiary: string // new background token\n }\n interface ThemeSizes {\n xl: SizeEntry // new size step\n }\n interface Theme {\n elevations: Record<'low' | 'mid' | 'high', string> // whole new scale\n }\n}\n```\n\nComponent prop unions derive via `keyof Theme['scale']`, so `color=\"brand\"`, `bg=\"tertiary\"`, and `size=\"xl\"` typecheck everywhere automatically. Then supply the values:\n\n```ts\nconst brand = createTheme(baseTheme, {\n palette: { brand: { main: '#00ff88', light: '#66ffb2', dark: '#00b25f', contrastText: '#000' } },\n background: { tertiary: '#101418' },\n sizes: { xl: { paddingTop: 2, paddingBottom: 2, paddingLeft: 4, paddingRight: 4, fontSize: 2 } },\n elevations: { low: '0 1px 2px', mid: '0 2px 6px', high: '0 6px 18px' },\n defaults: { size: 'xl' }, // components may default to augmented keys\n})\n```\n\nTwo rules: new object-valued keys (like a `PaletteEntry`) must be supplied complete - components read `.main`/`.contrastText` at runtime; and TypeScript cannot verify at runtime that an augmented token was supplied - **always pair an augmentation with the matching override**.\n\n## Breakpoints and layout\n\n`theme.breakpoints` and `theme.layout` hold the page's layout system: where it changes, how many\ncolumns it has, its margins and gutters, its side panels and the top bar. Everything responsive is\nCSS - no component measures the window in JavaScript - so a prerendered page lays out the same\nwith JavaScript off. The design system ships these as tokens and building blocks (`AppBar`,\n`Sidebar`, `Drawer`, `Grid`, `Flex`); each app composes its own pages from them.\n\n### `theme.breakpoints` - window classes\n\nEach key is a range: its value is where the range starts, and it holds until the next key. The\ntheme writes the start because media queries are min-width. `xs` starts at 0, so it applies\neverywhere until `sm` overrides it.\n\n```ts\nbreakpoints: { xs: '0px', sm: '600px', md: '840px', lg: '1200px', xl: '1600px' }\n```\n\n| Key | Range | Material 3 window class |\n| ---- | ----------- | ----------------------- |\n| `xs` | 0-599px | compact |\n| `sm` | 600-839px | medium |\n| `md` | 840-1199px | expanded |\n| `lg` | 1200-1599px | large |\n| `xl` | 1600px+ | extra-large |\n\nThey are window classes, not devices: a class is about the space the window has. Responsive props\nuse them by name - each key from its size up - or by position:\n\n```tsx\n<View display={{ xs: 'none', md: 'block' }} />\n<View p={[2, 3, 4]} /> // xs, sm, md\n<View p={{ xs: 2, cqSm: 4 }} /> // cq keys: container queries on the same sizes\n```\n\nFor hand-written styles, `theme.breakpoints` carries the query helpers (also exported for\n`baseTheme` as `up`, `down`, `only`, `between`, `not` and `containerQueries`):\n\n```ts\nconst Panel = styled.div(({ theme }) => ({\n padding: 16,\n [theme.breakpoints.down('sm')]: { padding: 8 }, // @media (width < 600px)\n [theme.breakpoints.only('md')]: { padding: 24 }, // @media (840px <= width < 1200px)\n}))\n```\n\nEvery form, the container queries, the units and the order blocks are written in are covered in\nthe styled-system [Breakpoints](https://docs.soroush.tech/styled-system/docs/breakpoints/) guide.\n\n### `theme.layout` - layout tokens per window class\n\n`xs` is complete; each later class lists only what changes and is merged over the ones before it.\nWith `baseTheme`:\n\n| Class | Columns | Margin / gutter | Content | Start panel | End panel | Top bar |\n| ----- | ------- | --------------- | ---------- | ----------- | ----------- | ------- |\n| `xs` | 4 | 16 / 16 | fluid | hidden | hidden | 64 |\n| `sm` | 8 | 32 / 16 | fluid | rail 72 | hidden | 64 |\n| `md` | 12 | 24 / 24 | fluid | rail 72 | overlay 360 | 64 |\n| `lg` | 12 | 24 / 24 | fixed 1200 | rail 72 | overlay 412 | 64 |\n| `xl` | 12 | 24 / 24 | fixed 1600 | inline 280 | inline 412 | 64 |\n\n- **Units** - `margin` and `gutter` are `theme.space` keys, so they move with the spacing scale.\n Bar heights, panel widths and `maxWidth` take a space key or any CSS length.\n- **Columns** - 1 to 16. 12 is the default from `md` up.\n- **Panels** - `start` and `end` follow the writing direction (they swap in RTL). `mode` is\n `inline` (beside the content at `width`), `collapsed` (a rail at `railWidth`), `overlay` (over\n the content at `width`) or `hidden`. A panel first declared at a later class needs its `mode`,\n `width` and `railWidth` there.\n- **Bars** - `top` (and an optional `bottom`) heights; `0` removes an inherited bar.\n\nThese are tokens: the app places its own `AppBar`, `Sidebar` and `Drawer` with them, and the\ndesign studio draws them on its frames.\n\n### The `layout` prop - the page frame everywhere, the columns on a Grid\n\n`layout` turns the content tokens into CSS per window class. On any `View`-based component -\n`Flex` included - it is the **frame**: the margin and the max width, and the element keeps its\nown display. `Grid` adds the **columns** on top of that frame:\n\n```tsx\n<View layout>...</View> // the theme's frame\n<Flex layout gap={3}>...</Flex> // the frame, a flex column inside\n<Grid layout>...</Grid> // the frame and the theme's columns\n<Grid layout gap={2}>...</Grid> // its own gutter: 16px at every class\n<Grid layout gap={{ xs: 2, md: 4 }}>...</Grid> // 16px, then 32px from md up\n<Grid layout={{ lg: { columns: 16 } }}>...</Grid> // 16 columns from lg up\n<Grid layout={{ maxWidth: '1280px', md: { columns: 6 } }}>...</Grid> // both\n```\n\n- **The frame** - the full width of its parent (`width: 100%`, border-box) with the margin as\n `padding-inline`; in fixed mode capped by `max-width` and centred. It spans its parent in any\n context - a block, a grid item, a flex column or row - so the frame owns its width: size it\n with `maxWidth`, not `width`.\n- **Grid** - `grid-template-columns: repeat(N, minmax(0, 1fr))` and the gutter as `column-gap`.\n- **The gutter is the grid's `gap`** - its own `gap` or `columnGap` (`columnGap` wins), single,\n per class (`{ md: 4 }`) or as an array, sets `column-gap` at every class it covers; where it is\n not set, the theme's gutter applies. Rows take `gap`'s row half or `rowGap`. On a `Flex` or a\n `View`, `gap` is plain flexbox spacing.\n- **Children take `span`** - how many columns of a grid an element takes, on any `View`-based\n component: `span={6}`, per class `span={{ xs: 4, md: 6 }}`, or `span=\"full\"` for the whole row\n whatever the column count (`grid-column: 1 / -1`, in any grid).\n- A field in the value (`maxWidth: '1280px'`) replaces the theme's at every class; whatever it\n does not set still follows the theme. An entry under a class name replaces it **from that class\n up**, mobile-first like every responsive prop, on top of the fields.\n- **The layout owns the column tracks, inline padding and max width** it writes: an explicit\n `gridTemplateColumns`, padding or `maxWidth` on the same element does not override them from the\n second class up. A grid with tracks of its own leaves `layout` off and sits inside a frame.\n\n### Layout: one way per intent\n\nGenerated code, agents and people write each layout intent one way:\n\n| Intent | Write | Not |\n| ------------------------------------------------ | ----------------------------------------------------------- | --------------------------------------------------------- |\n| Content on the page frame, no columns | `<View layout>`, or `<Flex layout>` for a flex stack or row | `maxWidth` + `mx=\"auto\"` + `px`, a custom frame component |\n| A section on the theme's columns | `<Grid layout>` | hand-written tracks on a page section, `Flex` with widths |\n| The app's layout | `theme.layout`, built with `createTheme` | layout values written on every page |\n| A page's (or a region's) own layout | `<LayoutProvider layout={...}>` around the page | the same `layout` value on each section, a nested theme |\n| A section's own columns, margin or max width | `layout={{ md: { columns: 6 } }}`, `layout={{ maxWidth }}` | helpers that repeat a value per class |\n| A section's own gutter | `gap={2}` / `gap={{ xs: 2, md: 4 }}` on the `Grid` | a `gutter` field, `gap` and `columnGap` both |\n| A child taking N columns | `span={6}` / `span={{ xs: 4, md: 6 }}` | `gridColumn=\"span 6\"` |\n| A child taking the whole row | `span=\"full\"` | `grid-column: 1 / -1`, `style`, column-count objects |\n| Space between rows only | `rowGap` | margins on the children |\n| A grid with tracks of its own (`auto-fill`, ...) | a plain `Grid` without `layout`, inside a frame | `layout` plus `gridTemplateColumns` |\n\nThe same page without the prop needs every value written out - and stops following the theme:\n\n```tsx\n<Grid\n gridTemplateColumns={{\n xs: 'repeat(4, minmax(0, 1fr))',\n sm: 'repeat(8, minmax(0, 1fr))',\n md: 'repeat(12, minmax(0, 1fr))',\n }}\n columnGap={{ xs: 2, md: 3 }}\n px={{ xs: 2, sm: 4, md: 3 }}\n>\n ...\n</Grid>\n```\n\n### Your own breakpoints and layout\n\nOverride values with `createTheme`, like any scale:\n\n```ts\nconst theme = createTheme(baseTheme, {\n breakpoints: { md: '900px' },\n layout: { lg: { content: { maxWidth: '1280px' } } },\n})\n```\n\nThe helpers on `theme.breakpoints` are rebuilt from the merged sizes. `createTheme` merges, so\nit can change values and add a larger breakpoint after the existing ones, but not remove or rename\none. To use your own names, declare them by augmenting `BreakpointOverrides` (`true` adds a name,\n`false` removes a default) and replace the scale and the layout on the base:\n\n```ts\ndeclare module '@soroush.tech/design-system/theme' {\n interface BreakpointOverrides {\n mobile: true\n tablet: true\n web: true\n xs: false\n sm: false\n md: false\n lg: false\n xl: false\n }\n}\n\nconst theme = createTheme(\n {\n ...baseTheme,\n breakpoints: withBreakpointHelpers({ mobile: '0px', tablet: '768px', web: '1280px' }),\n layout: { mobile: { ...a complete entry... }, tablet: { ... }, web: { ... } },\n },\n {}\n)\n```\n\nResponsive props, `cq` keys (`cqTablet`), the helpers and the `layout` keys all follow the new\nnames.\n\n## The scale interfaces\n\n| Scale | Key in Theme | Interface |\n| --------------- | ---------------------- | ------------------------- |\n| Palette | `theme.palette` | `ThemePalette` |\n| Text colors | `theme.text` | `ThemeText` |\n| Backgrounds | `theme.background` | `ThemeBackground` |\n| Borders | `theme.border` | `ThemeBorder` |\n| Space | `theme.space` | `ThemeSpace` |\n| Breakpoints | `theme.breakpoints` | `ThemeBreakpoints` |\n| Layout | `theme.layout` | `ThemeLayout` |\n| Sizes | `theme.sizes` | `ThemeSizes` |\n| Radii | `theme.radii` | `ThemeRadii` |\n| Border widths | `theme.borderWidths` | `ThemeBorderWidths` |\n| Fonts | `theme.fonts` | `ThemeFonts` |\n| Font weights | `theme.fontWeights` | `ThemeFontWeights` |\n| Line heights | `theme.lineHeights` | `ThemeLineHeights` |\n| Letter spacings | `theme.letterSpacings` | `ThemeLetterSpacings` |\n| Typography | `theme.typography` | `ThemeTypographyVariants` |\n| Avatar sizes | `theme.avatar` | `ThemeAvatarSizes` |\n| Icon sizes | `theme.icon` | `ThemeIconSizes` |\n| Switch tokens | `theme.switch` | `ThemeSwitch` |\n| Shadow tokens | `theme.shadow` | `ThemeShadow` |\n\n## The spacing scale\n\n`theme.space` steps on an 8px unit, and every step is a whole pixel. The same steps serve padding,\nmargin, `gap` / `rowGap` / `columnGap`, the `layout` margin and the grid's gutter:\n\n| Step | `0` | `0.125` | `0.25` | `0.5` | `0.75` | `1` | `1.25` | `1.5` | `1.75` | `2` | `3` | `4` | `5` | `6` | `7` | `8` | `9` | `10` |\n| ---- | --- | ------- | ------ | ----- | ------ | --- | ------ | ----- | ------ | --- | --- | --- | --- | --- | --- | --- | --- | ---- |\n| px | 0 | 1 | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 24 | 32 | 40 | 48 | 56 | 64 | 72 | 80 |\n\nBelow 4px, lines are border widths (`theme.borderWidths`). Use `0.125` and `0.25` only for a gap\nthat should be a hairline - a 1px or 2px gap the background shows through, as in a grid of tiles\non a coloured `Grid`: `<Grid layout gap={0.125} bg=\"grid\">`.\n| Defaults | `theme.defaults` | `ThemeDefaults` |\n| Components | `theme.components` | `ThemeComponents` |\n\nThe contract is verified against the real published d.ts by `type-tests/augmentation.ts` (`pnpm test:types`), so it can't silently break in a release.\n",
|
|
1340
1340
|
"url": "https://docs.soroush.tech/design-system/customization/theming/"
|
|
1341
1341
|
},
|
|
1342
1342
|
{
|
|
1343
1343
|
"id": "customization",
|
|
1344
1344
|
"title": "How to customize",
|
|
1345
1345
|
"summary": "Override component styles through theme.components and style props.",
|
|
1346
|
-
"body": "# Per-component customization (`theme.components`)\n\nCustomize one component for the whole app - default prop values, per-slot CSS, and new variant values - without wrapping or forking. Zero-config themes pay nothing: the resolver bails out on its first check when `theme.components` is absent.\n\n```ts\nconst brand = createTheme(baseTheme, {\n components: {\n Button: {\n defaultProps: { size: 'sm', shape: 'rounded' },\n styleOverrides: {\n root: ({ theme, ownerState }) => ({\n letterSpacing: theme.letterSpacings.wide,\n ...(ownerState.variant === 'contained' && { textTransform: 'none' }),\n }),\n label: { fontStyle: 'italic' },\n },\n variants: [\n {\n props: { variant: 'dashed' },\n style: ({ theme }) => ({\n backgroundColor: 'transparent',\n border: `${theme.borderWidths.thin} dashed ${theme.border.primary}`,\n }),\n },\n ],\n },\n },\n})\n```\n\nThe `Theme/Customization` Storybook story renders all three mechanisms under a customized theme and is locked by Chromatic - it is the living contract.\n\nEvery styled element is registered - the `ThemeComponents` interface in `src/theme/themes.ts` is the authoritative key/slot list, so `styleOverrides` reaches every root and every sub-element slot (Switch's `track`/`thumb`/`input`, Select's `listbox`, LinearProgress's bars, ...), including the layout primitives `View`/`Flex`/`Grid`. Two cautions: an override on `View`/`Flex`/`Grid` cascades into the internals of every composed component (use those keys for app-wide policy only), and hidden/structural slots (`input`, `valueGhost`, `positioner`) carry accessibility or layout behavior - restyle their looks, not their geometry/visibility. Note that `defaultProps` is honored only by components that resolve props through `useDefaultProps` (currently `Breadcrumbs`, `Button`, `Card`, `Pressable`, `Rating`, `NumberInput`, `RangeInput`, `TransferList`, `Collapse`, `FabMenu`, `ScrollArea`, `Autocomplete`, `Tooltip`, `Snackbar`, `Fab`, `Alert`, `Badge`, `Chip`, `Accordion`, `AccordionSummary`, `AccordionGroup`, `Tabs`, `Tab`, `TabScrollButton`, `TabPanel`, `Menu`, `ContextMenu`, `MenuList` and `MenuItem`); everywhere else, use `styleOverrides`/`variants`.\n\n---\n\n## `defaultProps`\n\nPer-component default prop values. They sit in the standard resolution chain - later steps only apply when earlier ones are unset:\n\n```\nexplicit prop → group context (e.g. ButtonGroup) → theme.components.X.defaultProps → theme.defaults.* → literal fallback\n```\n\nUse `theme.defaults` for global policy (\"everything compact\") and `defaultProps` for component policy (\"only Buttons compact\"). Components read them via the `useDefaultProps(name)` hook.\n\n## `styleOverrides`\n\nPer-slot CSS merged **after** the component's own styles - the theme wins the cascade - but **before** the styled-system prop parsers, so per-instance props (`m`, `p`, `width`, ...) always beat the theme.\n\nValues are plain CSS objects or callbacks receiving `{ theme, ownerState }`. `ownerState` is the styled root's **resolved** props - after group context, `defaultProps`, and `theme.defaults` have been applied - so a conditional like `ownerState.variant === 'contained'` sees the same value the component's own styles used. Prop-keyed conditionals belong in the callback; there are no magic override keys to memorize.\n\nSlot names (`root`, `label`, `icon`, ...) are typed per component in `ThemeComponents` and are **public API** - renaming one is a breaking change.\n\n## `variants`\n\nExtra variant entries matched by props: an entry applies when every key in its `props` equals the render prop. Matching runs on the component's root slot only. Note that `createTheme` replaces `variants` arrays wholesale - composing two override sets does not concatenate them.\n\n**New variant values** need two things - the type registration and the styles:\n\n```ts\ndeclare module '@soroush.tech/design-system/theme' {\n interface ButtonVariants {\n dashed: true // widens ButtonVariant so variant=\"dashed\" typechecks\n }\n}\n```\n\nRegistering the value without a matching `variants` entry renders an unstyled button - always pair them.\n\n## Slot props - customizing composed sub-elements\n\nSome slots aren't raw CSS surfaces but composed components with their own token props - Card's title is a `Typography` with `variant`/`color`/`fontFamily`. CSS overrides are the wrong tool for \"make every card title a subtitle instead of an overline\"; that's a **prop** change. Such components accept slot prop objects in `defaultProps`, merged under any per-instance props:\n\n```ts\ncomponents: {\n Card: {\n defaultProps: {\n titleProps: { variant: 'subtitle1', color: 'secondary', fontFamily: 'body' },\n captionProps: { mb: 2 },\n },\n // ...and the same slots are still CSS-addressable:\n styleOverrides: {\n title: { letterSpacing: '0.1em' },\n },\n },\n}\n```\n\nResolution per slot prop: component literal → theme `defaultProps.titleProps` → per-instance `titleProps` (instance wins). The slot-prop shapes are token-typed (`CardSlotTypographyProps`), so `variant`/`color`/`mb` autocomplete against your theme scales - including augmented keys.\n\nSo a composed slot is customizable at three levels: **props** (`defaultProps.titleProps`), **CSS** (`styleOverrides.title`), and **structure** (Card's `title` prop accepts a ReactNode for full replacement).\n\n## Registering your own components\n\nThe mechanism is infrastructure, not just configuration. Create your roots with this package's `styled` and register the name:\n\n```ts\nimport { styled } from '@soroush.tech/design-system'\nimport type { ComponentConfig } from '@soroush.tech/design-system/theme'\n\ndeclare module '@soroush.tech/design-system/theme' {\n interface ThemeComponents {\n MyWidget?: ComponentConfig<{ tone?: 'calm' | 'loud' }, 'root' | 'handle'>\n }\n}\n\nconst WidgetRoot = styled('div', { name: 'MyWidget' })({ padding: 8 })\nconst WidgetHandle = styled('span', { name: 'MyWidget', slot: 'handle' })({ cursor: 'grab' })\n```\n\nYour widget now honors `theme.components.MyWidget.styleOverrides` / `.variants` exactly like the built-ins.\n\n## Converting a design-system component (maintainers)\n\n`Button` is the reference implementation. The rules:\n\n1. Pass `name` on the root and `slot` on named sub-elements. Slot names become public API.\n2. Move styled-system parsers (`space`, `layout`, ...) from the style arguments into the `systemProps` option - this is what keeps instance props beating theme overrides.\n3. Resolve `defaultProps` via `useDefaultProps(name)` in the wrapper, in the chain above.\n4. Type the component's `ThemeComponents` entry (`ComponentConfig<OwnerState, Slots>`); if it has variants, expose them via an augmentable interface (see `ButtonVariants`).\n5. Cover all three mechanisms plus the precedence pairs in the component's tests.\n\n## Runtime cost\n\n- **Unused** (`theme.components` absent): one no-op function call and a property lookup per named root per render; anonymous roots are
|
|
1346
|
+
"body": "# Per-component customization (`theme.components`)\n\nCustomize one component for the whole app - default prop values, per-slot CSS, and new variant values - without wrapping or forking. Zero-config themes pay nothing: the resolver bails out on its first check when `theme.components` is absent.\n\n```ts\nconst brand = createTheme(baseTheme, {\n components: {\n Button: {\n defaultProps: { size: 'sm', shape: 'rounded' },\n styleOverrides: {\n root: ({ theme, ownerState }) => ({\n letterSpacing: theme.letterSpacings.wide,\n ...(ownerState.variant === 'contained' && { textTransform: 'none' }),\n }),\n label: { fontStyle: 'italic' },\n },\n variants: [\n {\n props: { variant: 'dashed' },\n style: ({ theme }) => ({\n backgroundColor: 'transparent',\n border: `${theme.borderWidths.thin} dashed ${theme.border.primary}`,\n }),\n },\n ],\n },\n },\n})\n```\n\nThe `Theme/Customization` Storybook story renders all three mechanisms under a customized theme and is locked by Chromatic - it is the living contract.\n\nEvery styled element is registered - the `ThemeComponents` interface in `src/theme/themes.ts` is the authoritative key/slot list, so `styleOverrides` reaches every root and every sub-element slot (Switch's `track`/`thumb`/`input`, Select's `listbox`, LinearProgress's bars, ...), including the layout primitives `View`/`Flex`/`Grid`. Two cautions: an override on `View`/`Flex`/`Grid` cascades into the internals of every composed component (use those keys for app-wide policy only), and hidden/structural slots (`input`, `valueGhost`, `positioner`) carry accessibility or layout behavior - restyle their looks, not their geometry/visibility. Note that `defaultProps` is honored only by components that resolve props through `useDefaultProps` (currently `Breadcrumbs`, `Button`, `Card`, `Pressable`, `Rating`, `NumberInput`, `RangeInput`, `TransferList`, `Collapse`, `FabMenu`, `ScrollArea`, `Autocomplete`, `Tooltip`, `Snackbar`, `Fab`, `Alert`, `Badge`, `Chip`, `Accordion`, `AccordionSummary`, `AccordionGroup`, `Tabs`, `Tab`, `TabScrollButton`, `TabPanel`, `Menu`, `ContextMenu`, `MenuList` and `MenuItem`); everywhere else, use `styleOverrides`/`variants`.\n\n---\n\n## `defaultProps`\n\nPer-component default prop values. They sit in the standard resolution chain - later steps only apply when earlier ones are unset:\n\n```\nexplicit prop → group context (e.g. ButtonGroup) → theme.components.X.defaultProps → theme.defaults.* → literal fallback\n```\n\nUse `theme.defaults` for global policy (\"everything compact\") and `defaultProps` for component policy (\"only Buttons compact\"). Components read them via the `useDefaultProps(name)` hook.\n\n## `styleOverrides`\n\nPer-slot CSS merged **after** the component's own styles - the theme wins the cascade - but **before** the styled-system prop parsers, so per-instance props (`m`, `p`, `width`, ...) always beat the theme.\n\nValues are plain CSS objects or callbacks receiving `{ theme, ownerState }`. `ownerState` is the styled root's **resolved** props - after group context, `defaultProps`, and `theme.defaults` have been applied - so a conditional like `ownerState.variant === 'contained'` sees the same value the component's own styles used. Prop-keyed conditionals belong in the callback; there are no magic override keys to memorize.\n\nSlot names (`root`, `label`, `icon`, ...) are typed per component in `ThemeComponents` and are **public API** - renaming one is a breaking change.\n\n## `variants`\n\nExtra variant entries matched by props: an entry applies when every key in its `props` equals the render prop. Matching runs on the component's root slot only. Note that `createTheme` replaces `variants` arrays wholesale - composing two override sets does not concatenate them.\n\n**New variant values** need two things - the type registration and the styles:\n\n```ts\ndeclare module '@soroush.tech/design-system/theme' {\n interface ButtonVariants {\n dashed: true // widens ButtonVariant so variant=\"dashed\" typechecks\n }\n}\n```\n\nRegistering the value without a matching `variants` entry renders an unstyled button - always pair them.\n\n## Slot props - customizing composed sub-elements\n\nSome slots aren't raw CSS surfaces but composed components with their own token props - Card's title is a `Typography` with `variant`/`color`/`fontFamily`. CSS overrides are the wrong tool for \"make every card title a subtitle instead of an overline\"; that's a **prop** change. Such components accept slot prop objects in `defaultProps`, merged under any per-instance props:\n\n```ts\ncomponents: {\n Card: {\n defaultProps: {\n titleProps: { variant: 'subtitle1', color: 'secondary', fontFamily: 'body' },\n captionProps: { mb: 2 },\n },\n // ...and the same slots are still CSS-addressable:\n styleOverrides: {\n title: { letterSpacing: '0.1em' },\n },\n },\n}\n```\n\nResolution per slot prop: component literal → theme `defaultProps.titleProps` → per-instance `titleProps` (instance wins). The slot-prop shapes are token-typed (`CardSlotTypographyProps`), so `variant`/`color`/`mb` autocomplete against your theme scales - including augmented keys.\n\nSo a composed slot is customizable at three levels: **props** (`defaultProps.titleProps`), **CSS** (`styleOverrides.title`), and **structure** (Card's `title` prop accepts a ReactNode for full replacement).\n\n## Registering your own components\n\nThe mechanism is infrastructure, not just configuration. Create your roots with this package's `styled` and register the name:\n\n```ts\nimport { styled } from '@soroush.tech/design-system'\nimport type { ComponentConfig } from '@soroush.tech/design-system/theme'\n\ndeclare module '@soroush.tech/design-system/theme' {\n interface ThemeComponents {\n MyWidget?: ComponentConfig<{ tone?: 'calm' | 'loud' }, 'root' | 'handle'>\n }\n}\n\nconst WidgetRoot = styled('div', { name: 'MyWidget' })({ padding: 8 })\nconst WidgetHandle = styled('span', { name: 'MyWidget', slot: 'handle' })({ cursor: 'grab' })\n```\n\nYour widget now honors `theme.components.MyWidget.styleOverrides` / `.variants` exactly like the built-ins.\n\n## Converting a design-system component (maintainers)\n\n`Button` is the reference implementation. The rules:\n\n1. Pass `name` on the root and `slot` on named sub-elements. Slot names become public API.\n2. Move styled-system parsers (`space`, `layout`, ...) from the style arguments into the `systemProps` option - this is what keeps instance props beating theme overrides.\n3. Resolve `defaultProps` via `useDefaultProps(name)` in the wrapper, in the chain above.\n4. Type the component's `ThemeComponents` entry (`ComponentConfig<OwnerState, Slots>`); if it has variants, expose them via an augmentable interface (see `ButtonVariants`).\n5. Cover all three mechanisms plus the precedence pairs in the component's tests.\n\n## Runtime cost\n\n- **Unused** (`theme.components` absent): one no-op function call and a property lookup per named root per render; anonymous roots are plain `styled` roots. Bundle cost of the wrapper: well under a kilobyte.\n- **Used**: each overridden component behaves as if it shipped one more style function - the same cost class as its existing `sizeVariants`/`colorStyle` functions. The engine names a class by a hash of its compiled rules, so the same style always gives the same class.\n",
|
|
1347
1347
|
"url": "https://docs.soroush.tech/design-system/customization/how-to/"
|
|
1348
1348
|
},
|
|
1349
1349
|
{
|
|
1350
1350
|
"id": "setup",
|
|
1351
1351
|
"title": "New app setup",
|
|
1352
1352
|
"summary": "End-to-end checklist for a new app: fonts, global reset, providers, theme.",
|
|
1353
|
-
"body": "# New-app checklist\n\nReference wiring: a Next.js App Router app on React 19.\n\n## 1. Install\n\n```jsonc\n// package.json\n\"dependencies\": {\n \"@soroush.tech/design-system\": \"^
|
|
1353
|
+
"body": "# New-app checklist\n\nReference wiring: a Next.js App Router app on React 19.\n\n## 1. Install\n\n```jsonc\n// package.json\n\"dependencies\": {\n \"@soroush.tech/design-system\": \"^3.0.0\",\n \"react\": \"^19.2.8\",\n \"react-dom\": \"^19.2.8\"\n}\n```\n\nThe styling engine (UmberStyle, the `@umber-style/*` packages) comes in as a dependency\nof the design system - don't add it directly. The registry in `providers.tsx` takes\n`createCache` from `@soroush.tech/design-system/engine`. React 19.2 or later is required.\n\n## 2. Theme\n\nCopy `theme.ts` to the app root so it imports as `@/theme`.\nIt exports `light` and `dark`. The color ramps at the top (`carbonBlack`,\n`cyberCyan`, `kineticGreen`, `forestGreen`, `solarAmber`, `neonRed`, `softGreen`,\n`deepCrimson`, `lightSurface`, `kineticSurface`, `blackAlpha`) are the brand: every\napp that copies them shares one color set. Change which ramp fills a palette slot if\nthe app needs to, never the ramp values.\n\n## 3. Provider\n\nCopy `providers.tsx` to `app/providers.tsx`. Two things it does:\n\n- **Style registry** - collects the styles written during the server render and\n re-injects them via `useServerInsertedHTML`, so server markup arrives styled.\n Without it you get an unstyled flash on every hard navigation.\n- **Global reset** - `border-box` everywhere, zero body margin,\n `background.primary` / `text.initial` / `fonts.body` on `<body>`.\n\nThe cache key is the prefix of the class names and the CSS variables under the registry. The\nfile uses `soroush`, the design system's own; an app that already has a key of its own may keep\nit. The registry writes one `<style data-umber=\"<key> ...\">` element per flush into the stream.\n\nThis set-up is tested on Next.js 16.4 with React 19.2, in development and in a production\nbuild, with a page that streams through `Suspense`. Keep styled parts in client components:\nthe registry collects what client components render.\n\nUnder a strict Content Security Policy (a `style-src` with a nonce and no `unsafe-inline`), give\nthe cache the response's nonce, `createCache({ key: 'soroush', nonce })`, and put the same nonce\non the `<style>` element the registry returns, `nonce={cache.nonce}`: that element is the app's\nown. Every style element the engine makes then carries it. Give React the same nonce for its\nrender; it keeps the rules of a style element only when the element's nonce is its own. This\nregistry has not been run under such a policy end to end, so test it in your app.\n\nThen in `app/layout.tsx`:\n\n```tsx\nexport default function RootLayout({ children }: { children: React.ReactNode }) {\n return (\n <html lang=\"en\">\n <body>\n <Providers>\n <TopBar />\n {children}\n </Providers>\n </body>\n </html>\n )\n}\n```\n\n`<Providers>` wraps everything including the chrome. Route groups then supply their\nown inner layout (rail + `Main`).\n\n## 4. Fonts\n\n`theme.fonts` names _Space Grotesk_ and _JetBrains Mono_, but the package does not\nload them. An app that never loads them renders in the system sans and mono fonts.\nTo get the intended look, load them once in the root layout -\n`@fontsource-variable/space-grotesk` + `@fontsource-variable/jetbrains-mono`, or\n`next/font`. Leaving the system fonts is also a valid choice; just make it deliberately.\n\n## 5. Layout scaffold\n\n```\ncomponents/\n chrome/constants.ts TOPBAR_HEIGHT = \"3.5rem\"\n chrome/TopBar.tsx sticky AppBar, brand wordmark, breadcrumb, session cluster\n chrome/Main.tsx 1600px column, 20→40px gutters\n chrome/<Rail>.tsx optional icon rail, bottom bar on mobile\n ui.tsx NavLink, TokenCode, StatusBadge + STATUS_TONE map\n PageCard.tsx PageHeader.tsx SectionLabel.tsx Pill.tsx\n StatStrip.tsx TabNav.tsx SettingCard.tsx SearchInput.tsx Skeletons.tsx\n```\n\nSources in `layout-kit.md`.\n\n## 6. tsconfig\n\n`@/*` path alias to the app root - every import above assumes it.\n\n## 7. Verify\n\n`pnpm typecheck` (`tsc --noEmit`) catches the common mistakes: a `tone` string that\nisn't a `PaletteColor`, a `theme.text.*` key that doesn't exist, a missing\n`shouldForwardProp`. The theme is fully typed - lean on it instead of eyeballing.\n"
|
|
1354
1354
|
},
|
|
1355
1355
|
{
|
|
1356
1356
|
"id": "layout-kit",
|
|
@@ -1367,14 +1367,14 @@ const content = {
|
|
|
1367
1367
|
{
|
|
1368
1368
|
"id": "providers",
|
|
1369
1369
|
"title": "Providers (Next.js App Router)",
|
|
1370
|
-
"summary": "ThemeProvider plus the
|
|
1371
|
-
"body": "Copy this verbatim into your app as `providers.tsx`.\n\n```tsx\n'use client'\n\nimport { useServerInsertedHTML } from 'next/navigation'\nimport { useState } from 'react'\nimport
|
|
1370
|
+
"summary": "ThemeProvider plus the style registry for the Next.js App Router.",
|
|
1371
|
+
"body": "Copy this verbatim into your app as `providers.tsx`.\n\n```tsx\n'use client'\n\nimport { useServerInsertedHTML } from 'next/navigation'\nimport { useState } from 'react'\nimport { CacheProvider, createCache, Global } from '@soroush.tech/design-system/engine'\nimport { ThemeProvider } from '@soroush.tech/design-system/theme'\nimport { light } from '@/theme'\n\n/** Collects the styles rendered on the server and re-injects them into the\n * HTML stream, so server-rendered markup arrives already styled. */\nfunction useStyleRegistry() {\n const [{ cache, flush }] = useState(() => {\n const cache = createCache({ key: 'soroush' })\n cache.compat = true\n const prevInsert = cache.insert\n let inserted: string[] = []\n cache.insert = (...args) => {\n const serialized = args[1]\n if (cache.inserted[serialized.name] === undefined) inserted.push(serialized.name)\n return prevInsert(...args)\n }\n const flush = () => {\n const prev = inserted\n inserted = []\n return prev\n }\n return { cache, flush }\n })\n\n useServerInsertedHTML(() => {\n const names = flush()\n if (names.length === 0) return null\n let styles = ''\n for (const name of names) styles += cache.inserted[name]\n return (\n <style\n key={cache.key}\n data-umber={`${cache.key} ${names.join(' ')}`}\n dangerouslySetInnerHTML={{ __html: styles }}\n />\n )\n })\n\n return cache\n}\n\nexport default function Providers({ children }: Readonly<{ children: React.ReactNode }>) {\n const cache = useStyleRegistry()\n return (\n <CacheProvider value={cache}>\n <ThemeProvider theme={light}>\n <Global\n styles={(theme) => ({\n '*, *::before, *::after': { boxSizing: 'border-box' },\n body: {\n margin: 0,\n backgroundColor: theme.background.primary,\n color: theme.text.initial,\n fontFamily: theme.fonts.body,\n },\n })}\n />\n {children}\n </ThemeProvider>\n </CacheProvider>\n )\n}\n```\n"
|
|
1372
1372
|
},
|
|
1373
1373
|
{
|
|
1374
1374
|
"id": "design-system-overview",
|
|
1375
1375
|
"title": "Design system overview",
|
|
1376
1376
|
"summary": "The package README: what ships, the import contract, and the component inventory.",
|
|
1377
|
-
"body": "**Your design system. Your tokens. Your rules.**\nA fully typed React component library where nothing is hardcoded - every color, scale, and default belongs to you, not the package.\n\nTired of forking a component library just to change a color? Every token here is designed to be overridden - theming isn't an afterthought, it's the whole point.\n\n## Install\n\n```sh\nnpm i @soroush.tech/design-system\n```\n\n`react` and `react-dom` are peer dependencies. Emotion is an internal implementation detail - it ships as a regular dependency, not a peer, so you never install it yourself.\n\n---\n\n## Use it with AI tools\n\nTwo skills teach a coding agent how to build with this library: a house-style skill, and a\nWCAG 2.2 AA skill for contrast, labels, landmarks and accessibility tests. Both install for\nwhichever agents you use:\n\n```sh\nnpx skills add soroush-tech/design-system\n```\n\nAn MCP server serves this library's component inventory, every component's props\nreference, and the live token contract, so an AI assistant writes against the real API\ninstead of guessing. Add the hosted server, `https://mcp.soroush.design/mcp`, to any MCP\nclient; in Claude Code:\n\n```sh\nclaude mcp add --transport http soroush https://mcp.soroush.design/mcp\n```\n\nIt also runs locally over stdio (`npx -y @soroush.design/mcp`). Claude Code users can\ninstall the plugin instead, which brings the skills, the server and a UI review agent in\none step:\n\n```sh\nclaude plugin marketplace add soroush-tech/design-system\nclaude plugin install soroush-design-system@soroush-tech\n```\n\nAny other tool can read [docs.soroush.tech/llms.txt](https://docs.soroush.tech/llms.txt).\nSee [`@soroush.design/mcp`](../mcp) for the full tool list.\n\n---\n\n## Importing\n\nImport components by subpath, styling primitives from the barrel:\n\n```ts\nimport { Typography } from '@soroush.tech/design-system/Typography'\nimport { Flex } from '@soroush.tech/design-system/Flex'\n```\n\nStyling primitives (the engine) come from the barrel `@soroush.tech/design-system` - `styled`, `css`, `keyframes`, the `Theme` type, styled-system functions, and `createShouldForwardProp`. The barrel (`src/index.ts`) is the engine abstraction layer: to swap the CSS-in-JS engine, only that file changes.\n\n```ts\nimport { styled, css, type Theme } from '@soroush.tech/design-system'\n```\n\n`ThemeProvider` and the theme-value hooks (`useTheme`, `useDefaultProps`, `withTheme`) live at their own subpath:\n\n```ts\nimport { ThemeProvider, useTheme } from '@soroush.tech/design-system/theme'\n```\n\nStyle-computation helpers (`useStyle`, `withStyles`, `StylesConsumer`) - resolving a `StyleInput`/`StyleFactory` into a `CSSObject` - live at their own subpath:\n\n```ts\nimport { useStyle } from '@soroush.tech/design-system/style'\n```\n\nRaw engine primitives for building your own global styles - `Global`, `globalStyles`, and the SSR-only `CacheProvider`/`styleCache` pairing - live at their own subpath, not the barrel:\n\n```ts\nimport { Global, globalStyles, CacheProvider, styleCache } from '@soroush.tech/design-system/engine'\n```\n\n`Global` (retyped against this package's `Theme`) applies app-wide CSS and should render inside `ThemeProvider` so it resolves against the active theme. `globalStyles(theme)` is the base reset this package owns - box-sizing, margin/table resets, and theme-driven body colors - compose it into your own `Global` styles array alongside your app's own concerns (font-family, webfont loading, and anything else app-specific stay entirely app policy).\n\nThe component catalog - every component as data, for tools that place and write components (a\ndesign tool's palette, a source writer) - lives at its own subpath and loads in plain Node\n([docs](./docs/catalog.md)):\n\n```ts\nimport { catalog } from '@soroush.tech/design-system/catalog'\n```\n\nSSR critical-CSS extraction (e.g. with `@emotion/server`) is a separate, opt-in concern most apps never need - that's what `CacheProvider` and its paired `styleCache` instance are for.\n\nUnder a strict Content Security Policy, bring your own cache with the response's nonce - `createCache({ key: 'app', nonce })` from `@emotion/cache`, given to `CacheProvider` above `ThemeProvider` - and every style tag the engine inserts carries it. The shipped `styleCache` has no nonce.\n\nThe Emotion packages are regular dependencies of this package, not peers, on purpose: nothing of Emotion is on the public surface, so an app installs nothing extra and has no version to keep in step. An app that brings its own `@emotion/react` of another major gets two copies - the components keep working, as they style through their own copy and `ThemeProvider` - at the cost of the duplicate in the bundle and Emotion's one-time development warning.\n\n---\n\n## Component inventory\n\n### Layout & surfaces\n\n| Component | Purpose |\n| ------------ | ----------------------------------------------------------------------- |\n| `ScrollArea` | A scrolling area with scrollbars drawn over its content, shown on hover |\n| `View` | Styled `div` primitive - the base building block |\n| `Flex` | `View` with flexbox defaults |\n| `Grid` | CSS grid container |\n| `Paper` | Elevated surface with background and shadow |\n| `Card` | Content container built on `Paper` |\n| `Quote` | Bordered quote / terminal-panel surface on `View` |\n| `AppBar` | Top application bar |\n| `Drawer` | Slide-in side panel |\n\n### Content & data display\n\n| Component | Purpose |\n| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `Typography` | Text with variant → element mapping - the reference implementation for all components |\n| `Link` | Anchor with theme-aware styling |\n| `Icon` | Icon renderer |\n| `Image` | Image with styled-system props |\n| `Avatar` | User/entity avatar |\n| `Table` | Compound data table - exports `TableContainer`, `TableHead`, `TableBody`, `TableFooter`, `TableRow`, `TableCell`, `TablePagination`, `TablePaginationActions`, `TableSortLabel`, and `TableControl` from `@soroush.tech/design-system/Table` |\n| `Accordion` | A heading that opens and closes a region - exports `AccordionSummary`, `AccordionDetails`, `AccordionActions` and `AccordionGroup` from `@soroush.tech/design-system/Accordion` |\n\n### Inputs & forms\n\n| Component | Purpose |\n| ---------------------------------------------------- | ----------------------------------------------------------------------------------------- |\n| `Autocomplete` | A field whose text finds an option in a list - one, several as chips, or free text |\n| `Fab` | A floating action button: the one main action of a page, circular or extended |\n| `Button`, `ButtonGroup`, `ToggleButton` | Actions and toggles |\n| `TextInput` | Text field |\n| `Checkbox`, `Radio`, `Switch` | Selection controls |\n| `RangeInput` | A slider - one value on a range, or two or more thumbs for a range of values |\n| `TransferList` | Two lists and the buttons that move the checked items from one to the other |\n| `NumberInput` | A field for a number - read in its locale, clamped to a range, stepped by keys or buttons |\n| `Rating` | A row of icons the user sets as a rating, or a read-only display of one |\n| `NativeSelect` | Low-level platform `<select>` - not recommended; use `Select native` |\n| `Select` | The select to use - custom listbox, or `native` for the platform picker |\n| `MenuItem` | Option row for `Select`'s listbox, and a menu row in a `MenuList` |\n| `Form`, `FormControl`, `FormLabel`, `FormHelperText` | Form composition and labeling |\n| `Pagination` | Page navigation control |\n\n### Navigation & menus\n\n| Component | Purpose |\n| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `NavTree` | A tree of links to the pages of a site - groups of links, which can fold |\n| `Breadcrumbs` | The trail of links from a site's root to the current page - a long one collapses behind a button that shows it all |\n| `Menu` | A trigger and the list of commands it opens - exports `MenuList` (the `role=\"menu\"` list that owns the keyboard), `MenuDivider`, `MenuItems` (rows from data) and `ContextMenu` (the same list, opened at the pointer by a right-click) from `@soroush.tech/design-system/Menu` |\n| `Tabs` | A row of tabs - exports `Tab`, `TabContext` (holds the value for a `TabList` and its panels), `TabList` (the `Tabs` of a `TabContext`), `TabPanel` (the content a tab shows) and `TabScrollButton` from `@soroush.tech/design-system/Tabs` |\n\n### Feedback\n\n| Component | Purpose |\n| ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------- |\n| `FabMenu` | A fab that opens a stack of actions from the corner of a page |\n| `Snackbar` | A transient message in a corner of the window, with auto-hide and an action |\n| `Alert` | An inline message with a severity, an icon, a title and an action - exports `AlertTitle` from `@soroush.tech/design-system/Alert` |\n| `Badge` | A count or a dot anchored over another element |\n| `Chip` | A compact tag: a label, an icon or avatar, a click and a delete |\n| `CircularProgress`, `LinearProgress` | Determinate/indeterminate progress indicators |\n| `Skeleton` | Loading placeholder with pulse/wave animations |\n| `Backdrop` | Dimmed overlay behind modal surfaces |\n\n### Transitions\n\n| Component | Purpose |\n| ------------------------------- | ------------------------------------------------------------------ |\n| `Collapse` | Opens and closes its content by its height, or its width |\n| `Fade`, `Grow`, `Slide`, `Zoom` | Show and hide one child by opacity, scale, an edge or from nothing |\n\n### Overlay & behavior primitives\n\n| Component | Purpose |\n| --------------- | ----------------------------------------------------------------------------------- |\n| `Tooltip` | A short description of one element, shown on hover, keyboard focus and a long touch |\n| `Portal` | Renders children into a DOM node outside the parent hierarchy |\n| `FocusTrap` | Keeps focus inside a subtree |\n| `Modal` | Dialog primitive composing `Portal`, `Backdrop`, and `FocusTrap` |\n| `Popover` | Anchored floating surface built on `Modal` |\n| `ThemeProvider` | Supplies the theme and global styles to the app |\n\n---\n\n## Theme tokens\n\nComponents never hardcode colors or sizes - props resolve against scales on the `Theme` object:\n\n| Group | Scales |\n| ------------------ | ------------------------------------------------------------------------------------------------------------- |\n| Color | `palette` (main/light/dark/contrastText per color) · `text` · `background` · `border` · `colorScheme` |\n| Typography | `typography` (variant map) · `fonts` · `fontSizes` · `fontWeights` · `lineHeights` · `letterSpacings` |\n| Space & shape | `space` · `sizes` · `radii` · `borderWidths` · `shadows` |\n| Layout | `breakpoints` (xs/sm/md/lg/xl window classes) · `layout` (columns, margins, panels, top bar per class) |\n| Component scales | `avatar` (size steps) · `skeleton` (wave highlight) |\n| Layering & effects | `zOrder` (appBar/drawer/modal/snackbar/tooltip) · `blur` · `logoFilter` · `portraitBlend` · `portraitOpacity` |\n\nProp types are derived from the interface (`keyof Theme['text']`), so adding a token to `themes.ts` propagates everywhere automatically. See [`design-system.md`](./design-system.md) for the full scale table and the palette rules.\n\n---\n\n## Theming\n\nThe theme belongs to you - the package only ships defaults. This section is the overview; the full guides are [`docs/theming.md`](./docs/theming.md) and [`docs/customization.md`](./docs/customization.md).\n\n### One theme, yours\n\n`ThemeProvider` provides exactly one theme - the built-in dark theme when you pass nothing. Bring one theme, or as many as you like: switching between them is your state, not the provider's.\n\n```tsx\nimport { ThemeProvider } from '@soroush.tech/design-system/theme'\nimport { baseTheme, createTheme } from '@soroush.tech/design-system/theme'\n\n// Zero-config: the built-in `baseTheme`.\n<ThemeProvider>{app}</ThemeProvider>\n\n// Your theme - written from scratch or extended from the base.\nconst brand = createTheme(baseTheme, { palette: { primary: { main: '#00ff88' } } })\n<ThemeProvider theme={brand}>{app}</ThemeProvider>\n\n// Mode switching is app policy - own the state and pass the active theme:\nconst [isDark, setIsDark] = useState(true)\n<ThemeProvider theme={isDark ? brandDark : brandLight}>{app}</ThemeProvider>\n```\n\n`createTheme(base, overrides)` (exported from `@soroush.tech/design-system/theme`) is the merge primitive: plain objects recurse, arrays (`shadows`, `fontSizes`) and functions replace wholesale, `undefined` values are ignored - keys are added or replaced, never removed.\n\n### Breakpoints and layout\n\n`theme.breakpoints` are Material 3's window classes, each a range from its start until the next:\n`xs` 0-599px (compact, the base), `sm` 600-839 (medium), `md` 840-1199 (expanded), `lg`\n1200-1599 (large), `xl` 1600+ (extra-large). Responsive props use them by name or position -\n`p={{ xs: 2, md: 4 }}`, `p={[2, 3, 4]}` - and `cqSm`-style keys write container queries;\n`theme.breakpoints.up('md')` and its siblings write queries for hand-written styles. Everything is\nCSS, so pages work with JavaScript off. `theme.layout` holds the layout tokens per class (columns,\nmargins, gutters, side panels, top bar); `Grid` and `Flex` apply the column grid with\n`layout` / `layout={{ lg: { columns: 16 } }}`, and apps place `AppBar`, `Sidebar` and `Drawer`\nthemselves. The full guide is the\n[Breakpoints and layout](./docs/theming.md#breakpoints-and-layout) section of the theming guide.\n\n### Component defaults\n\nComponents carry visible literal fallbacks (`size = 'md'`, `variant = 'outside'`, ...) resolved through `themeDefault(theme, key, fallback)` - so every default, including behavioral variants, is overridable via the optional `theme.defaults` map or the provider's `defaults` prop:\n\n| Key | Fallback | Drives |\n| -------------------------------------------- | ---------------------------------- | -------------------------------------- |\n| `size` / `compactSize` | `'md'` / `'sm'` | sized components / dense table actions |\n| `color` / `neutralColor` | `'primary'` / `'default'` | accent controls / toggle controls |\n| `textColor` / `accentTextColor` | `'initial'` / `'primary'` | body text / icons + input labels |\n| `bg` / `surfaceBg` / `inputBg` | `'default'`/`'paper'`/`'terminal'` | switch track / paper surfaces / inputs |\n| `borderRadius` / `surfaceRadius` | `'md'` / `'sq'` | grouped controls / surfaces |\n| `avatarSize` / `borderColor` / `borderWidth` | `'md'` / `'primary'` / `'thin'` | avatars and rings |\n| `iconSize` | `'lg'` | Icon default glyph size (`theme.icon`) |\n| `inputMinWidth` | `'12rem'` | least width of an input not full width |\n| `buttonVariant` / `switchVariant` | `'contained'` / `'outside'` | Button / Switch visual variants |\n| `inputVariant` | `'default'` | TextInput, Select, NativeSelect frames |\n| `avatarVariant` / `cardVariant` | `'circular'` / `'paper'` | Avatar shape / Card treatment |\n| `linkUnderline` | `'always'` | Link underline behavior |\n| `paginationVariant` / `paginationShape` | `'text'` / `'circular'` | Pagination items |\n\nThe built-in themes carry no `defaults` - the literals apply. A theme with entirely different size or palette keys stays valid by pointing the keys at its own tokens:\n\n```tsx\n<ThemeProvider defaults={{ size: 'compact', color: 'brand', switchVariant: 'inside' }}>\n```\n\n### Per-component customization (`theme.components`)\n\nCustomize one component for the whole app - default prop values, per-slot CSS, and new variant values - without wrapping or forking:\n\n```tsx\nconst brand = createTheme(baseTheme, {\n components: {\n Button: {\n // Buttons default to sm + rounded; explicit props and ButtonGroup still win.\n defaultProps: { size: 'sm', shape: 'rounded' },\n\n // Per-slot CSS merged after Button's own styles - the theme wins the cascade,\n // but per-instance props (m, p, width, ...) still beat the theme.\n styleOverrides: {\n root: ({ theme, ownerState }) => ({\n letterSpacing: theme.letterSpacings.wide,\n ...(ownerState.variant === 'contained' && { textTransform: 'none' }),\n }),\n label: { fontStyle: 'italic' },\n },\n\n // A new variant value - register it first so it typechecks:\n // declare module '@soroush.tech/design-system/theme' { interface ButtonVariants { dashed: true } }\n variants: [\n {\n props: { variant: 'dashed' },\n style: ({ theme }) => ({\n backgroundColor: 'transparent',\n border: `${theme.borderWidths.thin} dashed ${theme.border.primary}`,\n }),\n },\n ],\n },\n },\n})\n```\n\nStyle callbacks receive `{ theme, ownerState }`, where `ownerState` is the styled root's **resolved** props (after group context, `defaultProps`, and `theme.defaults`). `defaultProps` sits in the standard precedence chain: explicit prop → group context → `defaultProps` → `theme.defaults.*` → the component's literal fallback. `variants` arrays are replaced wholesale by `createTheme`, never merged.\n\nYour own components can join the same mechanism: create their roots with this package's `styled(tag, { name: 'MyWidget', slot: 'root' })` and register the name by augmenting `ThemeComponents`. Zero-config themes pay nothing - the resolver bails out on the first check when `theme.components` is absent.\n\n### Extending tokens (declaration merging)\n\nEvery scale is an open interface declared on `@soroush.tech/design-system/theme`, so you can add palette colors, tokens, or whole scales - and every component prop union (`color`, `bg`, `size`, ...) widens automatically:\n\n```ts\nimport type { PaletteEntry } from '@soroush.tech/design-system/theme'\n\ndeclare module '@soroush.tech/design-system/theme' {\n interface ThemePalette {\n brand: PaletteEntry // new palette color\n }\n interface ThemeBackground {\n tertiary: string // new background token\n }\n interface Theme {\n elevations: Record<'low' | 'mid' | 'high', string> // whole new scale\n }\n}\n```\n\nThen supply the values with `createTheme` and use the new keys:\n\n```tsx\nconst brandDark = createTheme(baseTheme, {\n palette: { brand: { main: '#00ff88', light: '#66ffb2', dark: '#00b25f', contrastText: '#000' } },\n background: { tertiary: '#101418' },\n elevations: { low: '0 1px 2px', mid: '0 2px 6px', high: '0 6px 18px' },\n})\n\n<ThemeProvider theme={brandDark}>\n <Button color=\"brand\" />\n <View bg=\"tertiary\" />\n</ThemeProvider>\n```\n\nNotes: new object-valued keys (like a `PaletteEntry`) must be supplied complete - components read `.main`/`.contrastText` at runtime; and TypeScript cannot verify at runtime that an augmented token was actually supplied, so always pair an augmentation with the matching override.\n\n---\n\n## Adding a component\n\nScaffold with the skill - it reads the live `Typography` files and `design-system.md` so output matches the codebase:\n\n```\n/new_theme_component ComponentName\n```\n\nThen work through the checklist at the bottom of [`design-system.md`](./design-system.md).\n\n---\n\nThe library takes inspiration from [Material UI](https://mui.com/) - its component vocabulary and prop conventions will feel familiar - but it is written entirely in house. It is not a clone or a fork: every component is built from scratch on our own engine and token system, and the API is free to diverge wherever it serves its consumers better.\n\n---\n\n## Release notes\n\nPer-version notes for every published release live in\n[`release-notes/`](https://github.com/soroush-tech/design-system/tree/main/packages/design-system/release-notes).\n",
|
|
1377
|
+
"body": "**Your design system. Your tokens. Your rules.**\nA fully typed React component library where nothing is hardcoded - every color, scale, and default belongs to you, not the package.\n\nTired of forking a component library just to change a color? Every token here is designed to be overridden - theming isn't an afterthought, it's the whole point.\n\n## Install\n\n```sh\nnpm i @soroush.tech/design-system\n```\n\n`react` and `react-dom` are peer dependencies, and React 19.2 or later is required. The styling engine (UmberStyle, the `@umber-style/*` packages) is an internal implementation detail - it ships as a regular dependency, not a peer, so you never install it yourself.\n\n---\n\n## Use it with AI tools\n\nTwo skills teach a coding agent how to build with this library: a house-style skill, and a\nWCAG 2.2 AA skill for contrast, labels, landmarks and accessibility tests. Both install for\nwhichever agents you use:\n\n```sh\nnpx skills add soroush-tech/design-system\n```\n\nAn MCP server serves this library's component inventory, every component's props\nreference, and the live token contract, so an AI assistant writes against the real API\ninstead of guessing. Add the hosted server, `https://mcp.soroush.design/mcp`, to any MCP\nclient; in Claude Code:\n\n```sh\nclaude mcp add --transport http soroush https://mcp.soroush.design/mcp\n```\n\nIt also runs locally over stdio (`npx -y @soroush.design/mcp`). Claude Code users can\ninstall the plugin instead, which brings the skills, the server and a UI review agent in\none step:\n\n```sh\nclaude plugin marketplace add soroush-tech/design-system\nclaude plugin install soroush-design-system@soroush-tech\n```\n\nAny other tool can read [docs.soroush.tech/llms.txt](https://docs.soroush.tech/llms.txt).\nSee [`@soroush.design/mcp`](../mcp) for the full tool list.\n\n---\n\n## Importing\n\nImport components by subpath, styling primitives from the barrel:\n\n```ts\nimport { Typography } from '@soroush.tech/design-system/Typography'\nimport { Flex } from '@soroush.tech/design-system/Flex'\n```\n\nStyling primitives (the engine) come from the barrel `@soroush.tech/design-system` - `styled`, `css`, `keyframes`, the `Theme` type, styled-system functions, and `createShouldForwardProp`. The barrel (`src/index.ts`) is the engine abstraction layer: to swap the CSS-in-JS engine, only that file changes.\n\n```ts\nimport { styled, css, type Theme } from '@soroush.tech/design-system'\n```\n\n`ThemeProvider` and the theme-value hooks (`useTheme`, `useDefaultProps`, `withTheme`) live at their own subpath:\n\n```ts\nimport { ThemeProvider, useTheme } from '@soroush.tech/design-system/theme'\n```\n\nStyle-computation helpers (`useStyle`, `withStyles`, `StylesConsumer`) - resolving a `StyleInput`/`StyleFactory` into a `CSSObject` - live at their own subpath:\n\n```ts\nimport { useStyle } from '@soroush.tech/design-system/style'\n```\n\nRaw engine primitives for building your own global styles - `Global`, `globalStyles`, and the SSR-only `CacheProvider`/`styleCache` pairing - live at their own subpath, not the barrel:\n\n```ts\nimport { Global, globalStyles, CacheProvider, styleCache } from '@soroush.tech/design-system/engine'\n```\n\n`Global` (retyped against this package's `Theme`) applies app-wide CSS and should render inside `ThemeProvider` so it resolves against the active theme. `globalStyles(theme)` is the base reset this package owns - box-sizing, margin/table resets, and theme-driven body colors - compose it into your own `Global` styles array alongside your app's own concerns (font-family, webfont loading, and anything else app-specific stay entirely app policy).\n\nThe component catalog - every component as data, for tools that place and write components (a\ndesign tool's palette, a source writer) - lives at its own subpath and loads in plain Node\n([docs](./docs/catalog.md)):\n\n```ts\nimport { catalog } from '@soroush.tech/design-system/catalog'\n```\n\nServer rendering with critical CSS (a Vike or other static or server renderer) is a separate, opt-in concern - that's what `CacheProvider` and its paired `styleCache` instance are for. Give `CacheProvider` the `styleCache`, render, then read the CSS of the page from the same cache with `createInstance` from `@umber-style/server/create-instance` (`pnpm add @umber-style/server`): `extractCriticalToChunks(html)` and `constructStyleTagsFromChunks(chunks)` give the `<style data-umber>` tags to put in the head. Next.js App Router apps collect the styles with a registry instead - see `docs/consumer/setup.md`.\n\nThe cache key and class prefix is `soroush`. Server-rendered style elements carry `data-umber=\"soroush ...\"`, and the live element in the browser is `<style data-style=\"soroush\">`.\n\nThe engine packages are regular dependencies of this package, not peers, on purpose: an app installs nothing extra to render the components, and has no version to keep in step. The one package an app adds itself is `@umber-style/server`, and only to extract critical CSS.\n\n---\n\n## Component inventory\n\n### Layout & surfaces\n\n| Component | Purpose |\n| ------------ | ----------------------------------------------------------------------- |\n| `ScrollArea` | A scrolling area with scrollbars drawn over its content, shown on hover |\n| `View` | Styled `div` primitive - the base building block |\n| `Flex` | `View` with flexbox defaults |\n| `Grid` | CSS grid container |\n| `Paper` | Elevated surface with background and shadow |\n| `Card` | Content container built on `Paper` |\n| `Quote` | Bordered quote / terminal-panel surface on `View` |\n| `AppBar` | Top application bar |\n| `Drawer` | Slide-in side panel |\n\n### Content & data display\n\n| Component | Purpose |\n| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `Typography` | Text with variant → element mapping - the reference implementation for all components |\n| `Link` | Anchor with theme-aware styling |\n| `Icon` | Icon renderer |\n| `Image` | Image with styled-system props |\n| `Avatar` | User/entity avatar |\n| `Table` | Compound data table - exports `TableContainer`, `TableHead`, `TableBody`, `TableFooter`, `TableRow`, `TableCell`, `TablePagination`, `TablePaginationActions`, `TableSortLabel`, and `TableControl` from `@soroush.tech/design-system/Table` |\n| `Accordion` | A heading that opens and closes a region - exports `AccordionSummary`, `AccordionDetails`, `AccordionActions` and `AccordionGroup` from `@soroush.tech/design-system/Accordion` |\n\n### Inputs & forms\n\n| Component | Purpose |\n| ---------------------------------------------------- | ----------------------------------------------------------------------------------------- |\n| `Autocomplete` | A field whose text finds an option in a list - one, several as chips, or free text |\n| `Fab` | A floating action button: the one main action of a page, circular or extended |\n| `Button`, `ButtonGroup`, `ToggleButton` | Actions and toggles |\n| `TextInput` | Text field |\n| `Checkbox`, `Radio`, `Switch` | Selection controls |\n| `RangeInput` | A slider - one value on a range, or two or more thumbs for a range of values |\n| `TransferList` | Two lists and the buttons that move the checked items from one to the other |\n| `NumberInput` | A field for a number - read in its locale, clamped to a range, stepped by keys or buttons |\n| `Rating` | A row of icons the user sets as a rating, or a read-only display of one |\n| `NativeSelect` | Low-level platform `<select>` - not recommended; use `Select native` |\n| `Select` | The select to use - custom listbox, or `native` for the platform picker |\n| `MenuItem` | Option row for `Select`'s listbox, and a menu row in a `MenuList` |\n| `Form`, `FormControl`, `FormLabel`, `FormHelperText` | Form composition and labeling |\n| `Pagination` | Page navigation control |\n\n### Navigation & menus\n\n| Component | Purpose |\n| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `NavTree` | A tree of links to the pages of a site - groups of links, which can fold |\n| `Breadcrumbs` | The trail of links from a site's root to the current page - a long one collapses behind a button that shows it all |\n| `Menu` | A trigger and the list of commands it opens - exports `MenuList` (the `role=\"menu\"` list that owns the keyboard), `MenuDivider`, `MenuItems` (rows from data) and `ContextMenu` (the same list, opened at the pointer by a right-click) from `@soroush.tech/design-system/Menu` |\n| `Tabs` | A row of tabs - exports `Tab`, `TabContext` (holds the value for a `TabList` and its panels), `TabList` (the `Tabs` of a `TabContext`), `TabPanel` (the content a tab shows) and `TabScrollButton` from `@soroush.tech/design-system/Tabs` |\n\n### Feedback\n\n| Component | Purpose |\n| ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------- |\n| `FabMenu` | A fab that opens a stack of actions from the corner of a page |\n| `Snackbar` | A transient message in a corner of the window, with auto-hide and an action |\n| `Alert` | An inline message with a severity, an icon, a title and an action - exports `AlertTitle` from `@soroush.tech/design-system/Alert` |\n| `Badge` | A count or a dot anchored over another element |\n| `Chip` | A compact tag: a label, an icon or avatar, a click and a delete |\n| `CircularProgress`, `LinearProgress` | Determinate/indeterminate progress indicators |\n| `Skeleton` | Loading placeholder with pulse/wave animations |\n| `Backdrop` | Dimmed overlay behind modal surfaces |\n\n### Transitions\n\n| Component | Purpose |\n| ------------------------------- | ------------------------------------------------------------------ |\n| `Collapse` | Opens and closes its content by its height, or its width |\n| `Fade`, `Grow`, `Slide`, `Zoom` | Show and hide one child by opacity, scale, an edge or from nothing |\n\n### Overlay & behavior primitives\n\n| Component | Purpose |\n| --------------- | ----------------------------------------------------------------------------------- |\n| `Tooltip` | A short description of one element, shown on hover, keyboard focus and a long touch |\n| `Portal` | Renders children into a DOM node outside the parent hierarchy |\n| `FocusTrap` | Keeps focus inside a subtree |\n| `Modal` | Dialog primitive composing `Portal`, `Backdrop`, and `FocusTrap` |\n| `Popover` | Anchored floating surface built on `Modal` |\n| `ThemeProvider` | Supplies the theme and global styles to the app |\n\n---\n\n## Theme tokens\n\nComponents never hardcode colors or sizes - props resolve against scales on the `Theme` object:\n\n| Group | Scales |\n| ------------------ | ------------------------------------------------------------------------------------------------------------- |\n| Color | `palette` (main/light/dark/contrastText per color) · `text` · `background` · `border` · `colorScheme` |\n| Typography | `typography` (variant map) · `fonts` · `fontSizes` · `fontWeights` · `lineHeights` · `letterSpacings` |\n| Space & shape | `space` · `sizes` · `radii` · `borderWidths` · `shadows` |\n| Layout | `breakpoints` (xs/sm/md/lg/xl window classes) · `layout` (columns, margins, panels, top bar per class) |\n| Component scales | `avatar` (size steps) · `skeleton` (wave highlight) |\n| Layering & effects | `zOrder` (appBar/drawer/modal/snackbar/tooltip) · `blur` · `logoFilter` · `portraitBlend` · `portraitOpacity` |\n\nProp types are derived from the interface (`keyof Theme['text']`), so adding a token to `themes.ts` propagates everywhere automatically. See [`design-system.md`](./design-system.md) for the full scale table and the palette rules.\n\n---\n\n## Theming\n\nThe theme belongs to you - the package only ships defaults. This section is the overview; the full guides are [`docs/theming.md`](./docs/theming.md) and [`docs/customization.md`](./docs/customization.md).\n\n### One theme, yours\n\n`ThemeProvider` provides exactly one theme - the built-in dark theme when you pass nothing. Bring one theme, or as many as you like: switching between them is your state, not the provider's.\n\n```tsx\nimport { ThemeProvider } from '@soroush.tech/design-system/theme'\nimport { baseTheme, createTheme } from '@soroush.tech/design-system/theme'\n\n// Zero-config: the built-in `baseTheme`.\n<ThemeProvider>{app}</ThemeProvider>\n\n// Your theme - written from scratch or extended from the base.\nconst brand = createTheme(baseTheme, { palette: { primary: { main: '#00ff88' } } })\n<ThemeProvider theme={brand}>{app}</ThemeProvider>\n\n// Mode switching is app policy - own the state and pass the active theme:\nconst [isDark, setIsDark] = useState(true)\n<ThemeProvider theme={isDark ? brandDark : brandLight}>{app}</ThemeProvider>\n```\n\n`createTheme(base, overrides)` (exported from `@soroush.tech/design-system/theme`) is the merge primitive: plain objects recurse, arrays (`shadows`, `fontSizes`) and functions replace wholesale, `undefined` values are ignored - keys are added or replaced, never removed.\n\n### Breakpoints and layout\n\n`theme.breakpoints` are Material 3's window classes, each a range from its start until the next:\n`xs` 0-599px (compact, the base), `sm` 600-839 (medium), `md` 840-1199 (expanded), `lg`\n1200-1599 (large), `xl` 1600+ (extra-large). Responsive props use them by name or position -\n`p={{ xs: 2, md: 4 }}`, `p={[2, 3, 4]}` - and `cqSm`-style keys write container queries;\n`theme.breakpoints.up('md')` and its siblings write queries for hand-written styles. Everything is\nCSS, so pages work with JavaScript off. `theme.layout` holds the layout tokens per class (columns,\nmargins, gutters, side panels, top bar); `Grid` and `Flex` apply the column grid with\n`layout` / `layout={{ lg: { columns: 16 } }}`, and apps place `AppBar`, `Sidebar` and `Drawer`\nthemselves. The full guide is the\n[Breakpoints and layout](./docs/theming.md#breakpoints-and-layout) section of the theming guide.\n\n### Component defaults\n\nComponents carry visible literal fallbacks (`size = 'md'`, `variant = 'outside'`, ...) resolved through `themeDefault(theme, key, fallback)` - so every default, including behavioral variants, is overridable via the optional `theme.defaults` map or the provider's `defaults` prop:\n\n| Key | Fallback | Drives |\n| -------------------------------------------- | ---------------------------------- | -------------------------------------- |\n| `size` / `compactSize` | `'md'` / `'sm'` | sized components / dense table actions |\n| `color` / `neutralColor` | `'primary'` / `'default'` | accent controls / toggle controls |\n| `textColor` / `accentTextColor` | `'initial'` / `'primary'` | body text / icons + input labels |\n| `bg` / `surfaceBg` / `inputBg` | `'default'`/`'paper'`/`'terminal'` | switch track / paper surfaces / inputs |\n| `borderRadius` / `surfaceRadius` | `'md'` / `'sq'` | grouped controls / surfaces |\n| `avatarSize` / `borderColor` / `borderWidth` | `'md'` / `'primary'` / `'thin'` | avatars and rings |\n| `iconSize` | `'lg'` | Icon default glyph size (`theme.icon`) |\n| `inputMinWidth` | `'12rem'` | least width of an input not full width |\n| `buttonVariant` / `switchVariant` | `'contained'` / `'outside'` | Button / Switch visual variants |\n| `inputVariant` | `'default'` | TextInput, Select, NativeSelect frames |\n| `avatarVariant` / `cardVariant` | `'circular'` / `'paper'` | Avatar shape / Card treatment |\n| `linkUnderline` | `'always'` | Link underline behavior |\n| `paginationVariant` / `paginationShape` | `'text'` / `'circular'` | Pagination items |\n\nThe built-in themes carry no `defaults` - the literals apply. A theme with entirely different size or palette keys stays valid by pointing the keys at its own tokens:\n\n```tsx\n<ThemeProvider defaults={{ size: 'compact', color: 'brand', switchVariant: 'inside' }}>\n```\n\n### Per-component customization (`theme.components`)\n\nCustomize one component for the whole app - default prop values, per-slot CSS, and new variant values - without wrapping or forking:\n\n```tsx\nconst brand = createTheme(baseTheme, {\n components: {\n Button: {\n // Buttons default to sm + rounded; explicit props and ButtonGroup still win.\n defaultProps: { size: 'sm', shape: 'rounded' },\n\n // Per-slot CSS merged after Button's own styles - the theme wins the cascade,\n // but per-instance props (m, p, width, ...) still beat the theme.\n styleOverrides: {\n root: ({ theme, ownerState }) => ({\n letterSpacing: theme.letterSpacings.wide,\n ...(ownerState.variant === 'contained' && { textTransform: 'none' }),\n }),\n label: { fontStyle: 'italic' },\n },\n\n // A new variant value - register it first so it typechecks:\n // declare module '@soroush.tech/design-system/theme' { interface ButtonVariants { dashed: true } }\n variants: [\n {\n props: { variant: 'dashed' },\n style: ({ theme }) => ({\n backgroundColor: 'transparent',\n border: `${theme.borderWidths.thin} dashed ${theme.border.primary}`,\n }),\n },\n ],\n },\n },\n})\n```\n\nStyle callbacks receive `{ theme, ownerState }`, where `ownerState` is the styled root's **resolved** props (after group context, `defaultProps`, and `theme.defaults`). `defaultProps` sits in the standard precedence chain: explicit prop → group context → `defaultProps` → `theme.defaults.*` → the component's literal fallback. `variants` arrays are replaced wholesale by `createTheme`, never merged.\n\nYour own components can join the same mechanism: create their roots with this package's `styled(tag, { name: 'MyWidget', slot: 'root' })` and register the name by augmenting `ThemeComponents`. Zero-config themes pay nothing - the resolver bails out on the first check when `theme.components` is absent.\n\n### Extending tokens (declaration merging)\n\nEvery scale is an open interface declared on `@soroush.tech/design-system/theme`, so you can add palette colors, tokens, or whole scales - and every component prop union (`color`, `bg`, `size`, ...) widens automatically:\n\n```ts\nimport type { PaletteEntry } from '@soroush.tech/design-system/theme'\n\ndeclare module '@soroush.tech/design-system/theme' {\n interface ThemePalette {\n brand: PaletteEntry // new palette color\n }\n interface ThemeBackground {\n tertiary: string // new background token\n }\n interface Theme {\n elevations: Record<'low' | 'mid' | 'high', string> // whole new scale\n }\n}\n```\n\nThen supply the values with `createTheme` and use the new keys:\n\n```tsx\nconst brandDark = createTheme(baseTheme, {\n palette: { brand: { main: '#00ff88', light: '#66ffb2', dark: '#00b25f', contrastText: '#000' } },\n background: { tertiary: '#101418' },\n elevations: { low: '0 1px 2px', mid: '0 2px 6px', high: '0 6px 18px' },\n})\n\n<ThemeProvider theme={brandDark}>\n <Button color=\"brand\" />\n <View bg=\"tertiary\" />\n</ThemeProvider>\n```\n\nNotes: new object-valued keys (like a `PaletteEntry`) must be supplied complete - components read `.main`/`.contrastText` at runtime; and TypeScript cannot verify at runtime that an augmented token was actually supplied, so always pair an augmentation with the matching override.\n\n---\n\n## Adding a component\n\nScaffold with the skill - it reads the live `Typography` files and `design-system.md` so output matches the codebase:\n\n```\n/new_theme_component ComponentName\n```\n\nThen work through the checklist at the bottom of [`design-system.md`](./design-system.md).\n\n---\n\nThe library takes inspiration from [Material UI](https://mui.com/) - its component vocabulary and prop conventions will feel familiar - but it is written entirely in house. It is not a clone or a fork: every component is built from scratch on our own engine and token system, and the API is free to diverge wherever it serves its consumers better.\n\n---\n\n## Release notes\n\nPer-version notes for every published release live in\n[`release-notes/`](https://github.com/soroush-tech/design-system/tree/main/packages/design-system/release-notes).\n",
|
|
1378
1378
|
"url": "https://docs.soroush.tech/design-system/"
|
|
1379
1379
|
},
|
|
1380
1380
|
{
|
|
@@ -1388,7 +1388,7 @@ const content = {
|
|
|
1388
1388
|
"id": "styled-system-overview",
|
|
1389
1389
|
"title": "Styled-system overview",
|
|
1390
1390
|
"summary": "The style-prop engine underneath the design system.",
|
|
1391
|
-
"body": "A maintained, first-class-TypeScript rewrite of [styled-system](https://github.com/jxnblk/styled-system) v5 - responsive, theme-aware style props for CSS-in-JS.\n\nIt is a **drop-in replacement** for the `styled-system` runtime: the root export surface matches upstream verbatim, and the package ships its own types (replacing `@types/styled-system`).\n\n## Features\n\n- Add style props that hook into your own theme\n- Quickly set responsive `font-size`, `margin`, `padding`, `gap`, `width`, and more with props\n- Influenced by constraint-based design-system principles\n- Typographic scale, and a spacing scale for `margin`, `padding` and `gap`\n- Works with any color palette\n- Works with most CSS-in-JS libraries, including [Emotion](https://emotion.sh) and [styled-components](https://styled-components.com)\n- First-class TypeScript types - theme-scale-aware props, replacing `@types/styled-system`\n\n## Install\n\n```sh\n# npm\nnpm install @soroush.tech/styled-system\n```\n\n```sh\n# pnpm\npnpm add @soroush.tech/styled-system\n```\n\n```sh\n# yarn\nyarn add @soroush.tech/styled-system\n```\n\n
|
|
1391
|
+
"body": "A maintained, first-class-TypeScript rewrite of [styled-system](https://github.com/jxnblk/styled-system) v5 - responsive, theme-aware style props for CSS-in-JS.\n\nIt is a **drop-in replacement** for the `styled-system` runtime: the root export surface matches upstream verbatim, and the package ships its own types (replacing `@types/styled-system`).\n\n## Features\n\n- Add style props that hook into your own theme\n- Quickly set responsive `font-size`, `margin`, `padding`, `gap`, `width`, and more with props\n- Influenced by constraint-based design-system principles\n- Typographic scale, and a spacing scale for `margin`, `padding` and `gap`\n- Works with any color palette\n- Works with most CSS-in-JS libraries, including [Emotion](https://emotion.sh) and [styled-components](https://styled-components.com)\n- First-class TypeScript types - theme-scale-aware props, replacing `@types/styled-system`\n\n## Install\n\n```sh\n# npm\nnpm install @soroush.tech/styled-system\n```\n\n```sh\n# pnpm\npnpm add @soroush.tech/styled-system\n```\n\n```sh\n# yarn\nyarn add @soroush.tech/styled-system\n```\n\n`prop-types` (`^15.8.1`, optional peer) is used by a single [subpath](#subpath-imports),\n`prop-types`. Install it only if you import that subpath. The `should-forward-prop` subpath\nneeds nothing installed: its check for a valid attribute is a dependency of this package. You bring your own CSS-in-JS\nlibrary (Emotion, styled-components, ...); the core carries neither at runtime.\n\n## Usage\n\n```ts\n// Example uses Emotion, but styled-system works with most other CSS-in-JS libraries as well\nimport styled from '@emotion/styled'\nimport { space, layout, typography, color } from '@soroush.tech/styled-system'\n\n// Add styled-system functions to your component\nconst Box = styled.div`\n ${space}\n ${layout}\n ${typography}\n ${color}\n`\n```\n\nEach style function exposes its own set of component props that handle styles based on values defined in a theme.\n\n```tsx\n// width: 50%\n<Box width={1 / 2} />\n\n// font-size: 20px (theme.fontSizes[4])\n<Box fontSize={4} />\n\n// margin: 16px (theme.space[2])\n<Box m={2} />\n\n// padding: 32px (theme.space[3])\n<Box p={3} />\n\n// color\n<Box color=\"tomato\" />\n\n// color: #333 (theme.colors.gray[0])\n<Box color=\"gray.0\" />\n\n// background-color\n<Box bg=\"tomato\" />\n```\n\n### Responsive style props\n\nSet responsive `width`, `margin`, `padding`, `font-size`, and other properties with a shorthand array syntax. See [Responsive Styles](./docs/responsive-styles.md).\n\n```tsx\n// responsive width\n<Box width={[1, 1 / 2, 1 / 4]} />\n\n// responsive font-size\n<Box fontSize={[2, 3, 4]} />\n\n// responsive margin\n<Box m={[1, 2, 3]} />\n\n// responsive padding\n<Box p={[1, 2, 3]} />\n```\n\n### Subpath imports\n\nSubpaths mirror the original `@styled-system/*` packages:\n\n```ts\nimport { css } from '@soroush.tech/styled-system/css'\nimport { themeGet } from '@soroush.tech/styled-system/theme-get'\nimport { pick, omit } from '@soroush.tech/styled-system/props'\nimport propTypes, { createPropTypes } from '@soroush.tech/styled-system/prop-types'\nimport shouldForwardProp, {\n createShouldForwardProp,\n props,\n} from '@soroush.tech/styled-system/should-forward-prop'\n```\n\n## Drop-in via alias\n\nExisting `styled-system` users can swap with a package-manager alias - no code changes:\n\n```jsonc\n\"dependencies\": {\n \"styled-system\": \"npm:@soroush.tech/styled-system@^5\"\n}\n```\n\nThe satellite `@styled-system/*` packages don't need separate aliases - import them as\nsubpaths off the aliased `styled-system` name, and they resolve through this package's\n`exports`:\n\n```ts\nimport themeGet from 'styled-system/theme-get'\nimport propTypes from 'styled-system/prop-types'\nimport { css } from 'styled-system/css'\nimport shouldForwardProp from 'styled-system/should-forward-prop'\n```\n\nTypes resolve under both modern module resolution (`node16`/`nodenext`/`bundler`, via\n`exports`) and classic `node` (via `typesVersions`).\n\n## Documentation\n\nFull docs live in [`docs/`](./docs/README.md):\n\n- [Getting Started](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/docs/getting-started.md)\n- [Responsive Styles](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/docs/responsive-styles.md)\n- [How it Works](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/docs/how-it-works.md)\n- [Custom Props](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/docs/custom-props.md)\n- [Variants](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/docs/variants.md)\n- [API](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/docs/api.md)\n- [Reference Table](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/docs/table.md)\n- [TypeScript](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/docs/typescript.md)\n- [Guides](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/docs/guides/index.md)\n\nRunnable demos live in the [examples repo](https://github.com/soroush-tech/examples/tree/main/styled-system).\n\n## Release notes\n\nPer-version notes for every published release live in\n[`release-notes/`](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/release-notes).\n\n## License\n\nMIT - a rewrite of styled-system (© 2017-2021 Brent Jackson), see [`LICENSE`](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/LICENSE).\n",
|
|
1392
1392
|
"url": "https://docs.soroush.tech/styled-system/"
|
|
1393
1393
|
},
|
|
1394
1394
|
{
|
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@ let _modelcontextprotocol_sdk_server_mcp_js = require("@modelcontextprotocol/sdk
|
|
|
3
3
|
let zod = require("zod");
|
|
4
4
|
// src/content.ts
|
|
5
5
|
const content = {
|
|
6
|
-
"version": "
|
|
6
|
+
"version": "3.0.0-alpha.0",
|
|
7
7
|
"components": [
|
|
8
8
|
{
|
|
9
9
|
"name": "ScrollArea",
|
|
@@ -1321,7 +1321,7 @@ const content = {
|
|
|
1321
1321
|
"id": "installation",
|
|
1322
1322
|
"title": "Installation",
|
|
1323
1323
|
"summary": "Install the packages and their peer dependencies.",
|
|
1324
|
-
"body": "# Installation\n\nInstall the design system and its peer dependencies:\n\n```sh\nnpm i @soroush.tech/design-system react react-dom\n```\n\n
|
|
1324
|
+
"body": "# Installation\n\n## Start a new app\n\nTo start a new app on the design system - a Vike app, prerendered at build time, that then moves\nbetween pages with no reload - in TypeScript or JavaScript:\n\n```sh\nnpx @soroush.design/cli create my-app\n```\n\nIt makes the app in a new folder, with the themes, the providers and a few pages, shows every file\nfirst, and installs it with the package manager you ran it with. Add `--sample-data`, or answer\nyes to its question, for two pages that show how data gets onto a page: a list of sample items,\nand a page for each. Its options are in the\n[command line](/cli/) docs. For an app you already have, use `init`, below.\n\n## Set it up with one command\n\nIn a client-rendered React app - built with Vite, webpack, Rspack, Parcel or Create React App,\nin TypeScript or JavaScript - one command sets the design system up:\n\n```sh\nnpx @soroush.design/cli init\n```\n\nIt shows every change before it makes one, and writes nothing until you say yes:\n\n- `src/theme/themes` - a `light` and a `dark` theme, each a `createTheme(baseTheme, {...})` call\n you make your own;\n- `src/theme/Providers` - the `ThemeProvider` with the base page styles;\n- your root - what it renders is wrapped in `<Providers>`;\n- the install of `@soroush.tech/design-system`, with your own package manager.\n\nIt runs in a git repository with no uncommitted change, never overwrites a file, and takes back\nevery change if a write fails. Run in a workspace's root, it sets up the one app in it. Add\n`--dry-run` to see the changes and exit. In PowerShell, quote the package name, since `@` starts a\nsplat there: `npx '@soroush.design/cli' init`.\n\nEvery option, and what `init` checks first, are in the [command line](/cli/) docs. Next.js, Vike\nand React Router apps are not supported by `init` yet: set those up by hand, below.\n\n## Or set it up by hand\n\nInstall the design system and its peer dependencies:\n\n```sh\nnpm i @soroush.tech/design-system react react-dom\n```\n\nReact 19.2 or later is required.\n\n### Set up the ThemeProvider\n\nEvery component reads its colors, spacing, and typography from the theme. Wrap your app once:\n\n```tsx\nimport { ThemeProvider, baseTheme, createTheme } from '@soroush.tech/design-system/theme'\n\nconst theme = createTheme(baseTheme, {\n // Your brand overrides - palettes, backgrounds, text colors, ...\n})\n\nexport function App() {\n return <ThemeProvider theme={theme}>{/* your app */}</ThemeProvider>\n}\n```\n\n`baseTheme` is a complete dark-schemed default, so an empty override object is a valid start.\nSee [Theming](/design-system/customization/theming/) for building light and dark brand themes.\n\n## Fonts\n\nThe theme's default stacks reference Space Grotesk (body) and JetBrains Mono (code). Self-host\nthem with Fontsource, or swap the `fonts` scale to your own faces:\n\n```sh\nnpm i @fontsource-variable/space-grotesk @fontsource-variable/jetbrains-mono\n```\n\n```ts\nimport '@fontsource-variable/space-grotesk/wght.css'\nimport '@fontsource-variable/jetbrains-mono/wght.css'\n```\n",
|
|
1325
1325
|
"url": "https://docs.soroush.tech/design-system/getting-started/installation/"
|
|
1326
1326
|
},
|
|
1327
1327
|
{
|
|
@@ -1335,21 +1335,21 @@ const content = {
|
|
|
1335
1335
|
"id": "theming",
|
|
1336
1336
|
"title": "Theming",
|
|
1337
1337
|
"summary": "The Theme type, the scales it carries, and how createTheme composes one.",
|
|
1338
|
-
"body": "# Theming\n\nThe theme belongs to you - the package ships defaults, every part is replaceable, and the type system widens with your extensions. This guide covers the full ladder, from using the built-ins to owning every token.\n\n## The ladder\n\n1. **Use the default** - `<ThemeProvider>` with no props renders the built-in `baseTheme` (dark-schemed).\n2. **Override values** - build your theme with `createTheme(base, overrides)` and pass it via `theme`.\n3. **Repoint component defaults** - `theme.defaults` / the provider's `defaults` prop change what components fall back to.\n4. **Extend the type system** - declaration merging adds palette colors, scale keys, and whole scales.\n5. **Customize single components** - `theme.components` (see [customization.md](./customization.md)).\n\n---\n\n## One theme, yours\n\n`ThemeProvider` provides exactly one theme. The package ships a single complete default - `baseTheme` - and you derive every mode from it; switching (dark/light, or ten brand modes) is your state:\n\n```tsx\nimport { ThemeProvider } from '@soroush.tech/design-system/theme'\nimport { baseTheme, createTheme } from '@soroush.tech/design-system/theme'\n\nconst dark = createTheme(baseTheme, { name: 'dark' /* your palettes */ })\nconst light = createTheme(baseTheme, { name: 'light', colorScheme: 'light' /* your palettes */ })\n\nconst [isDark, setIsDark] = useState(true)\n<ThemeProvider theme={isDark ? dark : light}>{app}</ThemeProvider>\n```\n\n## Building themes with `createTheme`\n\n`createTheme(base, overrides)` deep-merges sparse patches onto a base theme:\n\n```ts\nimport { baseTheme, createTheme } from '@soroush.tech/design-system/theme'\n\nexport const brandDark = createTheme(baseTheme, {\n palette: { primary: { main: '#00ff88' } }, // sibling fields (light/dark/contrastText) survive\n radii: { md: '10px' },\n shadows: ['none'], // arrays replace wholesale, never merge\n})\n```\n\nMerge rules: plain objects recurse; arrays (`shadows`, `fontSizes`) and functions replace wholesale; `undefined` values are ignored - keys are added or replaced, never removed. Neither argument is mutated.\n\n## Component defaults (`theme.defaults`)\n\nComponents carry visible literal fallbacks (`size = 'md'`, `variant = 'outside'`, ...) resolved through `themeDefault(theme, key, fallback)`. The optional `theme.defaults` map overrides any of them globally - essential when your theme uses entirely different size or palette keys:\n\n```tsx\n<ThemeProvider defaults={{ size: 'compact', color: 'brand', switchVariant: 'inside' }}>\n```\n\nThe full key table lives in the [README's Theming section](../README.md#component-defaults). The built-in `baseTheme` carries no `defaults` - the literals apply until you say otherwise. For _per-component_ defaults (only Buttons compact), use `theme.components.X.defaultProps` instead ([customization.md](./customization.md)).\n\n## Extending the type system\n\nEvery scale is an open interface owned by `@soroush.tech/design-system/theme` - that module (not Emotion, an internal implementation detail) is the augmentation surface, and it merges reliably across tsdown's chunked d.ts for every consumer:\n\n```ts\nimport type { PaletteEntry, SizeEntry } from '@soroush.tech/design-system/theme'\n\ndeclare module '@soroush.tech/design-system/theme' {\n interface ThemePalette {\n brand: PaletteEntry // new palette color\n }\n interface ThemeBackground {\n tertiary: string // new background token\n }\n interface ThemeSizes {\n xl: SizeEntry // new size step\n }\n interface Theme {\n elevations: Record<'low' | 'mid' | 'high', string> // whole new scale\n }\n}\n```\n\nComponent prop unions derive via `keyof Theme['scale']`, so `color=\"brand\"`, `bg=\"tertiary\"`, and `size=\"xl\"` typecheck everywhere automatically. Then supply the values:\n\n```ts\nconst brand = createTheme(baseTheme, {\n palette: { brand: { main: '#00ff88', light: '#66ffb2', dark: '#00b25f', contrastText: '#000' } },\n background: { tertiary: '#101418' },\n sizes: { xl: { paddingTop: 2, paddingBottom: 2, paddingLeft: 4, paddingRight: 4, fontSize: 2 } },\n elevations: { low: '0 1px 2px', mid: '0 2px 6px', high: '0 6px 18px' },\n defaults: { size: 'xl' }, // components may default to augmented keys\n})\n```\n\nTwo rules: new object-valued keys (like a `PaletteEntry`) must be supplied complete - components read `.main`/`.contrastText` at runtime; and TypeScript cannot verify at runtime that an augmented token was supplied - **always pair an augmentation with the matching override**.\n\n## Breakpoints and layout\n\n`theme.breakpoints` and `theme.layout` hold the page's layout system: where it changes, how many\ncolumns it has, its margins and gutters, its side panels and the top bar. Everything responsive is\nCSS - no component measures the window in JavaScript - so a prerendered page lays out the same\nwith JavaScript off. The design system ships these as tokens and building blocks (`AppBar`,\n`Sidebar`, `Drawer`, `Grid`, `Flex`); each app composes its own pages from them.\n\n### `theme.breakpoints` - window classes\n\nEach key is a range: its value is where the range starts, and it holds until the next key. The\ntheme writes the start because media queries are min-width. `xs` starts at 0, so it applies\neverywhere until `sm` overrides it.\n\n```ts\nbreakpoints: { xs: '0px', sm: '600px', md: '840px', lg: '1200px', xl: '1600px' }\n```\n\n| Key | Range | Material 3 window class |\n| ---- | ----------- | ----------------------- |\n| `xs` | 0-599px | compact |\n| `sm` | 600-839px | medium |\n| `md` | 840-1199px | expanded |\n| `lg` | 1200-1599px | large |\n| `xl` | 1600px+ | extra-large |\n\nThey are window classes, not devices: a class is about the space the window has. Responsive props\nuse them by name - each key from its size up - or by position:\n\n```tsx\n<View display={{ xs: 'none', md: 'block' }} />\n<View p={[2, 3, 4]} /> // xs, sm, md\n<View p={{ xs: 2, cqSm: 4 }} /> // cq keys: container queries on the same sizes\n```\n\nFor hand-written styles, `theme.breakpoints` carries the query helpers (also exported for\n`baseTheme` as `up`, `down`, `only`, `between`, `not` and `containerQueries`):\n\n```ts\nconst Panel = styled.div(({ theme }) => ({\n padding: 16,\n [theme.breakpoints.down('sm')]: { padding: 8 }, // @media (width < 600px)\n [theme.breakpoints.only('md')]: { padding: 24 }, // @media (840px <= width < 1200px)\n}))\n```\n\nEvery form, the container queries, the units and the order blocks are written in are covered in\nthe styled-system [Breakpoints](https://docs.soroush.tech/styled-system/docs/breakpoints/) guide.\n\n### `theme.layout` - layout tokens per window class\n\n`xs` is complete; each later class lists only what changes and is merged over the ones before it.\nWith `baseTheme`:\n\n| Class | Columns | Margin / gutter | Content | Start panel | End panel | Top bar |\n| ----- | ------- | --------------- | ---------- | ----------- | ----------- | ------- |\n| `xs` | 4 | 16 / 16 | fluid | hidden | hidden | 64 |\n| `sm` | 8 | 32 / 16 | fluid | rail 72 | hidden | 64 |\n| `md` | 12 | 24 / 24 | fluid | rail 72 | overlay 360 | 64 |\n| `lg` | 12 | 24 / 24 | fixed 1200 | rail 72 | overlay 412 | 64 |\n| `xl` | 12 | 24 / 24 | fixed 1600 | inline 280 | inline 412 | 64 |\n\n- **Units** - `margin` and `gutter` are `theme.space` keys, so they move with the spacing scale.\n Bar heights, panel widths and `maxWidth` take a space key or any CSS length.\n- **Columns** - 1 to 16. 12 is the default from `md` up.\n- **Panels** - `start` and `end` follow the writing direction (they swap in RTL). `mode` is\n `inline` (beside the content at `width`), `collapsed` (a rail at `railWidth`), `overlay` (over\n the content at `width`) or `hidden`. A panel first declared at a later class needs its `mode`,\n `width` and `railWidth` there.\n- **Bars** - `top` (and an optional `bottom`) heights; `0` removes an inherited bar.\n\nThese are tokens: the app places its own `AppBar`, `Sidebar` and `Drawer` with them, and the\ndesign studio draws them on its frames.\n\n### The `layout` prop - the page frame everywhere, the columns on a Grid\n\n`layout` turns the content tokens into CSS per window class. On any `View`-based component -\n`Flex` included - it is the **frame**: the margin and the max width, and the element keeps its\nown display. `Grid` adds the **columns** on top of that frame:\n\n```tsx\n<View layout>...</View> // the theme's frame\n<Flex layout gap={3}>...</Flex> // the frame, a flex column inside\n<Grid layout>...</Grid> // the frame and the theme's columns\n<Grid layout gap={2}>...</Grid> // its own gutter: 16px at every class\n<Grid layout gap={{ xs: 2, md: 4 }}>...</Grid> // 16px, then 32px from md up\n<Grid layout={{ lg: { columns: 16 } }}>...</Grid> // 16 columns from lg up\n<Grid layout={{ maxWidth: '1280px', md: { columns: 6 } }}>...</Grid> // both\n```\n\n- **The frame** - the full width of its parent (`width: 100%`, border-box) with the margin as\n `padding-inline`; in fixed mode capped by `max-width` and centred. It spans its parent in any\n context - a block, a grid item, a flex column or row - so the frame owns its width: size it\n with `maxWidth`, not `width`.\n- **Grid** - `grid-template-columns: repeat(N, minmax(0, 1fr))` and the gutter as `column-gap`.\n- **The gutter is the grid's `gap`** - its own `gap` or `columnGap` (`columnGap` wins), single,\n per class (`{ md: 4 }`) or as an array, sets `column-gap` at every class it covers; where it is\n not set, the theme's gutter applies. Rows take `gap`'s row half or `rowGap`. On a `Flex` or a\n `View`, `gap` is plain flexbox spacing.\n- **Children take `span`** - how many columns of a grid an element takes, on any `View`-based\n component: `span={6}`, per class `span={{ xs: 4, md: 6 }}`, or `span=\"full\"` for the whole row\n whatever the column count (`grid-column: 1 / -1`, in any grid).\n- A field in the value (`maxWidth: '1280px'`) replaces the theme's at every class; whatever it\n does not set still follows the theme. An entry under a class name replaces it **from that class\n up**, mobile-first like every responsive prop, on top of the fields.\n- **The layout owns the column tracks, inline padding and max width** it writes: an explicit\n `gridTemplateColumns`, padding or `maxWidth` on the same element does not override them from the\n second class up. A grid with tracks of its own leaves `layout` off and sits inside a frame.\n\n### Layout: one way per intent\n\nGenerated code, agents and people write each layout intent one way:\n\n| Intent | Write | Not |\n| ------------------------------------------------ | ----------------------------------------------------------- | --------------------------------------------------------- |\n| Content on the page frame, no columns | `<View layout>`, or `<Flex layout>` for a flex stack or row | `maxWidth` + `mx=\"auto\"` + `px`, a custom frame component |\n| A section on the theme's columns | `<Grid layout>` | hand-written tracks on a page section, `Flex` with widths |\n| The app's layout | `theme.layout`, built with `createTheme` | layout values written on every page |\n| A page's (or a region's) own layout | `<LayoutProvider layout={...}>` around the page | the same `layout` value on each section, a nested theme |\n| A section's own columns, margin or max width | `layout={{ md: { columns: 6 } }}`, `layout={{ maxWidth }}` | helpers that repeat a value per class |\n| A section's own gutter | `gap={2}` / `gap={{ xs: 2, md: 4 }}` on the `Grid` | a `gutter` field, `gap` and `columnGap` both |\n| A child taking N columns | `span={6}` / `span={{ xs: 4, md: 6 }}` | `gridColumn=\"span 6\"` |\n| A child taking the whole row | `span=\"full\"` | `grid-column: 1 / -1`, `style`, column-count objects |\n| Space between rows only | `rowGap` | margins on the children |\n| A grid with tracks of its own (`auto-fill`, ...) | a plain `Grid` without `layout`, inside a frame | `layout` plus `gridTemplateColumns` |\n\nThe same page without the prop needs every value written out - and stops following the theme:\n\n```tsx\n<Grid\n gridTemplateColumns={{\n xs: 'repeat(4, minmax(0, 1fr))',\n sm: 'repeat(8, minmax(0, 1fr))',\n md: 'repeat(12, minmax(0, 1fr))',\n }}\n columnGap={{ xs: 2, md: 3 }}\n px={{ xs: 2, sm: 4, md: 3 }}\n>\n ...\n</Grid>\n```\n\n### Your own breakpoints and layout\n\nOverride values with `createTheme`, like any scale:\n\n```ts\nconst theme = createTheme(baseTheme, {\n breakpoints: { md: '900px' },\n layout: { lg: { content: { maxWidth: '1280px' } } },\n})\n```\n\nThe helpers on `theme.breakpoints` are rebuilt from the merged sizes. `createTheme` merges, so\nit can change values and add a larger breakpoint after the existing ones, but not remove or rename\none. To use your own names, declare them by augmenting `BreakpointOverrides` (`true` adds a name,\n`false` removes a default) and replace the scale and the layout on the base:\n\n```ts\ndeclare module '@soroush.tech/design-system/theme' {\n interface BreakpointOverrides {\n mobile: true\n tablet: true\n web: true\n xs: false\n sm: false\n md: false\n lg: false\n xl: false\n }\n}\n\nconst theme = createTheme(\n {\n ...baseTheme,\n breakpoints: withBreakpointHelpers({ mobile: '0px', tablet: '768px', web: '1280px' }),\n layout: { mobile: { ...a complete entry... }, tablet: { ... }, web: { ... } },\n },\n {}\n)\n```\n\nResponsive props, `cq` keys (`cqTablet`), the helpers and the `layout` keys all follow the new\nnames.\n\n## The scale interfaces\n\n| Scale | Key in Theme | Interface |\n| --------------- | ---------------------- | ------------------------- |\n| Palette | `theme.palette` | `ThemePalette` |\n| Text colors | `theme.text` | `ThemeText` |\n| Backgrounds | `theme.background` | `ThemeBackground` |\n| Borders | `theme.border` | `ThemeBorder` |\n| Space | `theme.space` | `ThemeSpace` |\n| Breakpoints | `theme.breakpoints` | `ThemeBreakpoints` |\n| Layout | `theme.layout` | `ThemeLayout` |\n| Sizes | `theme.sizes` | `ThemeSizes` |\n| Radii | `theme.radii` | `ThemeRadii` |\n| Border widths | `theme.borderWidths` | `ThemeBorderWidths` |\n| Fonts | `theme.fonts` | `ThemeFonts` |\n| Font weights | `theme.fontWeights` | `ThemeFontWeights` |\n| Line heights | `theme.lineHeights` | `ThemeLineHeights` |\n| Letter spacings | `theme.letterSpacings` | `ThemeLetterSpacings` |\n| Typography | `theme.typography` | `ThemeTypographyVariants` |\n| Avatar sizes | `theme.avatar` | `ThemeAvatarSizes` |\n| Icon sizes | `theme.icon` | `ThemeIconSizes` |\n| Switch tokens | `theme.switch` | `ThemeSwitch` |\n| Shadow tokens | `theme.shadow` | `ThemeShadow` |\n\n## The spacing scale\n\n`theme.space` steps on an 8px unit, and every step is a whole pixel. The same steps serve padding,\nmargin, `gap` / `rowGap` / `columnGap`, the `layout` margin and the grid's gutter:\n\n| Step | `0` | `0.125` | `0.25` | `0.5` | `0.75` | `1` | `1.25` | `1.5` | `1.75` | `2` | `3` | `4` | `5` | `6` | `7` | `8` | `9` | `10` |\n| ---- | --- | ------- | ------ | ----- | ------ | --- | ------ | ----- | ------ | --- | --- | --- | --- | --- | --- | --- | --- | ---- |\n| px | 0 | 1 | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 24 | 32 | 40 | 48 | 56 | 64 | 72 | 80 |\n\nBelow 4px, lines are border widths (`theme.borderWidths`). Use `0.125` and `0.25` only for a gap\nthat should be a hairline - a 1px or 2px gap the background shows through, as in a grid of tiles\non a coloured `Grid`: `<Grid layout gap={0.125} bg=\"grid\">`.\n| Defaults | `theme.defaults` | `ThemeDefaults` |\n| Components | `theme.components` | `ThemeComponents` |\n\nThe contract is verified against the real published d.ts by `type-tests/augmentation.ts` (`pnpm test:types`), so it can't silently break in a release.\n",
|
|
1338
|
+
"body": "# Theming\n\nThe theme belongs to you - the package ships defaults, every part is replaceable, and the type system widens with your extensions. This guide covers the full ladder, from using the built-ins to owning every token.\n\n## The ladder\n\n1. **Use the default** - `<ThemeProvider>` with no props renders the built-in `baseTheme` (dark-schemed).\n2. **Override values** - build your theme with `createTheme(base, overrides)` and pass it via `theme`.\n3. **Repoint component defaults** - `theme.defaults` / the provider's `defaults` prop change what components fall back to.\n4. **Extend the type system** - declaration merging adds palette colors, scale keys, and whole scales.\n5. **Customize single components** - `theme.components` (see [customization.md](./customization.md)).\n\n---\n\n## One theme, yours\n\n`ThemeProvider` provides exactly one theme. The package ships a single complete default - `baseTheme` - and you derive every mode from it; switching (dark/light, or ten brand modes) is your state:\n\n```tsx\nimport { ThemeProvider } from '@soroush.tech/design-system/theme'\nimport { baseTheme, createTheme } from '@soroush.tech/design-system/theme'\n\nconst dark = createTheme(baseTheme, { name: 'dark' /* your palettes */ })\nconst light = createTheme(baseTheme, { name: 'light', colorScheme: 'light' /* your palettes */ })\n\nconst [isDark, setIsDark] = useState(true)\n<ThemeProvider theme={isDark ? dark : light}>{app}</ThemeProvider>\n```\n\n## Building themes with `createTheme`\n\n`createTheme(base, overrides)` deep-merges sparse patches onto a base theme:\n\n```ts\nimport { baseTheme, createTheme } from '@soroush.tech/design-system/theme'\n\nexport const brandDark = createTheme(baseTheme, {\n palette: { primary: { main: '#00ff88' } }, // sibling fields (light/dark/contrastText) survive\n radii: { md: '10px' },\n shadows: ['none'], // arrays replace wholesale, never merge\n})\n```\n\nMerge rules: plain objects recurse; arrays (`shadows`, `fontSizes`) and functions replace wholesale; `undefined` values are ignored - keys are added or replaced, never removed. Neither argument is mutated.\n\n## Component defaults (`theme.defaults`)\n\nComponents carry visible literal fallbacks (`size = 'md'`, `variant = 'outside'`, ...) resolved through `themeDefault(theme, key, fallback)`. The optional `theme.defaults` map overrides any of them globally - essential when your theme uses entirely different size or palette keys:\n\n```tsx\n<ThemeProvider defaults={{ size: 'compact', color: 'brand', switchVariant: 'inside' }}>\n```\n\nThe full key table lives in the [README's Theming section](../README.md#component-defaults). The built-in `baseTheme` carries no `defaults` - the literals apply until you say otherwise. For _per-component_ defaults (only Buttons compact), use `theme.components.X.defaultProps` instead ([customization.md](./customization.md)).\n\n## Extending the type system\n\nEvery scale is an open interface owned by `@soroush.tech/design-system/theme` - that module (not the styling engine, an internal implementation detail) is the augmentation surface, and it merges reliably across tsdown's chunked d.ts for every consumer:\n\n```ts\nimport type { PaletteEntry, SizeEntry } from '@soroush.tech/design-system/theme'\n\ndeclare module '@soroush.tech/design-system/theme' {\n interface ThemePalette {\n brand: PaletteEntry // new palette color\n }\n interface ThemeBackground {\n tertiary: string // new background token\n }\n interface ThemeSizes {\n xl: SizeEntry // new size step\n }\n interface Theme {\n elevations: Record<'low' | 'mid' | 'high', string> // whole new scale\n }\n}\n```\n\nComponent prop unions derive via `keyof Theme['scale']`, so `color=\"brand\"`, `bg=\"tertiary\"`, and `size=\"xl\"` typecheck everywhere automatically. Then supply the values:\n\n```ts\nconst brand = createTheme(baseTheme, {\n palette: { brand: { main: '#00ff88', light: '#66ffb2', dark: '#00b25f', contrastText: '#000' } },\n background: { tertiary: '#101418' },\n sizes: { xl: { paddingTop: 2, paddingBottom: 2, paddingLeft: 4, paddingRight: 4, fontSize: 2 } },\n elevations: { low: '0 1px 2px', mid: '0 2px 6px', high: '0 6px 18px' },\n defaults: { size: 'xl' }, // components may default to augmented keys\n})\n```\n\nTwo rules: new object-valued keys (like a `PaletteEntry`) must be supplied complete - components read `.main`/`.contrastText` at runtime; and TypeScript cannot verify at runtime that an augmented token was supplied - **always pair an augmentation with the matching override**.\n\n## Breakpoints and layout\n\n`theme.breakpoints` and `theme.layout` hold the page's layout system: where it changes, how many\ncolumns it has, its margins and gutters, its side panels and the top bar. Everything responsive is\nCSS - no component measures the window in JavaScript - so a prerendered page lays out the same\nwith JavaScript off. The design system ships these as tokens and building blocks (`AppBar`,\n`Sidebar`, `Drawer`, `Grid`, `Flex`); each app composes its own pages from them.\n\n### `theme.breakpoints` - window classes\n\nEach key is a range: its value is where the range starts, and it holds until the next key. The\ntheme writes the start because media queries are min-width. `xs` starts at 0, so it applies\neverywhere until `sm` overrides it.\n\n```ts\nbreakpoints: { xs: '0px', sm: '600px', md: '840px', lg: '1200px', xl: '1600px' }\n```\n\n| Key | Range | Material 3 window class |\n| ---- | ----------- | ----------------------- |\n| `xs` | 0-599px | compact |\n| `sm` | 600-839px | medium |\n| `md` | 840-1199px | expanded |\n| `lg` | 1200-1599px | large |\n| `xl` | 1600px+ | extra-large |\n\nThey are window classes, not devices: a class is about the space the window has. Responsive props\nuse them by name - each key from its size up - or by position:\n\n```tsx\n<View display={{ xs: 'none', md: 'block' }} />\n<View p={[2, 3, 4]} /> // xs, sm, md\n<View p={{ xs: 2, cqSm: 4 }} /> // cq keys: container queries on the same sizes\n```\n\nFor hand-written styles, `theme.breakpoints` carries the query helpers (also exported for\n`baseTheme` as `up`, `down`, `only`, `between`, `not` and `containerQueries`):\n\n```ts\nconst Panel = styled.div(({ theme }) => ({\n padding: 16,\n [theme.breakpoints.down('sm')]: { padding: 8 }, // @media (width < 600px)\n [theme.breakpoints.only('md')]: { padding: 24 }, // @media (840px <= width < 1200px)\n}))\n```\n\nEvery form, the container queries, the units and the order blocks are written in are covered in\nthe styled-system [Breakpoints](https://docs.soroush.tech/styled-system/docs/breakpoints/) guide.\n\n### `theme.layout` - layout tokens per window class\n\n`xs` is complete; each later class lists only what changes and is merged over the ones before it.\nWith `baseTheme`:\n\n| Class | Columns | Margin / gutter | Content | Start panel | End panel | Top bar |\n| ----- | ------- | --------------- | ---------- | ----------- | ----------- | ------- |\n| `xs` | 4 | 16 / 16 | fluid | hidden | hidden | 64 |\n| `sm` | 8 | 32 / 16 | fluid | rail 72 | hidden | 64 |\n| `md` | 12 | 24 / 24 | fluid | rail 72 | overlay 360 | 64 |\n| `lg` | 12 | 24 / 24 | fixed 1200 | rail 72 | overlay 412 | 64 |\n| `xl` | 12 | 24 / 24 | fixed 1600 | inline 280 | inline 412 | 64 |\n\n- **Units** - `margin` and `gutter` are `theme.space` keys, so they move with the spacing scale.\n Bar heights, panel widths and `maxWidth` take a space key or any CSS length.\n- **Columns** - 1 to 16. 12 is the default from `md` up.\n- **Panels** - `start` and `end` follow the writing direction (they swap in RTL). `mode` is\n `inline` (beside the content at `width`), `collapsed` (a rail at `railWidth`), `overlay` (over\n the content at `width`) or `hidden`. A panel first declared at a later class needs its `mode`,\n `width` and `railWidth` there.\n- **Bars** - `top` (and an optional `bottom`) heights; `0` removes an inherited bar.\n\nThese are tokens: the app places its own `AppBar`, `Sidebar` and `Drawer` with them, and the\ndesign studio draws them on its frames.\n\n### The `layout` prop - the page frame everywhere, the columns on a Grid\n\n`layout` turns the content tokens into CSS per window class. On any `View`-based component -\n`Flex` included - it is the **frame**: the margin and the max width, and the element keeps its\nown display. `Grid` adds the **columns** on top of that frame:\n\n```tsx\n<View layout>...</View> // the theme's frame\n<Flex layout gap={3}>...</Flex> // the frame, a flex column inside\n<Grid layout>...</Grid> // the frame and the theme's columns\n<Grid layout gap={2}>...</Grid> // its own gutter: 16px at every class\n<Grid layout gap={{ xs: 2, md: 4 }}>...</Grid> // 16px, then 32px from md up\n<Grid layout={{ lg: { columns: 16 } }}>...</Grid> // 16 columns from lg up\n<Grid layout={{ maxWidth: '1280px', md: { columns: 6 } }}>...</Grid> // both\n```\n\n- **The frame** - the full width of its parent (`width: 100%`, border-box) with the margin as\n `padding-inline`; in fixed mode capped by `max-width` and centred. It spans its parent in any\n context - a block, a grid item, a flex column or row - so the frame owns its width: size it\n with `maxWidth`, not `width`.\n- **Grid** - `grid-template-columns: repeat(N, minmax(0, 1fr))` and the gutter as `column-gap`.\n- **The gutter is the grid's `gap`** - its own `gap` or `columnGap` (`columnGap` wins), single,\n per class (`{ md: 4 }`) or as an array, sets `column-gap` at every class it covers; where it is\n not set, the theme's gutter applies. Rows take `gap`'s row half or `rowGap`. On a `Flex` or a\n `View`, `gap` is plain flexbox spacing.\n- **Children take `span`** - how many columns of a grid an element takes, on any `View`-based\n component: `span={6}`, per class `span={{ xs: 4, md: 6 }}`, or `span=\"full\"` for the whole row\n whatever the column count (`grid-column: 1 / -1`, in any grid).\n- A field in the value (`maxWidth: '1280px'`) replaces the theme's at every class; whatever it\n does not set still follows the theme. An entry under a class name replaces it **from that class\n up**, mobile-first like every responsive prop, on top of the fields.\n- **The layout owns the column tracks, inline padding and max width** it writes: an explicit\n `gridTemplateColumns`, padding or `maxWidth` on the same element does not override them from the\n second class up. A grid with tracks of its own leaves `layout` off and sits inside a frame.\n\n### Layout: one way per intent\n\nGenerated code, agents and people write each layout intent one way:\n\n| Intent | Write | Not |\n| ------------------------------------------------ | ----------------------------------------------------------- | --------------------------------------------------------- |\n| Content on the page frame, no columns | `<View layout>`, or `<Flex layout>` for a flex stack or row | `maxWidth` + `mx=\"auto\"` + `px`, a custom frame component |\n| A section on the theme's columns | `<Grid layout>` | hand-written tracks on a page section, `Flex` with widths |\n| The app's layout | `theme.layout`, built with `createTheme` | layout values written on every page |\n| A page's (or a region's) own layout | `<LayoutProvider layout={...}>` around the page | the same `layout` value on each section, a nested theme |\n| A section's own columns, margin or max width | `layout={{ md: { columns: 6 } }}`, `layout={{ maxWidth }}` | helpers that repeat a value per class |\n| A section's own gutter | `gap={2}` / `gap={{ xs: 2, md: 4 }}` on the `Grid` | a `gutter` field, `gap` and `columnGap` both |\n| A child taking N columns | `span={6}` / `span={{ xs: 4, md: 6 }}` | `gridColumn=\"span 6\"` |\n| A child taking the whole row | `span=\"full\"` | `grid-column: 1 / -1`, `style`, column-count objects |\n| Space between rows only | `rowGap` | margins on the children |\n| A grid with tracks of its own (`auto-fill`, ...) | a plain `Grid` without `layout`, inside a frame | `layout` plus `gridTemplateColumns` |\n\nThe same page without the prop needs every value written out - and stops following the theme:\n\n```tsx\n<Grid\n gridTemplateColumns={{\n xs: 'repeat(4, minmax(0, 1fr))',\n sm: 'repeat(8, minmax(0, 1fr))',\n md: 'repeat(12, minmax(0, 1fr))',\n }}\n columnGap={{ xs: 2, md: 3 }}\n px={{ xs: 2, sm: 4, md: 3 }}\n>\n ...\n</Grid>\n```\n\n### Your own breakpoints and layout\n\nOverride values with `createTheme`, like any scale:\n\n```ts\nconst theme = createTheme(baseTheme, {\n breakpoints: { md: '900px' },\n layout: { lg: { content: { maxWidth: '1280px' } } },\n})\n```\n\nThe helpers on `theme.breakpoints` are rebuilt from the merged sizes. `createTheme` merges, so\nit can change values and add a larger breakpoint after the existing ones, but not remove or rename\none. To use your own names, declare them by augmenting `BreakpointOverrides` (`true` adds a name,\n`false` removes a default) and replace the scale and the layout on the base:\n\n```ts\ndeclare module '@soroush.tech/design-system/theme' {\n interface BreakpointOverrides {\n mobile: true\n tablet: true\n web: true\n xs: false\n sm: false\n md: false\n lg: false\n xl: false\n }\n}\n\nconst theme = createTheme(\n {\n ...baseTheme,\n breakpoints: withBreakpointHelpers({ mobile: '0px', tablet: '768px', web: '1280px' }),\n layout: { mobile: { ...a complete entry... }, tablet: { ... }, web: { ... } },\n },\n {}\n)\n```\n\nResponsive props, `cq` keys (`cqTablet`), the helpers and the `layout` keys all follow the new\nnames.\n\n## The scale interfaces\n\n| Scale | Key in Theme | Interface |\n| --------------- | ---------------------- | ------------------------- |\n| Palette | `theme.palette` | `ThemePalette` |\n| Text colors | `theme.text` | `ThemeText` |\n| Backgrounds | `theme.background` | `ThemeBackground` |\n| Borders | `theme.border` | `ThemeBorder` |\n| Space | `theme.space` | `ThemeSpace` |\n| Breakpoints | `theme.breakpoints` | `ThemeBreakpoints` |\n| Layout | `theme.layout` | `ThemeLayout` |\n| Sizes | `theme.sizes` | `ThemeSizes` |\n| Radii | `theme.radii` | `ThemeRadii` |\n| Border widths | `theme.borderWidths` | `ThemeBorderWidths` |\n| Fonts | `theme.fonts` | `ThemeFonts` |\n| Font weights | `theme.fontWeights` | `ThemeFontWeights` |\n| Line heights | `theme.lineHeights` | `ThemeLineHeights` |\n| Letter spacings | `theme.letterSpacings` | `ThemeLetterSpacings` |\n| Typography | `theme.typography` | `ThemeTypographyVariants` |\n| Avatar sizes | `theme.avatar` | `ThemeAvatarSizes` |\n| Icon sizes | `theme.icon` | `ThemeIconSizes` |\n| Switch tokens | `theme.switch` | `ThemeSwitch` |\n| Shadow tokens | `theme.shadow` | `ThemeShadow` |\n\n## The spacing scale\n\n`theme.space` steps on an 8px unit, and every step is a whole pixel. The same steps serve padding,\nmargin, `gap` / `rowGap` / `columnGap`, the `layout` margin and the grid's gutter:\n\n| Step | `0` | `0.125` | `0.25` | `0.5` | `0.75` | `1` | `1.25` | `1.5` | `1.75` | `2` | `3` | `4` | `5` | `6` | `7` | `8` | `9` | `10` |\n| ---- | --- | ------- | ------ | ----- | ------ | --- | ------ | ----- | ------ | --- | --- | --- | --- | --- | --- | --- | --- | ---- |\n| px | 0 | 1 | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 24 | 32 | 40 | 48 | 56 | 64 | 72 | 80 |\n\nBelow 4px, lines are border widths (`theme.borderWidths`). Use `0.125` and `0.25` only for a gap\nthat should be a hairline - a 1px or 2px gap the background shows through, as in a grid of tiles\non a coloured `Grid`: `<Grid layout gap={0.125} bg=\"grid\">`.\n| Defaults | `theme.defaults` | `ThemeDefaults` |\n| Components | `theme.components` | `ThemeComponents` |\n\nThe contract is verified against the real published d.ts by `type-tests/augmentation.ts` (`pnpm test:types`), so it can't silently break in a release.\n",
|
|
1339
1339
|
"url": "https://docs.soroush.tech/design-system/customization/theming/"
|
|
1340
1340
|
},
|
|
1341
1341
|
{
|
|
1342
1342
|
"id": "customization",
|
|
1343
1343
|
"title": "How to customize",
|
|
1344
1344
|
"summary": "Override component styles through theme.components and style props.",
|
|
1345
|
-
"body": "# Per-component customization (`theme.components`)\n\nCustomize one component for the whole app - default prop values, per-slot CSS, and new variant values - without wrapping or forking. Zero-config themes pay nothing: the resolver bails out on its first check when `theme.components` is absent.\n\n```ts\nconst brand = createTheme(baseTheme, {\n components: {\n Button: {\n defaultProps: { size: 'sm', shape: 'rounded' },\n styleOverrides: {\n root: ({ theme, ownerState }) => ({\n letterSpacing: theme.letterSpacings.wide,\n ...(ownerState.variant === 'contained' && { textTransform: 'none' }),\n }),\n label: { fontStyle: 'italic' },\n },\n variants: [\n {\n props: { variant: 'dashed' },\n style: ({ theme }) => ({\n backgroundColor: 'transparent',\n border: `${theme.borderWidths.thin} dashed ${theme.border.primary}`,\n }),\n },\n ],\n },\n },\n})\n```\n\nThe `Theme/Customization` Storybook story renders all three mechanisms under a customized theme and is locked by Chromatic - it is the living contract.\n\nEvery styled element is registered - the `ThemeComponents` interface in `src/theme/themes.ts` is the authoritative key/slot list, so `styleOverrides` reaches every root and every sub-element slot (Switch's `track`/`thumb`/`input`, Select's `listbox`, LinearProgress's bars, ...), including the layout primitives `View`/`Flex`/`Grid`. Two cautions: an override on `View`/`Flex`/`Grid` cascades into the internals of every composed component (use those keys for app-wide policy only), and hidden/structural slots (`input`, `valueGhost`, `positioner`) carry accessibility or layout behavior - restyle their looks, not their geometry/visibility. Note that `defaultProps` is honored only by components that resolve props through `useDefaultProps` (currently `Breadcrumbs`, `Button`, `Card`, `Pressable`, `Rating`, `NumberInput`, `RangeInput`, `TransferList`, `Collapse`, `FabMenu`, `ScrollArea`, `Autocomplete`, `Tooltip`, `Snackbar`, `Fab`, `Alert`, `Badge`, `Chip`, `Accordion`, `AccordionSummary`, `AccordionGroup`, `Tabs`, `Tab`, `TabScrollButton`, `TabPanel`, `Menu`, `ContextMenu`, `MenuList` and `MenuItem`); everywhere else, use `styleOverrides`/`variants`.\n\n---\n\n## `defaultProps`\n\nPer-component default prop values. They sit in the standard resolution chain - later steps only apply when earlier ones are unset:\n\n```\nexplicit prop → group context (e.g. ButtonGroup) → theme.components.X.defaultProps → theme.defaults.* → literal fallback\n```\n\nUse `theme.defaults` for global policy (\"everything compact\") and `defaultProps` for component policy (\"only Buttons compact\"). Components read them via the `useDefaultProps(name)` hook.\n\n## `styleOverrides`\n\nPer-slot CSS merged **after** the component's own styles - the theme wins the cascade - but **before** the styled-system prop parsers, so per-instance props (`m`, `p`, `width`, ...) always beat the theme.\n\nValues are plain CSS objects or callbacks receiving `{ theme, ownerState }`. `ownerState` is the styled root's **resolved** props - after group context, `defaultProps`, and `theme.defaults` have been applied - so a conditional like `ownerState.variant === 'contained'` sees the same value the component's own styles used. Prop-keyed conditionals belong in the callback; there are no magic override keys to memorize.\n\nSlot names (`root`, `label`, `icon`, ...) are typed per component in `ThemeComponents` and are **public API** - renaming one is a breaking change.\n\n## `variants`\n\nExtra variant entries matched by props: an entry applies when every key in its `props` equals the render prop. Matching runs on the component's root slot only. Note that `createTheme` replaces `variants` arrays wholesale - composing two override sets does not concatenate them.\n\n**New variant values** need two things - the type registration and the styles:\n\n```ts\ndeclare module '@soroush.tech/design-system/theme' {\n interface ButtonVariants {\n dashed: true // widens ButtonVariant so variant=\"dashed\" typechecks\n }\n}\n```\n\nRegistering the value without a matching `variants` entry renders an unstyled button - always pair them.\n\n## Slot props - customizing composed sub-elements\n\nSome slots aren't raw CSS surfaces but composed components with their own token props - Card's title is a `Typography` with `variant`/`color`/`fontFamily`. CSS overrides are the wrong tool for \"make every card title a subtitle instead of an overline\"; that's a **prop** change. Such components accept slot prop objects in `defaultProps`, merged under any per-instance props:\n\n```ts\ncomponents: {\n Card: {\n defaultProps: {\n titleProps: { variant: 'subtitle1', color: 'secondary', fontFamily: 'body' },\n captionProps: { mb: 2 },\n },\n // ...and the same slots are still CSS-addressable:\n styleOverrides: {\n title: { letterSpacing: '0.1em' },\n },\n },\n}\n```\n\nResolution per slot prop: component literal → theme `defaultProps.titleProps` → per-instance `titleProps` (instance wins). The slot-prop shapes are token-typed (`CardSlotTypographyProps`), so `variant`/`color`/`mb` autocomplete against your theme scales - including augmented keys.\n\nSo a composed slot is customizable at three levels: **props** (`defaultProps.titleProps`), **CSS** (`styleOverrides.title`), and **structure** (Card's `title` prop accepts a ReactNode for full replacement).\n\n## Registering your own components\n\nThe mechanism is infrastructure, not just configuration. Create your roots with this package's `styled` and register the name:\n\n```ts\nimport { styled } from '@soroush.tech/design-system'\nimport type { ComponentConfig } from '@soroush.tech/design-system/theme'\n\ndeclare module '@soroush.tech/design-system/theme' {\n interface ThemeComponents {\n MyWidget?: ComponentConfig<{ tone?: 'calm' | 'loud' }, 'root' | 'handle'>\n }\n}\n\nconst WidgetRoot = styled('div', { name: 'MyWidget' })({ padding: 8 })\nconst WidgetHandle = styled('span', { name: 'MyWidget', slot: 'handle' })({ cursor: 'grab' })\n```\n\nYour widget now honors `theme.components.MyWidget.styleOverrides` / `.variants` exactly like the built-ins.\n\n## Converting a design-system component (maintainers)\n\n`Button` is the reference implementation. The rules:\n\n1. Pass `name` on the root and `slot` on named sub-elements. Slot names become public API.\n2. Move styled-system parsers (`space`, `layout`, ...) from the style arguments into the `systemProps` option - this is what keeps instance props beating theme overrides.\n3. Resolve `defaultProps` via `useDefaultProps(name)` in the wrapper, in the chain above.\n4. Type the component's `ThemeComponents` entry (`ComponentConfig<OwnerState, Slots>`); if it has variants, expose them via an augmentable interface (see `ButtonVariants`).\n5. Cover all three mechanisms plus the precedence pairs in the component's tests.\n\n## Runtime cost\n\n- **Unused** (`theme.components` absent): one no-op function call and a property lookup per named root per render; anonymous roots are
|
|
1345
|
+
"body": "# Per-component customization (`theme.components`)\n\nCustomize one component for the whole app - default prop values, per-slot CSS, and new variant values - without wrapping or forking. Zero-config themes pay nothing: the resolver bails out on its first check when `theme.components` is absent.\n\n```ts\nconst brand = createTheme(baseTheme, {\n components: {\n Button: {\n defaultProps: { size: 'sm', shape: 'rounded' },\n styleOverrides: {\n root: ({ theme, ownerState }) => ({\n letterSpacing: theme.letterSpacings.wide,\n ...(ownerState.variant === 'contained' && { textTransform: 'none' }),\n }),\n label: { fontStyle: 'italic' },\n },\n variants: [\n {\n props: { variant: 'dashed' },\n style: ({ theme }) => ({\n backgroundColor: 'transparent',\n border: `${theme.borderWidths.thin} dashed ${theme.border.primary}`,\n }),\n },\n ],\n },\n },\n})\n```\n\nThe `Theme/Customization` Storybook story renders all three mechanisms under a customized theme and is locked by Chromatic - it is the living contract.\n\nEvery styled element is registered - the `ThemeComponents` interface in `src/theme/themes.ts` is the authoritative key/slot list, so `styleOverrides` reaches every root and every sub-element slot (Switch's `track`/`thumb`/`input`, Select's `listbox`, LinearProgress's bars, ...), including the layout primitives `View`/`Flex`/`Grid`. Two cautions: an override on `View`/`Flex`/`Grid` cascades into the internals of every composed component (use those keys for app-wide policy only), and hidden/structural slots (`input`, `valueGhost`, `positioner`) carry accessibility or layout behavior - restyle their looks, not their geometry/visibility. Note that `defaultProps` is honored only by components that resolve props through `useDefaultProps` (currently `Breadcrumbs`, `Button`, `Card`, `Pressable`, `Rating`, `NumberInput`, `RangeInput`, `TransferList`, `Collapse`, `FabMenu`, `ScrollArea`, `Autocomplete`, `Tooltip`, `Snackbar`, `Fab`, `Alert`, `Badge`, `Chip`, `Accordion`, `AccordionSummary`, `AccordionGroup`, `Tabs`, `Tab`, `TabScrollButton`, `TabPanel`, `Menu`, `ContextMenu`, `MenuList` and `MenuItem`); everywhere else, use `styleOverrides`/`variants`.\n\n---\n\n## `defaultProps`\n\nPer-component default prop values. They sit in the standard resolution chain - later steps only apply when earlier ones are unset:\n\n```\nexplicit prop → group context (e.g. ButtonGroup) → theme.components.X.defaultProps → theme.defaults.* → literal fallback\n```\n\nUse `theme.defaults` for global policy (\"everything compact\") and `defaultProps` for component policy (\"only Buttons compact\"). Components read them via the `useDefaultProps(name)` hook.\n\n## `styleOverrides`\n\nPer-slot CSS merged **after** the component's own styles - the theme wins the cascade - but **before** the styled-system prop parsers, so per-instance props (`m`, `p`, `width`, ...) always beat the theme.\n\nValues are plain CSS objects or callbacks receiving `{ theme, ownerState }`. `ownerState` is the styled root's **resolved** props - after group context, `defaultProps`, and `theme.defaults` have been applied - so a conditional like `ownerState.variant === 'contained'` sees the same value the component's own styles used. Prop-keyed conditionals belong in the callback; there are no magic override keys to memorize.\n\nSlot names (`root`, `label`, `icon`, ...) are typed per component in `ThemeComponents` and are **public API** - renaming one is a breaking change.\n\n## `variants`\n\nExtra variant entries matched by props: an entry applies when every key in its `props` equals the render prop. Matching runs on the component's root slot only. Note that `createTheme` replaces `variants` arrays wholesale - composing two override sets does not concatenate them.\n\n**New variant values** need two things - the type registration and the styles:\n\n```ts\ndeclare module '@soroush.tech/design-system/theme' {\n interface ButtonVariants {\n dashed: true // widens ButtonVariant so variant=\"dashed\" typechecks\n }\n}\n```\n\nRegistering the value without a matching `variants` entry renders an unstyled button - always pair them.\n\n## Slot props - customizing composed sub-elements\n\nSome slots aren't raw CSS surfaces but composed components with their own token props - Card's title is a `Typography` with `variant`/`color`/`fontFamily`. CSS overrides are the wrong tool for \"make every card title a subtitle instead of an overline\"; that's a **prop** change. Such components accept slot prop objects in `defaultProps`, merged under any per-instance props:\n\n```ts\ncomponents: {\n Card: {\n defaultProps: {\n titleProps: { variant: 'subtitle1', color: 'secondary', fontFamily: 'body' },\n captionProps: { mb: 2 },\n },\n // ...and the same slots are still CSS-addressable:\n styleOverrides: {\n title: { letterSpacing: '0.1em' },\n },\n },\n}\n```\n\nResolution per slot prop: component literal → theme `defaultProps.titleProps` → per-instance `titleProps` (instance wins). The slot-prop shapes are token-typed (`CardSlotTypographyProps`), so `variant`/`color`/`mb` autocomplete against your theme scales - including augmented keys.\n\nSo a composed slot is customizable at three levels: **props** (`defaultProps.titleProps`), **CSS** (`styleOverrides.title`), and **structure** (Card's `title` prop accepts a ReactNode for full replacement).\n\n## Registering your own components\n\nThe mechanism is infrastructure, not just configuration. Create your roots with this package's `styled` and register the name:\n\n```ts\nimport { styled } from '@soroush.tech/design-system'\nimport type { ComponentConfig } from '@soroush.tech/design-system/theme'\n\ndeclare module '@soroush.tech/design-system/theme' {\n interface ThemeComponents {\n MyWidget?: ComponentConfig<{ tone?: 'calm' | 'loud' }, 'root' | 'handle'>\n }\n}\n\nconst WidgetRoot = styled('div', { name: 'MyWidget' })({ padding: 8 })\nconst WidgetHandle = styled('span', { name: 'MyWidget', slot: 'handle' })({ cursor: 'grab' })\n```\n\nYour widget now honors `theme.components.MyWidget.styleOverrides` / `.variants` exactly like the built-ins.\n\n## Converting a design-system component (maintainers)\n\n`Button` is the reference implementation. The rules:\n\n1. Pass `name` on the root and `slot` on named sub-elements. Slot names become public API.\n2. Move styled-system parsers (`space`, `layout`, ...) from the style arguments into the `systemProps` option - this is what keeps instance props beating theme overrides.\n3. Resolve `defaultProps` via `useDefaultProps(name)` in the wrapper, in the chain above.\n4. Type the component's `ThemeComponents` entry (`ComponentConfig<OwnerState, Slots>`); if it has variants, expose them via an augmentable interface (see `ButtonVariants`).\n5. Cover all three mechanisms plus the precedence pairs in the component's tests.\n\n## Runtime cost\n\n- **Unused** (`theme.components` absent): one no-op function call and a property lookup per named root per render; anonymous roots are plain `styled` roots. Bundle cost of the wrapper: well under a kilobyte.\n- **Used**: each overridden component behaves as if it shipped one more style function - the same cost class as its existing `sizeVariants`/`colorStyle` functions. The engine names a class by a hash of its compiled rules, so the same style always gives the same class.\n",
|
|
1346
1346
|
"url": "https://docs.soroush.tech/design-system/customization/how-to/"
|
|
1347
1347
|
},
|
|
1348
1348
|
{
|
|
1349
1349
|
"id": "setup",
|
|
1350
1350
|
"title": "New app setup",
|
|
1351
1351
|
"summary": "End-to-end checklist for a new app: fonts, global reset, providers, theme.",
|
|
1352
|
-
"body": "# New-app checklist\n\nReference wiring: a Next.js App Router app on React 19.\n\n## 1. Install\n\n```jsonc\n// package.json\n\"dependencies\": {\n \"@soroush.tech/design-system\": \"^
|
|
1352
|
+
"body": "# New-app checklist\n\nReference wiring: a Next.js App Router app on React 19.\n\n## 1. Install\n\n```jsonc\n// package.json\n\"dependencies\": {\n \"@soroush.tech/design-system\": \"^3.0.0\",\n \"react\": \"^19.2.8\",\n \"react-dom\": \"^19.2.8\"\n}\n```\n\nThe styling engine (UmberStyle, the `@umber-style/*` packages) comes in as a dependency\nof the design system - don't add it directly. The registry in `providers.tsx` takes\n`createCache` from `@soroush.tech/design-system/engine`. React 19.2 or later is required.\n\n## 2. Theme\n\nCopy `theme.ts` to the app root so it imports as `@/theme`.\nIt exports `light` and `dark`. The color ramps at the top (`carbonBlack`,\n`cyberCyan`, `kineticGreen`, `forestGreen`, `solarAmber`, `neonRed`, `softGreen`,\n`deepCrimson`, `lightSurface`, `kineticSurface`, `blackAlpha`) are the brand: every\napp that copies them shares one color set. Change which ramp fills a palette slot if\nthe app needs to, never the ramp values.\n\n## 3. Provider\n\nCopy `providers.tsx` to `app/providers.tsx`. Two things it does:\n\n- **Style registry** - collects the styles written during the server render and\n re-injects them via `useServerInsertedHTML`, so server markup arrives styled.\n Without it you get an unstyled flash on every hard navigation.\n- **Global reset** - `border-box` everywhere, zero body margin,\n `background.primary` / `text.initial` / `fonts.body` on `<body>`.\n\nThe cache key is the prefix of the class names and the CSS variables under the registry. The\nfile uses `soroush`, the design system's own; an app that already has a key of its own may keep\nit. The registry writes one `<style data-umber=\"<key> ...\">` element per flush into the stream.\n\nThis set-up is tested on Next.js 16.4 with React 19.2, in development and in a production\nbuild, with a page that streams through `Suspense`. Keep styled parts in client components:\nthe registry collects what client components render.\n\nUnder a strict Content Security Policy (a `style-src` with a nonce and no `unsafe-inline`), give\nthe cache the response's nonce, `createCache({ key: 'soroush', nonce })`, and put the same nonce\non the `<style>` element the registry returns, `nonce={cache.nonce}`: that element is the app's\nown. Every style element the engine makes then carries it. Give React the same nonce for its\nrender; it keeps the rules of a style element only when the element's nonce is its own. This\nregistry has not been run under such a policy end to end, so test it in your app.\n\nThen in `app/layout.tsx`:\n\n```tsx\nexport default function RootLayout({ children }: { children: React.ReactNode }) {\n return (\n <html lang=\"en\">\n <body>\n <Providers>\n <TopBar />\n {children}\n </Providers>\n </body>\n </html>\n )\n}\n```\n\n`<Providers>` wraps everything including the chrome. Route groups then supply their\nown inner layout (rail + `Main`).\n\n## 4. Fonts\n\n`theme.fonts` names _Space Grotesk_ and _JetBrains Mono_, but the package does not\nload them. An app that never loads them renders in the system sans and mono fonts.\nTo get the intended look, load them once in the root layout -\n`@fontsource-variable/space-grotesk` + `@fontsource-variable/jetbrains-mono`, or\n`next/font`. Leaving the system fonts is also a valid choice; just make it deliberately.\n\n## 5. Layout scaffold\n\n```\ncomponents/\n chrome/constants.ts TOPBAR_HEIGHT = \"3.5rem\"\n chrome/TopBar.tsx sticky AppBar, brand wordmark, breadcrumb, session cluster\n chrome/Main.tsx 1600px column, 20→40px gutters\n chrome/<Rail>.tsx optional icon rail, bottom bar on mobile\n ui.tsx NavLink, TokenCode, StatusBadge + STATUS_TONE map\n PageCard.tsx PageHeader.tsx SectionLabel.tsx Pill.tsx\n StatStrip.tsx TabNav.tsx SettingCard.tsx SearchInput.tsx Skeletons.tsx\n```\n\nSources in `layout-kit.md`.\n\n## 6. tsconfig\n\n`@/*` path alias to the app root - every import above assumes it.\n\n## 7. Verify\n\n`pnpm typecheck` (`tsc --noEmit`) catches the common mistakes: a `tone` string that\nisn't a `PaletteColor`, a `theme.text.*` key that doesn't exist, a missing\n`shouldForwardProp`. The theme is fully typed - lean on it instead of eyeballing.\n"
|
|
1353
1353
|
},
|
|
1354
1354
|
{
|
|
1355
1355
|
"id": "layout-kit",
|
|
@@ -1366,14 +1366,14 @@ const content = {
|
|
|
1366
1366
|
{
|
|
1367
1367
|
"id": "providers",
|
|
1368
1368
|
"title": "Providers (Next.js App Router)",
|
|
1369
|
-
"summary": "ThemeProvider plus the
|
|
1370
|
-
"body": "Copy this verbatim into your app as `providers.tsx`.\n\n```tsx\n'use client'\n\nimport { useServerInsertedHTML } from 'next/navigation'\nimport { useState } from 'react'\nimport
|
|
1369
|
+
"summary": "ThemeProvider plus the style registry for the Next.js App Router.",
|
|
1370
|
+
"body": "Copy this verbatim into your app as `providers.tsx`.\n\n```tsx\n'use client'\n\nimport { useServerInsertedHTML } from 'next/navigation'\nimport { useState } from 'react'\nimport { CacheProvider, createCache, Global } from '@soroush.tech/design-system/engine'\nimport { ThemeProvider } from '@soroush.tech/design-system/theme'\nimport { light } from '@/theme'\n\n/** Collects the styles rendered on the server and re-injects them into the\n * HTML stream, so server-rendered markup arrives already styled. */\nfunction useStyleRegistry() {\n const [{ cache, flush }] = useState(() => {\n const cache = createCache({ key: 'soroush' })\n cache.compat = true\n const prevInsert = cache.insert\n let inserted: string[] = []\n cache.insert = (...args) => {\n const serialized = args[1]\n if (cache.inserted[serialized.name] === undefined) inserted.push(serialized.name)\n return prevInsert(...args)\n }\n const flush = () => {\n const prev = inserted\n inserted = []\n return prev\n }\n return { cache, flush }\n })\n\n useServerInsertedHTML(() => {\n const names = flush()\n if (names.length === 0) return null\n let styles = ''\n for (const name of names) styles += cache.inserted[name]\n return (\n <style\n key={cache.key}\n data-umber={`${cache.key} ${names.join(' ')}`}\n dangerouslySetInnerHTML={{ __html: styles }}\n />\n )\n })\n\n return cache\n}\n\nexport default function Providers({ children }: Readonly<{ children: React.ReactNode }>) {\n const cache = useStyleRegistry()\n return (\n <CacheProvider value={cache}>\n <ThemeProvider theme={light}>\n <Global\n styles={(theme) => ({\n '*, *::before, *::after': { boxSizing: 'border-box' },\n body: {\n margin: 0,\n backgroundColor: theme.background.primary,\n color: theme.text.initial,\n fontFamily: theme.fonts.body,\n },\n })}\n />\n {children}\n </ThemeProvider>\n </CacheProvider>\n )\n}\n```\n"
|
|
1371
1371
|
},
|
|
1372
1372
|
{
|
|
1373
1373
|
"id": "design-system-overview",
|
|
1374
1374
|
"title": "Design system overview",
|
|
1375
1375
|
"summary": "The package README: what ships, the import contract, and the component inventory.",
|
|
1376
|
-
"body": "**Your design system. Your tokens. Your rules.**\nA fully typed React component library where nothing is hardcoded - every color, scale, and default belongs to you, not the package.\n\nTired of forking a component library just to change a color? Every token here is designed to be overridden - theming isn't an afterthought, it's the whole point.\n\n## Install\n\n```sh\nnpm i @soroush.tech/design-system\n```\n\n`react` and `react-dom` are peer dependencies. Emotion is an internal implementation detail - it ships as a regular dependency, not a peer, so you never install it yourself.\n\n---\n\n## Use it with AI tools\n\nTwo skills teach a coding agent how to build with this library: a house-style skill, and a\nWCAG 2.2 AA skill for contrast, labels, landmarks and accessibility tests. Both install for\nwhichever agents you use:\n\n```sh\nnpx skills add soroush-tech/design-system\n```\n\nAn MCP server serves this library's component inventory, every component's props\nreference, and the live token contract, so an AI assistant writes against the real API\ninstead of guessing. Add the hosted server, `https://mcp.soroush.design/mcp`, to any MCP\nclient; in Claude Code:\n\n```sh\nclaude mcp add --transport http soroush https://mcp.soroush.design/mcp\n```\n\nIt also runs locally over stdio (`npx -y @soroush.design/mcp`). Claude Code users can\ninstall the plugin instead, which brings the skills, the server and a UI review agent in\none step:\n\n```sh\nclaude plugin marketplace add soroush-tech/design-system\nclaude plugin install soroush-design-system@soroush-tech\n```\n\nAny other tool can read [docs.soroush.tech/llms.txt](https://docs.soroush.tech/llms.txt).\nSee [`@soroush.design/mcp`](../mcp) for the full tool list.\n\n---\n\n## Importing\n\nImport components by subpath, styling primitives from the barrel:\n\n```ts\nimport { Typography } from '@soroush.tech/design-system/Typography'\nimport { Flex } from '@soroush.tech/design-system/Flex'\n```\n\nStyling primitives (the engine) come from the barrel `@soroush.tech/design-system` - `styled`, `css`, `keyframes`, the `Theme` type, styled-system functions, and `createShouldForwardProp`. The barrel (`src/index.ts`) is the engine abstraction layer: to swap the CSS-in-JS engine, only that file changes.\n\n```ts\nimport { styled, css, type Theme } from '@soroush.tech/design-system'\n```\n\n`ThemeProvider` and the theme-value hooks (`useTheme`, `useDefaultProps`, `withTheme`) live at their own subpath:\n\n```ts\nimport { ThemeProvider, useTheme } from '@soroush.tech/design-system/theme'\n```\n\nStyle-computation helpers (`useStyle`, `withStyles`, `StylesConsumer`) - resolving a `StyleInput`/`StyleFactory` into a `CSSObject` - live at their own subpath:\n\n```ts\nimport { useStyle } from '@soroush.tech/design-system/style'\n```\n\nRaw engine primitives for building your own global styles - `Global`, `globalStyles`, and the SSR-only `CacheProvider`/`styleCache` pairing - live at their own subpath, not the barrel:\n\n```ts\nimport { Global, globalStyles, CacheProvider, styleCache } from '@soroush.tech/design-system/engine'\n```\n\n`Global` (retyped against this package's `Theme`) applies app-wide CSS and should render inside `ThemeProvider` so it resolves against the active theme. `globalStyles(theme)` is the base reset this package owns - box-sizing, margin/table resets, and theme-driven body colors - compose it into your own `Global` styles array alongside your app's own concerns (font-family, webfont loading, and anything else app-specific stay entirely app policy).\n\nThe component catalog - every component as data, for tools that place and write components (a\ndesign tool's palette, a source writer) - lives at its own subpath and loads in plain Node\n([docs](./docs/catalog.md)):\n\n```ts\nimport { catalog } from '@soroush.tech/design-system/catalog'\n```\n\nSSR critical-CSS extraction (e.g. with `@emotion/server`) is a separate, opt-in concern most apps never need - that's what `CacheProvider` and its paired `styleCache` instance are for.\n\nUnder a strict Content Security Policy, bring your own cache with the response's nonce - `createCache({ key: 'app', nonce })` from `@emotion/cache`, given to `CacheProvider` above `ThemeProvider` - and every style tag the engine inserts carries it. The shipped `styleCache` has no nonce.\n\nThe Emotion packages are regular dependencies of this package, not peers, on purpose: nothing of Emotion is on the public surface, so an app installs nothing extra and has no version to keep in step. An app that brings its own `@emotion/react` of another major gets two copies - the components keep working, as they style through their own copy and `ThemeProvider` - at the cost of the duplicate in the bundle and Emotion's one-time development warning.\n\n---\n\n## Component inventory\n\n### Layout & surfaces\n\n| Component | Purpose |\n| ------------ | ----------------------------------------------------------------------- |\n| `ScrollArea` | A scrolling area with scrollbars drawn over its content, shown on hover |\n| `View` | Styled `div` primitive - the base building block |\n| `Flex` | `View` with flexbox defaults |\n| `Grid` | CSS grid container |\n| `Paper` | Elevated surface with background and shadow |\n| `Card` | Content container built on `Paper` |\n| `Quote` | Bordered quote / terminal-panel surface on `View` |\n| `AppBar` | Top application bar |\n| `Drawer` | Slide-in side panel |\n\n### Content & data display\n\n| Component | Purpose |\n| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `Typography` | Text with variant → element mapping - the reference implementation for all components |\n| `Link` | Anchor with theme-aware styling |\n| `Icon` | Icon renderer |\n| `Image` | Image with styled-system props |\n| `Avatar` | User/entity avatar |\n| `Table` | Compound data table - exports `TableContainer`, `TableHead`, `TableBody`, `TableFooter`, `TableRow`, `TableCell`, `TablePagination`, `TablePaginationActions`, `TableSortLabel`, and `TableControl` from `@soroush.tech/design-system/Table` |\n| `Accordion` | A heading that opens and closes a region - exports `AccordionSummary`, `AccordionDetails`, `AccordionActions` and `AccordionGroup` from `@soroush.tech/design-system/Accordion` |\n\n### Inputs & forms\n\n| Component | Purpose |\n| ---------------------------------------------------- | ----------------------------------------------------------------------------------------- |\n| `Autocomplete` | A field whose text finds an option in a list - one, several as chips, or free text |\n| `Fab` | A floating action button: the one main action of a page, circular or extended |\n| `Button`, `ButtonGroup`, `ToggleButton` | Actions and toggles |\n| `TextInput` | Text field |\n| `Checkbox`, `Radio`, `Switch` | Selection controls |\n| `RangeInput` | A slider - one value on a range, or two or more thumbs for a range of values |\n| `TransferList` | Two lists and the buttons that move the checked items from one to the other |\n| `NumberInput` | A field for a number - read in its locale, clamped to a range, stepped by keys or buttons |\n| `Rating` | A row of icons the user sets as a rating, or a read-only display of one |\n| `NativeSelect` | Low-level platform `<select>` - not recommended; use `Select native` |\n| `Select` | The select to use - custom listbox, or `native` for the platform picker |\n| `MenuItem` | Option row for `Select`'s listbox, and a menu row in a `MenuList` |\n| `Form`, `FormControl`, `FormLabel`, `FormHelperText` | Form composition and labeling |\n| `Pagination` | Page navigation control |\n\n### Navigation & menus\n\n| Component | Purpose |\n| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `NavTree` | A tree of links to the pages of a site - groups of links, which can fold |\n| `Breadcrumbs` | The trail of links from a site's root to the current page - a long one collapses behind a button that shows it all |\n| `Menu` | A trigger and the list of commands it opens - exports `MenuList` (the `role=\"menu\"` list that owns the keyboard), `MenuDivider`, `MenuItems` (rows from data) and `ContextMenu` (the same list, opened at the pointer by a right-click) from `@soroush.tech/design-system/Menu` |\n| `Tabs` | A row of tabs - exports `Tab`, `TabContext` (holds the value for a `TabList` and its panels), `TabList` (the `Tabs` of a `TabContext`), `TabPanel` (the content a tab shows) and `TabScrollButton` from `@soroush.tech/design-system/Tabs` |\n\n### Feedback\n\n| Component | Purpose |\n| ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------- |\n| `FabMenu` | A fab that opens a stack of actions from the corner of a page |\n| `Snackbar` | A transient message in a corner of the window, with auto-hide and an action |\n| `Alert` | An inline message with a severity, an icon, a title and an action - exports `AlertTitle` from `@soroush.tech/design-system/Alert` |\n| `Badge` | A count or a dot anchored over another element |\n| `Chip` | A compact tag: a label, an icon or avatar, a click and a delete |\n| `CircularProgress`, `LinearProgress` | Determinate/indeterminate progress indicators |\n| `Skeleton` | Loading placeholder with pulse/wave animations |\n| `Backdrop` | Dimmed overlay behind modal surfaces |\n\n### Transitions\n\n| Component | Purpose |\n| ------------------------------- | ------------------------------------------------------------------ |\n| `Collapse` | Opens and closes its content by its height, or its width |\n| `Fade`, `Grow`, `Slide`, `Zoom` | Show and hide one child by opacity, scale, an edge or from nothing |\n\n### Overlay & behavior primitives\n\n| Component | Purpose |\n| --------------- | ----------------------------------------------------------------------------------- |\n| `Tooltip` | A short description of one element, shown on hover, keyboard focus and a long touch |\n| `Portal` | Renders children into a DOM node outside the parent hierarchy |\n| `FocusTrap` | Keeps focus inside a subtree |\n| `Modal` | Dialog primitive composing `Portal`, `Backdrop`, and `FocusTrap` |\n| `Popover` | Anchored floating surface built on `Modal` |\n| `ThemeProvider` | Supplies the theme and global styles to the app |\n\n---\n\n## Theme tokens\n\nComponents never hardcode colors or sizes - props resolve against scales on the `Theme` object:\n\n| Group | Scales |\n| ------------------ | ------------------------------------------------------------------------------------------------------------- |\n| Color | `palette` (main/light/dark/contrastText per color) · `text` · `background` · `border` · `colorScheme` |\n| Typography | `typography` (variant map) · `fonts` · `fontSizes` · `fontWeights` · `lineHeights` · `letterSpacings` |\n| Space & shape | `space` · `sizes` · `radii` · `borderWidths` · `shadows` |\n| Layout | `breakpoints` (xs/sm/md/lg/xl window classes) · `layout` (columns, margins, panels, top bar per class) |\n| Component scales | `avatar` (size steps) · `skeleton` (wave highlight) |\n| Layering & effects | `zOrder` (appBar/drawer/modal/snackbar/tooltip) · `blur` · `logoFilter` · `portraitBlend` · `portraitOpacity` |\n\nProp types are derived from the interface (`keyof Theme['text']`), so adding a token to `themes.ts` propagates everywhere automatically. See [`design-system.md`](./design-system.md) for the full scale table and the palette rules.\n\n---\n\n## Theming\n\nThe theme belongs to you - the package only ships defaults. This section is the overview; the full guides are [`docs/theming.md`](./docs/theming.md) and [`docs/customization.md`](./docs/customization.md).\n\n### One theme, yours\n\n`ThemeProvider` provides exactly one theme - the built-in dark theme when you pass nothing. Bring one theme, or as many as you like: switching between them is your state, not the provider's.\n\n```tsx\nimport { ThemeProvider } from '@soroush.tech/design-system/theme'\nimport { baseTheme, createTheme } from '@soroush.tech/design-system/theme'\n\n// Zero-config: the built-in `baseTheme`.\n<ThemeProvider>{app}</ThemeProvider>\n\n// Your theme - written from scratch or extended from the base.\nconst brand = createTheme(baseTheme, { palette: { primary: { main: '#00ff88' } } })\n<ThemeProvider theme={brand}>{app}</ThemeProvider>\n\n// Mode switching is app policy - own the state and pass the active theme:\nconst [isDark, setIsDark] = useState(true)\n<ThemeProvider theme={isDark ? brandDark : brandLight}>{app}</ThemeProvider>\n```\n\n`createTheme(base, overrides)` (exported from `@soroush.tech/design-system/theme`) is the merge primitive: plain objects recurse, arrays (`shadows`, `fontSizes`) and functions replace wholesale, `undefined` values are ignored - keys are added or replaced, never removed.\n\n### Breakpoints and layout\n\n`theme.breakpoints` are Material 3's window classes, each a range from its start until the next:\n`xs` 0-599px (compact, the base), `sm` 600-839 (medium), `md` 840-1199 (expanded), `lg`\n1200-1599 (large), `xl` 1600+ (extra-large). Responsive props use them by name or position -\n`p={{ xs: 2, md: 4 }}`, `p={[2, 3, 4]}` - and `cqSm`-style keys write container queries;\n`theme.breakpoints.up('md')` and its siblings write queries for hand-written styles. Everything is\nCSS, so pages work with JavaScript off. `theme.layout` holds the layout tokens per class (columns,\nmargins, gutters, side panels, top bar); `Grid` and `Flex` apply the column grid with\n`layout` / `layout={{ lg: { columns: 16 } }}`, and apps place `AppBar`, `Sidebar` and `Drawer`\nthemselves. The full guide is the\n[Breakpoints and layout](./docs/theming.md#breakpoints-and-layout) section of the theming guide.\n\n### Component defaults\n\nComponents carry visible literal fallbacks (`size = 'md'`, `variant = 'outside'`, ...) resolved through `themeDefault(theme, key, fallback)` - so every default, including behavioral variants, is overridable via the optional `theme.defaults` map or the provider's `defaults` prop:\n\n| Key | Fallback | Drives |\n| -------------------------------------------- | ---------------------------------- | -------------------------------------- |\n| `size` / `compactSize` | `'md'` / `'sm'` | sized components / dense table actions |\n| `color` / `neutralColor` | `'primary'` / `'default'` | accent controls / toggle controls |\n| `textColor` / `accentTextColor` | `'initial'` / `'primary'` | body text / icons + input labels |\n| `bg` / `surfaceBg` / `inputBg` | `'default'`/`'paper'`/`'terminal'` | switch track / paper surfaces / inputs |\n| `borderRadius` / `surfaceRadius` | `'md'` / `'sq'` | grouped controls / surfaces |\n| `avatarSize` / `borderColor` / `borderWidth` | `'md'` / `'primary'` / `'thin'` | avatars and rings |\n| `iconSize` | `'lg'` | Icon default glyph size (`theme.icon`) |\n| `inputMinWidth` | `'12rem'` | least width of an input not full width |\n| `buttonVariant` / `switchVariant` | `'contained'` / `'outside'` | Button / Switch visual variants |\n| `inputVariant` | `'default'` | TextInput, Select, NativeSelect frames |\n| `avatarVariant` / `cardVariant` | `'circular'` / `'paper'` | Avatar shape / Card treatment |\n| `linkUnderline` | `'always'` | Link underline behavior |\n| `paginationVariant` / `paginationShape` | `'text'` / `'circular'` | Pagination items |\n\nThe built-in themes carry no `defaults` - the literals apply. A theme with entirely different size or palette keys stays valid by pointing the keys at its own tokens:\n\n```tsx\n<ThemeProvider defaults={{ size: 'compact', color: 'brand', switchVariant: 'inside' }}>\n```\n\n### Per-component customization (`theme.components`)\n\nCustomize one component for the whole app - default prop values, per-slot CSS, and new variant values - without wrapping or forking:\n\n```tsx\nconst brand = createTheme(baseTheme, {\n components: {\n Button: {\n // Buttons default to sm + rounded; explicit props and ButtonGroup still win.\n defaultProps: { size: 'sm', shape: 'rounded' },\n\n // Per-slot CSS merged after Button's own styles - the theme wins the cascade,\n // but per-instance props (m, p, width, ...) still beat the theme.\n styleOverrides: {\n root: ({ theme, ownerState }) => ({\n letterSpacing: theme.letterSpacings.wide,\n ...(ownerState.variant === 'contained' && { textTransform: 'none' }),\n }),\n label: { fontStyle: 'italic' },\n },\n\n // A new variant value - register it first so it typechecks:\n // declare module '@soroush.tech/design-system/theme' { interface ButtonVariants { dashed: true } }\n variants: [\n {\n props: { variant: 'dashed' },\n style: ({ theme }) => ({\n backgroundColor: 'transparent',\n border: `${theme.borderWidths.thin} dashed ${theme.border.primary}`,\n }),\n },\n ],\n },\n },\n})\n```\n\nStyle callbacks receive `{ theme, ownerState }`, where `ownerState` is the styled root's **resolved** props (after group context, `defaultProps`, and `theme.defaults`). `defaultProps` sits in the standard precedence chain: explicit prop → group context → `defaultProps` → `theme.defaults.*` → the component's literal fallback. `variants` arrays are replaced wholesale by `createTheme`, never merged.\n\nYour own components can join the same mechanism: create their roots with this package's `styled(tag, { name: 'MyWidget', slot: 'root' })` and register the name by augmenting `ThemeComponents`. Zero-config themes pay nothing - the resolver bails out on the first check when `theme.components` is absent.\n\n### Extending tokens (declaration merging)\n\nEvery scale is an open interface declared on `@soroush.tech/design-system/theme`, so you can add palette colors, tokens, or whole scales - and every component prop union (`color`, `bg`, `size`, ...) widens automatically:\n\n```ts\nimport type { PaletteEntry } from '@soroush.tech/design-system/theme'\n\ndeclare module '@soroush.tech/design-system/theme' {\n interface ThemePalette {\n brand: PaletteEntry // new palette color\n }\n interface ThemeBackground {\n tertiary: string // new background token\n }\n interface Theme {\n elevations: Record<'low' | 'mid' | 'high', string> // whole new scale\n }\n}\n```\n\nThen supply the values with `createTheme` and use the new keys:\n\n```tsx\nconst brandDark = createTheme(baseTheme, {\n palette: { brand: { main: '#00ff88', light: '#66ffb2', dark: '#00b25f', contrastText: '#000' } },\n background: { tertiary: '#101418' },\n elevations: { low: '0 1px 2px', mid: '0 2px 6px', high: '0 6px 18px' },\n})\n\n<ThemeProvider theme={brandDark}>\n <Button color=\"brand\" />\n <View bg=\"tertiary\" />\n</ThemeProvider>\n```\n\nNotes: new object-valued keys (like a `PaletteEntry`) must be supplied complete - components read `.main`/`.contrastText` at runtime; and TypeScript cannot verify at runtime that an augmented token was actually supplied, so always pair an augmentation with the matching override.\n\n---\n\n## Adding a component\n\nScaffold with the skill - it reads the live `Typography` files and `design-system.md` so output matches the codebase:\n\n```\n/new_theme_component ComponentName\n```\n\nThen work through the checklist at the bottom of [`design-system.md`](./design-system.md).\n\n---\n\nThe library takes inspiration from [Material UI](https://mui.com/) - its component vocabulary and prop conventions will feel familiar - but it is written entirely in house. It is not a clone or a fork: every component is built from scratch on our own engine and token system, and the API is free to diverge wherever it serves its consumers better.\n\n---\n\n## Release notes\n\nPer-version notes for every published release live in\n[`release-notes/`](https://github.com/soroush-tech/design-system/tree/main/packages/design-system/release-notes).\n",
|
|
1376
|
+
"body": "**Your design system. Your tokens. Your rules.**\nA fully typed React component library where nothing is hardcoded - every color, scale, and default belongs to you, not the package.\n\nTired of forking a component library just to change a color? Every token here is designed to be overridden - theming isn't an afterthought, it's the whole point.\n\n## Install\n\n```sh\nnpm i @soroush.tech/design-system\n```\n\n`react` and `react-dom` are peer dependencies, and React 19.2 or later is required. The styling engine (UmberStyle, the `@umber-style/*` packages) is an internal implementation detail - it ships as a regular dependency, not a peer, so you never install it yourself.\n\n---\n\n## Use it with AI tools\n\nTwo skills teach a coding agent how to build with this library: a house-style skill, and a\nWCAG 2.2 AA skill for contrast, labels, landmarks and accessibility tests. Both install for\nwhichever agents you use:\n\n```sh\nnpx skills add soroush-tech/design-system\n```\n\nAn MCP server serves this library's component inventory, every component's props\nreference, and the live token contract, so an AI assistant writes against the real API\ninstead of guessing. Add the hosted server, `https://mcp.soroush.design/mcp`, to any MCP\nclient; in Claude Code:\n\n```sh\nclaude mcp add --transport http soroush https://mcp.soroush.design/mcp\n```\n\nIt also runs locally over stdio (`npx -y @soroush.design/mcp`). Claude Code users can\ninstall the plugin instead, which brings the skills, the server and a UI review agent in\none step:\n\n```sh\nclaude plugin marketplace add soroush-tech/design-system\nclaude plugin install soroush-design-system@soroush-tech\n```\n\nAny other tool can read [docs.soroush.tech/llms.txt](https://docs.soroush.tech/llms.txt).\nSee [`@soroush.design/mcp`](../mcp) for the full tool list.\n\n---\n\n## Importing\n\nImport components by subpath, styling primitives from the barrel:\n\n```ts\nimport { Typography } from '@soroush.tech/design-system/Typography'\nimport { Flex } from '@soroush.tech/design-system/Flex'\n```\n\nStyling primitives (the engine) come from the barrel `@soroush.tech/design-system` - `styled`, `css`, `keyframes`, the `Theme` type, styled-system functions, and `createShouldForwardProp`. The barrel (`src/index.ts`) is the engine abstraction layer: to swap the CSS-in-JS engine, only that file changes.\n\n```ts\nimport { styled, css, type Theme } from '@soroush.tech/design-system'\n```\n\n`ThemeProvider` and the theme-value hooks (`useTheme`, `useDefaultProps`, `withTheme`) live at their own subpath:\n\n```ts\nimport { ThemeProvider, useTheme } from '@soroush.tech/design-system/theme'\n```\n\nStyle-computation helpers (`useStyle`, `withStyles`, `StylesConsumer`) - resolving a `StyleInput`/`StyleFactory` into a `CSSObject` - live at their own subpath:\n\n```ts\nimport { useStyle } from '@soroush.tech/design-system/style'\n```\n\nRaw engine primitives for building your own global styles - `Global`, `globalStyles`, and the SSR-only `CacheProvider`/`styleCache` pairing - live at their own subpath, not the barrel:\n\n```ts\nimport { Global, globalStyles, CacheProvider, styleCache } from '@soroush.tech/design-system/engine'\n```\n\n`Global` (retyped against this package's `Theme`) applies app-wide CSS and should render inside `ThemeProvider` so it resolves against the active theme. `globalStyles(theme)` is the base reset this package owns - box-sizing, margin/table resets, and theme-driven body colors - compose it into your own `Global` styles array alongside your app's own concerns (font-family, webfont loading, and anything else app-specific stay entirely app policy).\n\nThe component catalog - every component as data, for tools that place and write components (a\ndesign tool's palette, a source writer) - lives at its own subpath and loads in plain Node\n([docs](./docs/catalog.md)):\n\n```ts\nimport { catalog } from '@soroush.tech/design-system/catalog'\n```\n\nServer rendering with critical CSS (a Vike or other static or server renderer) is a separate, opt-in concern - that's what `CacheProvider` and its paired `styleCache` instance are for. Give `CacheProvider` the `styleCache`, render, then read the CSS of the page from the same cache with `createInstance` from `@umber-style/server/create-instance` (`pnpm add @umber-style/server`): `extractCriticalToChunks(html)` and `constructStyleTagsFromChunks(chunks)` give the `<style data-umber>` tags to put in the head. Next.js App Router apps collect the styles with a registry instead - see `docs/consumer/setup.md`.\n\nThe cache key and class prefix is `soroush`. Server-rendered style elements carry `data-umber=\"soroush ...\"`, and the live element in the browser is `<style data-style=\"soroush\">`.\n\nThe engine packages are regular dependencies of this package, not peers, on purpose: an app installs nothing extra to render the components, and has no version to keep in step. The one package an app adds itself is `@umber-style/server`, and only to extract critical CSS.\n\n---\n\n## Component inventory\n\n### Layout & surfaces\n\n| Component | Purpose |\n| ------------ | ----------------------------------------------------------------------- |\n| `ScrollArea` | A scrolling area with scrollbars drawn over its content, shown on hover |\n| `View` | Styled `div` primitive - the base building block |\n| `Flex` | `View` with flexbox defaults |\n| `Grid` | CSS grid container |\n| `Paper` | Elevated surface with background and shadow |\n| `Card` | Content container built on `Paper` |\n| `Quote` | Bordered quote / terminal-panel surface on `View` |\n| `AppBar` | Top application bar |\n| `Drawer` | Slide-in side panel |\n\n### Content & data display\n\n| Component | Purpose |\n| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `Typography` | Text with variant → element mapping - the reference implementation for all components |\n| `Link` | Anchor with theme-aware styling |\n| `Icon` | Icon renderer |\n| `Image` | Image with styled-system props |\n| `Avatar` | User/entity avatar |\n| `Table` | Compound data table - exports `TableContainer`, `TableHead`, `TableBody`, `TableFooter`, `TableRow`, `TableCell`, `TablePagination`, `TablePaginationActions`, `TableSortLabel`, and `TableControl` from `@soroush.tech/design-system/Table` |\n| `Accordion` | A heading that opens and closes a region - exports `AccordionSummary`, `AccordionDetails`, `AccordionActions` and `AccordionGroup` from `@soroush.tech/design-system/Accordion` |\n\n### Inputs & forms\n\n| Component | Purpose |\n| ---------------------------------------------------- | ----------------------------------------------------------------------------------------- |\n| `Autocomplete` | A field whose text finds an option in a list - one, several as chips, or free text |\n| `Fab` | A floating action button: the one main action of a page, circular or extended |\n| `Button`, `ButtonGroup`, `ToggleButton` | Actions and toggles |\n| `TextInput` | Text field |\n| `Checkbox`, `Radio`, `Switch` | Selection controls |\n| `RangeInput` | A slider - one value on a range, or two or more thumbs for a range of values |\n| `TransferList` | Two lists and the buttons that move the checked items from one to the other |\n| `NumberInput` | A field for a number - read in its locale, clamped to a range, stepped by keys or buttons |\n| `Rating` | A row of icons the user sets as a rating, or a read-only display of one |\n| `NativeSelect` | Low-level platform `<select>` - not recommended; use `Select native` |\n| `Select` | The select to use - custom listbox, or `native` for the platform picker |\n| `MenuItem` | Option row for `Select`'s listbox, and a menu row in a `MenuList` |\n| `Form`, `FormControl`, `FormLabel`, `FormHelperText` | Form composition and labeling |\n| `Pagination` | Page navigation control |\n\n### Navigation & menus\n\n| Component | Purpose |\n| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `NavTree` | A tree of links to the pages of a site - groups of links, which can fold |\n| `Breadcrumbs` | The trail of links from a site's root to the current page - a long one collapses behind a button that shows it all |\n| `Menu` | A trigger and the list of commands it opens - exports `MenuList` (the `role=\"menu\"` list that owns the keyboard), `MenuDivider`, `MenuItems` (rows from data) and `ContextMenu` (the same list, opened at the pointer by a right-click) from `@soroush.tech/design-system/Menu` |\n| `Tabs` | A row of tabs - exports `Tab`, `TabContext` (holds the value for a `TabList` and its panels), `TabList` (the `Tabs` of a `TabContext`), `TabPanel` (the content a tab shows) and `TabScrollButton` from `@soroush.tech/design-system/Tabs` |\n\n### Feedback\n\n| Component | Purpose |\n| ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------- |\n| `FabMenu` | A fab that opens a stack of actions from the corner of a page |\n| `Snackbar` | A transient message in a corner of the window, with auto-hide and an action |\n| `Alert` | An inline message with a severity, an icon, a title and an action - exports `AlertTitle` from `@soroush.tech/design-system/Alert` |\n| `Badge` | A count or a dot anchored over another element |\n| `Chip` | A compact tag: a label, an icon or avatar, a click and a delete |\n| `CircularProgress`, `LinearProgress` | Determinate/indeterminate progress indicators |\n| `Skeleton` | Loading placeholder with pulse/wave animations |\n| `Backdrop` | Dimmed overlay behind modal surfaces |\n\n### Transitions\n\n| Component | Purpose |\n| ------------------------------- | ------------------------------------------------------------------ |\n| `Collapse` | Opens and closes its content by its height, or its width |\n| `Fade`, `Grow`, `Slide`, `Zoom` | Show and hide one child by opacity, scale, an edge or from nothing |\n\n### Overlay & behavior primitives\n\n| Component | Purpose |\n| --------------- | ----------------------------------------------------------------------------------- |\n| `Tooltip` | A short description of one element, shown on hover, keyboard focus and a long touch |\n| `Portal` | Renders children into a DOM node outside the parent hierarchy |\n| `FocusTrap` | Keeps focus inside a subtree |\n| `Modal` | Dialog primitive composing `Portal`, `Backdrop`, and `FocusTrap` |\n| `Popover` | Anchored floating surface built on `Modal` |\n| `ThemeProvider` | Supplies the theme and global styles to the app |\n\n---\n\n## Theme tokens\n\nComponents never hardcode colors or sizes - props resolve against scales on the `Theme` object:\n\n| Group | Scales |\n| ------------------ | ------------------------------------------------------------------------------------------------------------- |\n| Color | `palette` (main/light/dark/contrastText per color) · `text` · `background` · `border` · `colorScheme` |\n| Typography | `typography` (variant map) · `fonts` · `fontSizes` · `fontWeights` · `lineHeights` · `letterSpacings` |\n| Space & shape | `space` · `sizes` · `radii` · `borderWidths` · `shadows` |\n| Layout | `breakpoints` (xs/sm/md/lg/xl window classes) · `layout` (columns, margins, panels, top bar per class) |\n| Component scales | `avatar` (size steps) · `skeleton` (wave highlight) |\n| Layering & effects | `zOrder` (appBar/drawer/modal/snackbar/tooltip) · `blur` · `logoFilter` · `portraitBlend` · `portraitOpacity` |\n\nProp types are derived from the interface (`keyof Theme['text']`), so adding a token to `themes.ts` propagates everywhere automatically. See [`design-system.md`](./design-system.md) for the full scale table and the palette rules.\n\n---\n\n## Theming\n\nThe theme belongs to you - the package only ships defaults. This section is the overview; the full guides are [`docs/theming.md`](./docs/theming.md) and [`docs/customization.md`](./docs/customization.md).\n\n### One theme, yours\n\n`ThemeProvider` provides exactly one theme - the built-in dark theme when you pass nothing. Bring one theme, or as many as you like: switching between them is your state, not the provider's.\n\n```tsx\nimport { ThemeProvider } from '@soroush.tech/design-system/theme'\nimport { baseTheme, createTheme } from '@soroush.tech/design-system/theme'\n\n// Zero-config: the built-in `baseTheme`.\n<ThemeProvider>{app}</ThemeProvider>\n\n// Your theme - written from scratch or extended from the base.\nconst brand = createTheme(baseTheme, { palette: { primary: { main: '#00ff88' } } })\n<ThemeProvider theme={brand}>{app}</ThemeProvider>\n\n// Mode switching is app policy - own the state and pass the active theme:\nconst [isDark, setIsDark] = useState(true)\n<ThemeProvider theme={isDark ? brandDark : brandLight}>{app}</ThemeProvider>\n```\n\n`createTheme(base, overrides)` (exported from `@soroush.tech/design-system/theme`) is the merge primitive: plain objects recurse, arrays (`shadows`, `fontSizes`) and functions replace wholesale, `undefined` values are ignored - keys are added or replaced, never removed.\n\n### Breakpoints and layout\n\n`theme.breakpoints` are Material 3's window classes, each a range from its start until the next:\n`xs` 0-599px (compact, the base), `sm` 600-839 (medium), `md` 840-1199 (expanded), `lg`\n1200-1599 (large), `xl` 1600+ (extra-large). Responsive props use them by name or position -\n`p={{ xs: 2, md: 4 }}`, `p={[2, 3, 4]}` - and `cqSm`-style keys write container queries;\n`theme.breakpoints.up('md')` and its siblings write queries for hand-written styles. Everything is\nCSS, so pages work with JavaScript off. `theme.layout` holds the layout tokens per class (columns,\nmargins, gutters, side panels, top bar); `Grid` and `Flex` apply the column grid with\n`layout` / `layout={{ lg: { columns: 16 } }}`, and apps place `AppBar`, `Sidebar` and `Drawer`\nthemselves. The full guide is the\n[Breakpoints and layout](./docs/theming.md#breakpoints-and-layout) section of the theming guide.\n\n### Component defaults\n\nComponents carry visible literal fallbacks (`size = 'md'`, `variant = 'outside'`, ...) resolved through `themeDefault(theme, key, fallback)` - so every default, including behavioral variants, is overridable via the optional `theme.defaults` map or the provider's `defaults` prop:\n\n| Key | Fallback | Drives |\n| -------------------------------------------- | ---------------------------------- | -------------------------------------- |\n| `size` / `compactSize` | `'md'` / `'sm'` | sized components / dense table actions |\n| `color` / `neutralColor` | `'primary'` / `'default'` | accent controls / toggle controls |\n| `textColor` / `accentTextColor` | `'initial'` / `'primary'` | body text / icons + input labels |\n| `bg` / `surfaceBg` / `inputBg` | `'default'`/`'paper'`/`'terminal'` | switch track / paper surfaces / inputs |\n| `borderRadius` / `surfaceRadius` | `'md'` / `'sq'` | grouped controls / surfaces |\n| `avatarSize` / `borderColor` / `borderWidth` | `'md'` / `'primary'` / `'thin'` | avatars and rings |\n| `iconSize` | `'lg'` | Icon default glyph size (`theme.icon`) |\n| `inputMinWidth` | `'12rem'` | least width of an input not full width |\n| `buttonVariant` / `switchVariant` | `'contained'` / `'outside'` | Button / Switch visual variants |\n| `inputVariant` | `'default'` | TextInput, Select, NativeSelect frames |\n| `avatarVariant` / `cardVariant` | `'circular'` / `'paper'` | Avatar shape / Card treatment |\n| `linkUnderline` | `'always'` | Link underline behavior |\n| `paginationVariant` / `paginationShape` | `'text'` / `'circular'` | Pagination items |\n\nThe built-in themes carry no `defaults` - the literals apply. A theme with entirely different size or palette keys stays valid by pointing the keys at its own tokens:\n\n```tsx\n<ThemeProvider defaults={{ size: 'compact', color: 'brand', switchVariant: 'inside' }}>\n```\n\n### Per-component customization (`theme.components`)\n\nCustomize one component for the whole app - default prop values, per-slot CSS, and new variant values - without wrapping or forking:\n\n```tsx\nconst brand = createTheme(baseTheme, {\n components: {\n Button: {\n // Buttons default to sm + rounded; explicit props and ButtonGroup still win.\n defaultProps: { size: 'sm', shape: 'rounded' },\n\n // Per-slot CSS merged after Button's own styles - the theme wins the cascade,\n // but per-instance props (m, p, width, ...) still beat the theme.\n styleOverrides: {\n root: ({ theme, ownerState }) => ({\n letterSpacing: theme.letterSpacings.wide,\n ...(ownerState.variant === 'contained' && { textTransform: 'none' }),\n }),\n label: { fontStyle: 'italic' },\n },\n\n // A new variant value - register it first so it typechecks:\n // declare module '@soroush.tech/design-system/theme' { interface ButtonVariants { dashed: true } }\n variants: [\n {\n props: { variant: 'dashed' },\n style: ({ theme }) => ({\n backgroundColor: 'transparent',\n border: `${theme.borderWidths.thin} dashed ${theme.border.primary}`,\n }),\n },\n ],\n },\n },\n})\n```\n\nStyle callbacks receive `{ theme, ownerState }`, where `ownerState` is the styled root's **resolved** props (after group context, `defaultProps`, and `theme.defaults`). `defaultProps` sits in the standard precedence chain: explicit prop → group context → `defaultProps` → `theme.defaults.*` → the component's literal fallback. `variants` arrays are replaced wholesale by `createTheme`, never merged.\n\nYour own components can join the same mechanism: create their roots with this package's `styled(tag, { name: 'MyWidget', slot: 'root' })` and register the name by augmenting `ThemeComponents`. Zero-config themes pay nothing - the resolver bails out on the first check when `theme.components` is absent.\n\n### Extending tokens (declaration merging)\n\nEvery scale is an open interface declared on `@soroush.tech/design-system/theme`, so you can add palette colors, tokens, or whole scales - and every component prop union (`color`, `bg`, `size`, ...) widens automatically:\n\n```ts\nimport type { PaletteEntry } from '@soroush.tech/design-system/theme'\n\ndeclare module '@soroush.tech/design-system/theme' {\n interface ThemePalette {\n brand: PaletteEntry // new palette color\n }\n interface ThemeBackground {\n tertiary: string // new background token\n }\n interface Theme {\n elevations: Record<'low' | 'mid' | 'high', string> // whole new scale\n }\n}\n```\n\nThen supply the values with `createTheme` and use the new keys:\n\n```tsx\nconst brandDark = createTheme(baseTheme, {\n palette: { brand: { main: '#00ff88', light: '#66ffb2', dark: '#00b25f', contrastText: '#000' } },\n background: { tertiary: '#101418' },\n elevations: { low: '0 1px 2px', mid: '0 2px 6px', high: '0 6px 18px' },\n})\n\n<ThemeProvider theme={brandDark}>\n <Button color=\"brand\" />\n <View bg=\"tertiary\" />\n</ThemeProvider>\n```\n\nNotes: new object-valued keys (like a `PaletteEntry`) must be supplied complete - components read `.main`/`.contrastText` at runtime; and TypeScript cannot verify at runtime that an augmented token was actually supplied, so always pair an augmentation with the matching override.\n\n---\n\n## Adding a component\n\nScaffold with the skill - it reads the live `Typography` files and `design-system.md` so output matches the codebase:\n\n```\n/new_theme_component ComponentName\n```\n\nThen work through the checklist at the bottom of [`design-system.md`](./design-system.md).\n\n---\n\nThe library takes inspiration from [Material UI](https://mui.com/) - its component vocabulary and prop conventions will feel familiar - but it is written entirely in house. It is not a clone or a fork: every component is built from scratch on our own engine and token system, and the API is free to diverge wherever it serves its consumers better.\n\n---\n\n## Release notes\n\nPer-version notes for every published release live in\n[`release-notes/`](https://github.com/soroush-tech/design-system/tree/main/packages/design-system/release-notes).\n",
|
|
1377
1377
|
"url": "https://docs.soroush.tech/design-system/"
|
|
1378
1378
|
},
|
|
1379
1379
|
{
|
|
@@ -1387,7 +1387,7 @@ const content = {
|
|
|
1387
1387
|
"id": "styled-system-overview",
|
|
1388
1388
|
"title": "Styled-system overview",
|
|
1389
1389
|
"summary": "The style-prop engine underneath the design system.",
|
|
1390
|
-
"body": "A maintained, first-class-TypeScript rewrite of [styled-system](https://github.com/jxnblk/styled-system) v5 - responsive, theme-aware style props for CSS-in-JS.\n\nIt is a **drop-in replacement** for the `styled-system` runtime: the root export surface matches upstream verbatim, and the package ships its own types (replacing `@types/styled-system`).\n\n## Features\n\n- Add style props that hook into your own theme\n- Quickly set responsive `font-size`, `margin`, `padding`, `gap`, `width`, and more with props\n- Influenced by constraint-based design-system principles\n- Typographic scale, and a spacing scale for `margin`, `padding` and `gap`\n- Works with any color palette\n- Works with most CSS-in-JS libraries, including [Emotion](https://emotion.sh) and [styled-components](https://styled-components.com)\n- First-class TypeScript types - theme-scale-aware props, replacing `@types/styled-system`\n\n## Install\n\n```sh\n# npm\nnpm install @soroush.tech/styled-system\n```\n\n```sh\n# pnpm\npnpm add @soroush.tech/styled-system\n```\n\n```sh\n# yarn\nyarn add @soroush.tech/styled-system\n```\n\n
|
|
1390
|
+
"body": "A maintained, first-class-TypeScript rewrite of [styled-system](https://github.com/jxnblk/styled-system) v5 - responsive, theme-aware style props for CSS-in-JS.\n\nIt is a **drop-in replacement** for the `styled-system` runtime: the root export surface matches upstream verbatim, and the package ships its own types (replacing `@types/styled-system`).\n\n## Features\n\n- Add style props that hook into your own theme\n- Quickly set responsive `font-size`, `margin`, `padding`, `gap`, `width`, and more with props\n- Influenced by constraint-based design-system principles\n- Typographic scale, and a spacing scale for `margin`, `padding` and `gap`\n- Works with any color palette\n- Works with most CSS-in-JS libraries, including [Emotion](https://emotion.sh) and [styled-components](https://styled-components.com)\n- First-class TypeScript types - theme-scale-aware props, replacing `@types/styled-system`\n\n## Install\n\n```sh\n# npm\nnpm install @soroush.tech/styled-system\n```\n\n```sh\n# pnpm\npnpm add @soroush.tech/styled-system\n```\n\n```sh\n# yarn\nyarn add @soroush.tech/styled-system\n```\n\n`prop-types` (`^15.8.1`, optional peer) is used by a single [subpath](#subpath-imports),\n`prop-types`. Install it only if you import that subpath. The `should-forward-prop` subpath\nneeds nothing installed: its check for a valid attribute is a dependency of this package. You bring your own CSS-in-JS\nlibrary (Emotion, styled-components, ...); the core carries neither at runtime.\n\n## Usage\n\n```ts\n// Example uses Emotion, but styled-system works with most other CSS-in-JS libraries as well\nimport styled from '@emotion/styled'\nimport { space, layout, typography, color } from '@soroush.tech/styled-system'\n\n// Add styled-system functions to your component\nconst Box = styled.div`\n ${space}\n ${layout}\n ${typography}\n ${color}\n`\n```\n\nEach style function exposes its own set of component props that handle styles based on values defined in a theme.\n\n```tsx\n// width: 50%\n<Box width={1 / 2} />\n\n// font-size: 20px (theme.fontSizes[4])\n<Box fontSize={4} />\n\n// margin: 16px (theme.space[2])\n<Box m={2} />\n\n// padding: 32px (theme.space[3])\n<Box p={3} />\n\n// color\n<Box color=\"tomato\" />\n\n// color: #333 (theme.colors.gray[0])\n<Box color=\"gray.0\" />\n\n// background-color\n<Box bg=\"tomato\" />\n```\n\n### Responsive style props\n\nSet responsive `width`, `margin`, `padding`, `font-size`, and other properties with a shorthand array syntax. See [Responsive Styles](./docs/responsive-styles.md).\n\n```tsx\n// responsive width\n<Box width={[1, 1 / 2, 1 / 4]} />\n\n// responsive font-size\n<Box fontSize={[2, 3, 4]} />\n\n// responsive margin\n<Box m={[1, 2, 3]} />\n\n// responsive padding\n<Box p={[1, 2, 3]} />\n```\n\n### Subpath imports\n\nSubpaths mirror the original `@styled-system/*` packages:\n\n```ts\nimport { css } from '@soroush.tech/styled-system/css'\nimport { themeGet } from '@soroush.tech/styled-system/theme-get'\nimport { pick, omit } from '@soroush.tech/styled-system/props'\nimport propTypes, { createPropTypes } from '@soroush.tech/styled-system/prop-types'\nimport shouldForwardProp, {\n createShouldForwardProp,\n props,\n} from '@soroush.tech/styled-system/should-forward-prop'\n```\n\n## Drop-in via alias\n\nExisting `styled-system` users can swap with a package-manager alias - no code changes:\n\n```jsonc\n\"dependencies\": {\n \"styled-system\": \"npm:@soroush.tech/styled-system@^5\"\n}\n```\n\nThe satellite `@styled-system/*` packages don't need separate aliases - import them as\nsubpaths off the aliased `styled-system` name, and they resolve through this package's\n`exports`:\n\n```ts\nimport themeGet from 'styled-system/theme-get'\nimport propTypes from 'styled-system/prop-types'\nimport { css } from 'styled-system/css'\nimport shouldForwardProp from 'styled-system/should-forward-prop'\n```\n\nTypes resolve under both modern module resolution (`node16`/`nodenext`/`bundler`, via\n`exports`) and classic `node` (via `typesVersions`).\n\n## Documentation\n\nFull docs live in [`docs/`](./docs/README.md):\n\n- [Getting Started](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/docs/getting-started.md)\n- [Responsive Styles](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/docs/responsive-styles.md)\n- [How it Works](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/docs/how-it-works.md)\n- [Custom Props](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/docs/custom-props.md)\n- [Variants](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/docs/variants.md)\n- [API](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/docs/api.md)\n- [Reference Table](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/docs/table.md)\n- [TypeScript](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/docs/typescript.md)\n- [Guides](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/docs/guides/index.md)\n\nRunnable demos live in the [examples repo](https://github.com/soroush-tech/examples/tree/main/styled-system).\n\n## Release notes\n\nPer-version notes for every published release live in\n[`release-notes/`](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/release-notes).\n\n## License\n\nMIT - a rewrite of styled-system (© 2017-2021 Brent Jackson), see [`LICENSE`](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/LICENSE).\n",
|
|
1391
1391
|
"url": "https://docs.soroush.tech/styled-system/"
|
|
1392
1392
|
},
|
|
1393
1393
|
{
|
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
// src/content.ts
|
|
4
4
|
const content = {
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "3.0.0-alpha.0",
|
|
6
6
|
"components": [
|
|
7
7
|
{
|
|
8
8
|
"name": "ScrollArea",
|
|
@@ -1320,7 +1320,7 @@ const content = {
|
|
|
1320
1320
|
"id": "installation",
|
|
1321
1321
|
"title": "Installation",
|
|
1322
1322
|
"summary": "Install the packages and their peer dependencies.",
|
|
1323
|
-
"body": "# Installation\n\nInstall the design system and its peer dependencies:\n\n```sh\nnpm i @soroush.tech/design-system react react-dom\n```\n\n
|
|
1323
|
+
"body": "# Installation\n\n## Start a new app\n\nTo start a new app on the design system - a Vike app, prerendered at build time, that then moves\nbetween pages with no reload - in TypeScript or JavaScript:\n\n```sh\nnpx @soroush.design/cli create my-app\n```\n\nIt makes the app in a new folder, with the themes, the providers and a few pages, shows every file\nfirst, and installs it with the package manager you ran it with. Add `--sample-data`, or answer\nyes to its question, for two pages that show how data gets onto a page: a list of sample items,\nand a page for each. Its options are in the\n[command line](/cli/) docs. For an app you already have, use `init`, below.\n\n## Set it up with one command\n\nIn a client-rendered React app - built with Vite, webpack, Rspack, Parcel or Create React App,\nin TypeScript or JavaScript - one command sets the design system up:\n\n```sh\nnpx @soroush.design/cli init\n```\n\nIt shows every change before it makes one, and writes nothing until you say yes:\n\n- `src/theme/themes` - a `light` and a `dark` theme, each a `createTheme(baseTheme, {...})` call\n you make your own;\n- `src/theme/Providers` - the `ThemeProvider` with the base page styles;\n- your root - what it renders is wrapped in `<Providers>`;\n- the install of `@soroush.tech/design-system`, with your own package manager.\n\nIt runs in a git repository with no uncommitted change, never overwrites a file, and takes back\nevery change if a write fails. Run in a workspace's root, it sets up the one app in it. Add\n`--dry-run` to see the changes and exit. In PowerShell, quote the package name, since `@` starts a\nsplat there: `npx '@soroush.design/cli' init`.\n\nEvery option, and what `init` checks first, are in the [command line](/cli/) docs. Next.js, Vike\nand React Router apps are not supported by `init` yet: set those up by hand, below.\n\n## Or set it up by hand\n\nInstall the design system and its peer dependencies:\n\n```sh\nnpm i @soroush.tech/design-system react react-dom\n```\n\nReact 19.2 or later is required.\n\n### Set up the ThemeProvider\n\nEvery component reads its colors, spacing, and typography from the theme. Wrap your app once:\n\n```tsx\nimport { ThemeProvider, baseTheme, createTheme } from '@soroush.tech/design-system/theme'\n\nconst theme = createTheme(baseTheme, {\n // Your brand overrides - palettes, backgrounds, text colors, ...\n})\n\nexport function App() {\n return <ThemeProvider theme={theme}>{/* your app */}</ThemeProvider>\n}\n```\n\n`baseTheme` is a complete dark-schemed default, so an empty override object is a valid start.\nSee [Theming](/design-system/customization/theming/) for building light and dark brand themes.\n\n## Fonts\n\nThe theme's default stacks reference Space Grotesk (body) and JetBrains Mono (code). Self-host\nthem with Fontsource, or swap the `fonts` scale to your own faces:\n\n```sh\nnpm i @fontsource-variable/space-grotesk @fontsource-variable/jetbrains-mono\n```\n\n```ts\nimport '@fontsource-variable/space-grotesk/wght.css'\nimport '@fontsource-variable/jetbrains-mono/wght.css'\n```\n",
|
|
1324
1324
|
"url": "https://docs.soroush.tech/design-system/getting-started/installation/"
|
|
1325
1325
|
},
|
|
1326
1326
|
{
|
|
@@ -1334,21 +1334,21 @@ const content = {
|
|
|
1334
1334
|
"id": "theming",
|
|
1335
1335
|
"title": "Theming",
|
|
1336
1336
|
"summary": "The Theme type, the scales it carries, and how createTheme composes one.",
|
|
1337
|
-
"body": "# Theming\n\nThe theme belongs to you - the package ships defaults, every part is replaceable, and the type system widens with your extensions. This guide covers the full ladder, from using the built-ins to owning every token.\n\n## The ladder\n\n1. **Use the default** - `<ThemeProvider>` with no props renders the built-in `baseTheme` (dark-schemed).\n2. **Override values** - build your theme with `createTheme(base, overrides)` and pass it via `theme`.\n3. **Repoint component defaults** - `theme.defaults` / the provider's `defaults` prop change what components fall back to.\n4. **Extend the type system** - declaration merging adds palette colors, scale keys, and whole scales.\n5. **Customize single components** - `theme.components` (see [customization.md](./customization.md)).\n\n---\n\n## One theme, yours\n\n`ThemeProvider` provides exactly one theme. The package ships a single complete default - `baseTheme` - and you derive every mode from it; switching (dark/light, or ten brand modes) is your state:\n\n```tsx\nimport { ThemeProvider } from '@soroush.tech/design-system/theme'\nimport { baseTheme, createTheme } from '@soroush.tech/design-system/theme'\n\nconst dark = createTheme(baseTheme, { name: 'dark' /* your palettes */ })\nconst light = createTheme(baseTheme, { name: 'light', colorScheme: 'light' /* your palettes */ })\n\nconst [isDark, setIsDark] = useState(true)\n<ThemeProvider theme={isDark ? dark : light}>{app}</ThemeProvider>\n```\n\n## Building themes with `createTheme`\n\n`createTheme(base, overrides)` deep-merges sparse patches onto a base theme:\n\n```ts\nimport { baseTheme, createTheme } from '@soroush.tech/design-system/theme'\n\nexport const brandDark = createTheme(baseTheme, {\n palette: { primary: { main: '#00ff88' } }, // sibling fields (light/dark/contrastText) survive\n radii: { md: '10px' },\n shadows: ['none'], // arrays replace wholesale, never merge\n})\n```\n\nMerge rules: plain objects recurse; arrays (`shadows`, `fontSizes`) and functions replace wholesale; `undefined` values are ignored - keys are added or replaced, never removed. Neither argument is mutated.\n\n## Component defaults (`theme.defaults`)\n\nComponents carry visible literal fallbacks (`size = 'md'`, `variant = 'outside'`, ...) resolved through `themeDefault(theme, key, fallback)`. The optional `theme.defaults` map overrides any of them globally - essential when your theme uses entirely different size or palette keys:\n\n```tsx\n<ThemeProvider defaults={{ size: 'compact', color: 'brand', switchVariant: 'inside' }}>\n```\n\nThe full key table lives in the [README's Theming section](../README.md#component-defaults). The built-in `baseTheme` carries no `defaults` - the literals apply until you say otherwise. For _per-component_ defaults (only Buttons compact), use `theme.components.X.defaultProps` instead ([customization.md](./customization.md)).\n\n## Extending the type system\n\nEvery scale is an open interface owned by `@soroush.tech/design-system/theme` - that module (not Emotion, an internal implementation detail) is the augmentation surface, and it merges reliably across tsdown's chunked d.ts for every consumer:\n\n```ts\nimport type { PaletteEntry, SizeEntry } from '@soroush.tech/design-system/theme'\n\ndeclare module '@soroush.tech/design-system/theme' {\n interface ThemePalette {\n brand: PaletteEntry // new palette color\n }\n interface ThemeBackground {\n tertiary: string // new background token\n }\n interface ThemeSizes {\n xl: SizeEntry // new size step\n }\n interface Theme {\n elevations: Record<'low' | 'mid' | 'high', string> // whole new scale\n }\n}\n```\n\nComponent prop unions derive via `keyof Theme['scale']`, so `color=\"brand\"`, `bg=\"tertiary\"`, and `size=\"xl\"` typecheck everywhere automatically. Then supply the values:\n\n```ts\nconst brand = createTheme(baseTheme, {\n palette: { brand: { main: '#00ff88', light: '#66ffb2', dark: '#00b25f', contrastText: '#000' } },\n background: { tertiary: '#101418' },\n sizes: { xl: { paddingTop: 2, paddingBottom: 2, paddingLeft: 4, paddingRight: 4, fontSize: 2 } },\n elevations: { low: '0 1px 2px', mid: '0 2px 6px', high: '0 6px 18px' },\n defaults: { size: 'xl' }, // components may default to augmented keys\n})\n```\n\nTwo rules: new object-valued keys (like a `PaletteEntry`) must be supplied complete - components read `.main`/`.contrastText` at runtime; and TypeScript cannot verify at runtime that an augmented token was supplied - **always pair an augmentation with the matching override**.\n\n## Breakpoints and layout\n\n`theme.breakpoints` and `theme.layout` hold the page's layout system: where it changes, how many\ncolumns it has, its margins and gutters, its side panels and the top bar. Everything responsive is\nCSS - no component measures the window in JavaScript - so a prerendered page lays out the same\nwith JavaScript off. The design system ships these as tokens and building blocks (`AppBar`,\n`Sidebar`, `Drawer`, `Grid`, `Flex`); each app composes its own pages from them.\n\n### `theme.breakpoints` - window classes\n\nEach key is a range: its value is where the range starts, and it holds until the next key. The\ntheme writes the start because media queries are min-width. `xs` starts at 0, so it applies\neverywhere until `sm` overrides it.\n\n```ts\nbreakpoints: { xs: '0px', sm: '600px', md: '840px', lg: '1200px', xl: '1600px' }\n```\n\n| Key | Range | Material 3 window class |\n| ---- | ----------- | ----------------------- |\n| `xs` | 0-599px | compact |\n| `sm` | 600-839px | medium |\n| `md` | 840-1199px | expanded |\n| `lg` | 1200-1599px | large |\n| `xl` | 1600px+ | extra-large |\n\nThey are window classes, not devices: a class is about the space the window has. Responsive props\nuse them by name - each key from its size up - or by position:\n\n```tsx\n<View display={{ xs: 'none', md: 'block' }} />\n<View p={[2, 3, 4]} /> // xs, sm, md\n<View p={{ xs: 2, cqSm: 4 }} /> // cq keys: container queries on the same sizes\n```\n\nFor hand-written styles, `theme.breakpoints` carries the query helpers (also exported for\n`baseTheme` as `up`, `down`, `only`, `between`, `not` and `containerQueries`):\n\n```ts\nconst Panel = styled.div(({ theme }) => ({\n padding: 16,\n [theme.breakpoints.down('sm')]: { padding: 8 }, // @media (width < 600px)\n [theme.breakpoints.only('md')]: { padding: 24 }, // @media (840px <= width < 1200px)\n}))\n```\n\nEvery form, the container queries, the units and the order blocks are written in are covered in\nthe styled-system [Breakpoints](https://docs.soroush.tech/styled-system/docs/breakpoints/) guide.\n\n### `theme.layout` - layout tokens per window class\n\n`xs` is complete; each later class lists only what changes and is merged over the ones before it.\nWith `baseTheme`:\n\n| Class | Columns | Margin / gutter | Content | Start panel | End panel | Top bar |\n| ----- | ------- | --------------- | ---------- | ----------- | ----------- | ------- |\n| `xs` | 4 | 16 / 16 | fluid | hidden | hidden | 64 |\n| `sm` | 8 | 32 / 16 | fluid | rail 72 | hidden | 64 |\n| `md` | 12 | 24 / 24 | fluid | rail 72 | overlay 360 | 64 |\n| `lg` | 12 | 24 / 24 | fixed 1200 | rail 72 | overlay 412 | 64 |\n| `xl` | 12 | 24 / 24 | fixed 1600 | inline 280 | inline 412 | 64 |\n\n- **Units** - `margin` and `gutter` are `theme.space` keys, so they move with the spacing scale.\n Bar heights, panel widths and `maxWidth` take a space key or any CSS length.\n- **Columns** - 1 to 16. 12 is the default from `md` up.\n- **Panels** - `start` and `end` follow the writing direction (they swap in RTL). `mode` is\n `inline` (beside the content at `width`), `collapsed` (a rail at `railWidth`), `overlay` (over\n the content at `width`) or `hidden`. A panel first declared at a later class needs its `mode`,\n `width` and `railWidth` there.\n- **Bars** - `top` (and an optional `bottom`) heights; `0` removes an inherited bar.\n\nThese are tokens: the app places its own `AppBar`, `Sidebar` and `Drawer` with them, and the\ndesign studio draws them on its frames.\n\n### The `layout` prop - the page frame everywhere, the columns on a Grid\n\n`layout` turns the content tokens into CSS per window class. On any `View`-based component -\n`Flex` included - it is the **frame**: the margin and the max width, and the element keeps its\nown display. `Grid` adds the **columns** on top of that frame:\n\n```tsx\n<View layout>...</View> // the theme's frame\n<Flex layout gap={3}>...</Flex> // the frame, a flex column inside\n<Grid layout>...</Grid> // the frame and the theme's columns\n<Grid layout gap={2}>...</Grid> // its own gutter: 16px at every class\n<Grid layout gap={{ xs: 2, md: 4 }}>...</Grid> // 16px, then 32px from md up\n<Grid layout={{ lg: { columns: 16 } }}>...</Grid> // 16 columns from lg up\n<Grid layout={{ maxWidth: '1280px', md: { columns: 6 } }}>...</Grid> // both\n```\n\n- **The frame** - the full width of its parent (`width: 100%`, border-box) with the margin as\n `padding-inline`; in fixed mode capped by `max-width` and centred. It spans its parent in any\n context - a block, a grid item, a flex column or row - so the frame owns its width: size it\n with `maxWidth`, not `width`.\n- **Grid** - `grid-template-columns: repeat(N, minmax(0, 1fr))` and the gutter as `column-gap`.\n- **The gutter is the grid's `gap`** - its own `gap` or `columnGap` (`columnGap` wins), single,\n per class (`{ md: 4 }`) or as an array, sets `column-gap` at every class it covers; where it is\n not set, the theme's gutter applies. Rows take `gap`'s row half or `rowGap`. On a `Flex` or a\n `View`, `gap` is plain flexbox spacing.\n- **Children take `span`** - how many columns of a grid an element takes, on any `View`-based\n component: `span={6}`, per class `span={{ xs: 4, md: 6 }}`, or `span=\"full\"` for the whole row\n whatever the column count (`grid-column: 1 / -1`, in any grid).\n- A field in the value (`maxWidth: '1280px'`) replaces the theme's at every class; whatever it\n does not set still follows the theme. An entry under a class name replaces it **from that class\n up**, mobile-first like every responsive prop, on top of the fields.\n- **The layout owns the column tracks, inline padding and max width** it writes: an explicit\n `gridTemplateColumns`, padding or `maxWidth` on the same element does not override them from the\n second class up. A grid with tracks of its own leaves `layout` off and sits inside a frame.\n\n### Layout: one way per intent\n\nGenerated code, agents and people write each layout intent one way:\n\n| Intent | Write | Not |\n| ------------------------------------------------ | ----------------------------------------------------------- | --------------------------------------------------------- |\n| Content on the page frame, no columns | `<View layout>`, or `<Flex layout>` for a flex stack or row | `maxWidth` + `mx=\"auto\"` + `px`, a custom frame component |\n| A section on the theme's columns | `<Grid layout>` | hand-written tracks on a page section, `Flex` with widths |\n| The app's layout | `theme.layout`, built with `createTheme` | layout values written on every page |\n| A page's (or a region's) own layout | `<LayoutProvider layout={...}>` around the page | the same `layout` value on each section, a nested theme |\n| A section's own columns, margin or max width | `layout={{ md: { columns: 6 } }}`, `layout={{ maxWidth }}` | helpers that repeat a value per class |\n| A section's own gutter | `gap={2}` / `gap={{ xs: 2, md: 4 }}` on the `Grid` | a `gutter` field, `gap` and `columnGap` both |\n| A child taking N columns | `span={6}` / `span={{ xs: 4, md: 6 }}` | `gridColumn=\"span 6\"` |\n| A child taking the whole row | `span=\"full\"` | `grid-column: 1 / -1`, `style`, column-count objects |\n| Space between rows only | `rowGap` | margins on the children |\n| A grid with tracks of its own (`auto-fill`, ...) | a plain `Grid` without `layout`, inside a frame | `layout` plus `gridTemplateColumns` |\n\nThe same page without the prop needs every value written out - and stops following the theme:\n\n```tsx\n<Grid\n gridTemplateColumns={{\n xs: 'repeat(4, minmax(0, 1fr))',\n sm: 'repeat(8, minmax(0, 1fr))',\n md: 'repeat(12, minmax(0, 1fr))',\n }}\n columnGap={{ xs: 2, md: 3 }}\n px={{ xs: 2, sm: 4, md: 3 }}\n>\n ...\n</Grid>\n```\n\n### Your own breakpoints and layout\n\nOverride values with `createTheme`, like any scale:\n\n```ts\nconst theme = createTheme(baseTheme, {\n breakpoints: { md: '900px' },\n layout: { lg: { content: { maxWidth: '1280px' } } },\n})\n```\n\nThe helpers on `theme.breakpoints` are rebuilt from the merged sizes. `createTheme` merges, so\nit can change values and add a larger breakpoint after the existing ones, but not remove or rename\none. To use your own names, declare them by augmenting `BreakpointOverrides` (`true` adds a name,\n`false` removes a default) and replace the scale and the layout on the base:\n\n```ts\ndeclare module '@soroush.tech/design-system/theme' {\n interface BreakpointOverrides {\n mobile: true\n tablet: true\n web: true\n xs: false\n sm: false\n md: false\n lg: false\n xl: false\n }\n}\n\nconst theme = createTheme(\n {\n ...baseTheme,\n breakpoints: withBreakpointHelpers({ mobile: '0px', tablet: '768px', web: '1280px' }),\n layout: { mobile: { ...a complete entry... }, tablet: { ... }, web: { ... } },\n },\n {}\n)\n```\n\nResponsive props, `cq` keys (`cqTablet`), the helpers and the `layout` keys all follow the new\nnames.\n\n## The scale interfaces\n\n| Scale | Key in Theme | Interface |\n| --------------- | ---------------------- | ------------------------- |\n| Palette | `theme.palette` | `ThemePalette` |\n| Text colors | `theme.text` | `ThemeText` |\n| Backgrounds | `theme.background` | `ThemeBackground` |\n| Borders | `theme.border` | `ThemeBorder` |\n| Space | `theme.space` | `ThemeSpace` |\n| Breakpoints | `theme.breakpoints` | `ThemeBreakpoints` |\n| Layout | `theme.layout` | `ThemeLayout` |\n| Sizes | `theme.sizes` | `ThemeSizes` |\n| Radii | `theme.radii` | `ThemeRadii` |\n| Border widths | `theme.borderWidths` | `ThemeBorderWidths` |\n| Fonts | `theme.fonts` | `ThemeFonts` |\n| Font weights | `theme.fontWeights` | `ThemeFontWeights` |\n| Line heights | `theme.lineHeights` | `ThemeLineHeights` |\n| Letter spacings | `theme.letterSpacings` | `ThemeLetterSpacings` |\n| Typography | `theme.typography` | `ThemeTypographyVariants` |\n| Avatar sizes | `theme.avatar` | `ThemeAvatarSizes` |\n| Icon sizes | `theme.icon` | `ThemeIconSizes` |\n| Switch tokens | `theme.switch` | `ThemeSwitch` |\n| Shadow tokens | `theme.shadow` | `ThemeShadow` |\n\n## The spacing scale\n\n`theme.space` steps on an 8px unit, and every step is a whole pixel. The same steps serve padding,\nmargin, `gap` / `rowGap` / `columnGap`, the `layout` margin and the grid's gutter:\n\n| Step | `0` | `0.125` | `0.25` | `0.5` | `0.75` | `1` | `1.25` | `1.5` | `1.75` | `2` | `3` | `4` | `5` | `6` | `7` | `8` | `9` | `10` |\n| ---- | --- | ------- | ------ | ----- | ------ | --- | ------ | ----- | ------ | --- | --- | --- | --- | --- | --- | --- | --- | ---- |\n| px | 0 | 1 | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 24 | 32 | 40 | 48 | 56 | 64 | 72 | 80 |\n\nBelow 4px, lines are border widths (`theme.borderWidths`). Use `0.125` and `0.25` only for a gap\nthat should be a hairline - a 1px or 2px gap the background shows through, as in a grid of tiles\non a coloured `Grid`: `<Grid layout gap={0.125} bg=\"grid\">`.\n| Defaults | `theme.defaults` | `ThemeDefaults` |\n| Components | `theme.components` | `ThemeComponents` |\n\nThe contract is verified against the real published d.ts by `type-tests/augmentation.ts` (`pnpm test:types`), so it can't silently break in a release.\n",
|
|
1337
|
+
"body": "# Theming\n\nThe theme belongs to you - the package ships defaults, every part is replaceable, and the type system widens with your extensions. This guide covers the full ladder, from using the built-ins to owning every token.\n\n## The ladder\n\n1. **Use the default** - `<ThemeProvider>` with no props renders the built-in `baseTheme` (dark-schemed).\n2. **Override values** - build your theme with `createTheme(base, overrides)` and pass it via `theme`.\n3. **Repoint component defaults** - `theme.defaults` / the provider's `defaults` prop change what components fall back to.\n4. **Extend the type system** - declaration merging adds palette colors, scale keys, and whole scales.\n5. **Customize single components** - `theme.components` (see [customization.md](./customization.md)).\n\n---\n\n## One theme, yours\n\n`ThemeProvider` provides exactly one theme. The package ships a single complete default - `baseTheme` - and you derive every mode from it; switching (dark/light, or ten brand modes) is your state:\n\n```tsx\nimport { ThemeProvider } from '@soroush.tech/design-system/theme'\nimport { baseTheme, createTheme } from '@soroush.tech/design-system/theme'\n\nconst dark = createTheme(baseTheme, { name: 'dark' /* your palettes */ })\nconst light = createTheme(baseTheme, { name: 'light', colorScheme: 'light' /* your palettes */ })\n\nconst [isDark, setIsDark] = useState(true)\n<ThemeProvider theme={isDark ? dark : light}>{app}</ThemeProvider>\n```\n\n## Building themes with `createTheme`\n\n`createTheme(base, overrides)` deep-merges sparse patches onto a base theme:\n\n```ts\nimport { baseTheme, createTheme } from '@soroush.tech/design-system/theme'\n\nexport const brandDark = createTheme(baseTheme, {\n palette: { primary: { main: '#00ff88' } }, // sibling fields (light/dark/contrastText) survive\n radii: { md: '10px' },\n shadows: ['none'], // arrays replace wholesale, never merge\n})\n```\n\nMerge rules: plain objects recurse; arrays (`shadows`, `fontSizes`) and functions replace wholesale; `undefined` values are ignored - keys are added or replaced, never removed. Neither argument is mutated.\n\n## Component defaults (`theme.defaults`)\n\nComponents carry visible literal fallbacks (`size = 'md'`, `variant = 'outside'`, ...) resolved through `themeDefault(theme, key, fallback)`. The optional `theme.defaults` map overrides any of them globally - essential when your theme uses entirely different size or palette keys:\n\n```tsx\n<ThemeProvider defaults={{ size: 'compact', color: 'brand', switchVariant: 'inside' }}>\n```\n\nThe full key table lives in the [README's Theming section](../README.md#component-defaults). The built-in `baseTheme` carries no `defaults` - the literals apply until you say otherwise. For _per-component_ defaults (only Buttons compact), use `theme.components.X.defaultProps` instead ([customization.md](./customization.md)).\n\n## Extending the type system\n\nEvery scale is an open interface owned by `@soroush.tech/design-system/theme` - that module (not the styling engine, an internal implementation detail) is the augmentation surface, and it merges reliably across tsdown's chunked d.ts for every consumer:\n\n```ts\nimport type { PaletteEntry, SizeEntry } from '@soroush.tech/design-system/theme'\n\ndeclare module '@soroush.tech/design-system/theme' {\n interface ThemePalette {\n brand: PaletteEntry // new palette color\n }\n interface ThemeBackground {\n tertiary: string // new background token\n }\n interface ThemeSizes {\n xl: SizeEntry // new size step\n }\n interface Theme {\n elevations: Record<'low' | 'mid' | 'high', string> // whole new scale\n }\n}\n```\n\nComponent prop unions derive via `keyof Theme['scale']`, so `color=\"brand\"`, `bg=\"tertiary\"`, and `size=\"xl\"` typecheck everywhere automatically. Then supply the values:\n\n```ts\nconst brand = createTheme(baseTheme, {\n palette: { brand: { main: '#00ff88', light: '#66ffb2', dark: '#00b25f', contrastText: '#000' } },\n background: { tertiary: '#101418' },\n sizes: { xl: { paddingTop: 2, paddingBottom: 2, paddingLeft: 4, paddingRight: 4, fontSize: 2 } },\n elevations: { low: '0 1px 2px', mid: '0 2px 6px', high: '0 6px 18px' },\n defaults: { size: 'xl' }, // components may default to augmented keys\n})\n```\n\nTwo rules: new object-valued keys (like a `PaletteEntry`) must be supplied complete - components read `.main`/`.contrastText` at runtime; and TypeScript cannot verify at runtime that an augmented token was supplied - **always pair an augmentation with the matching override**.\n\n## Breakpoints and layout\n\n`theme.breakpoints` and `theme.layout` hold the page's layout system: where it changes, how many\ncolumns it has, its margins and gutters, its side panels and the top bar. Everything responsive is\nCSS - no component measures the window in JavaScript - so a prerendered page lays out the same\nwith JavaScript off. The design system ships these as tokens and building blocks (`AppBar`,\n`Sidebar`, `Drawer`, `Grid`, `Flex`); each app composes its own pages from them.\n\n### `theme.breakpoints` - window classes\n\nEach key is a range: its value is where the range starts, and it holds until the next key. The\ntheme writes the start because media queries are min-width. `xs` starts at 0, so it applies\neverywhere until `sm` overrides it.\n\n```ts\nbreakpoints: { xs: '0px', sm: '600px', md: '840px', lg: '1200px', xl: '1600px' }\n```\n\n| Key | Range | Material 3 window class |\n| ---- | ----------- | ----------------------- |\n| `xs` | 0-599px | compact |\n| `sm` | 600-839px | medium |\n| `md` | 840-1199px | expanded |\n| `lg` | 1200-1599px | large |\n| `xl` | 1600px+ | extra-large |\n\nThey are window classes, not devices: a class is about the space the window has. Responsive props\nuse them by name - each key from its size up - or by position:\n\n```tsx\n<View display={{ xs: 'none', md: 'block' }} />\n<View p={[2, 3, 4]} /> // xs, sm, md\n<View p={{ xs: 2, cqSm: 4 }} /> // cq keys: container queries on the same sizes\n```\n\nFor hand-written styles, `theme.breakpoints` carries the query helpers (also exported for\n`baseTheme` as `up`, `down`, `only`, `between`, `not` and `containerQueries`):\n\n```ts\nconst Panel = styled.div(({ theme }) => ({\n padding: 16,\n [theme.breakpoints.down('sm')]: { padding: 8 }, // @media (width < 600px)\n [theme.breakpoints.only('md')]: { padding: 24 }, // @media (840px <= width < 1200px)\n}))\n```\n\nEvery form, the container queries, the units and the order blocks are written in are covered in\nthe styled-system [Breakpoints](https://docs.soroush.tech/styled-system/docs/breakpoints/) guide.\n\n### `theme.layout` - layout tokens per window class\n\n`xs` is complete; each later class lists only what changes and is merged over the ones before it.\nWith `baseTheme`:\n\n| Class | Columns | Margin / gutter | Content | Start panel | End panel | Top bar |\n| ----- | ------- | --------------- | ---------- | ----------- | ----------- | ------- |\n| `xs` | 4 | 16 / 16 | fluid | hidden | hidden | 64 |\n| `sm` | 8 | 32 / 16 | fluid | rail 72 | hidden | 64 |\n| `md` | 12 | 24 / 24 | fluid | rail 72 | overlay 360 | 64 |\n| `lg` | 12 | 24 / 24 | fixed 1200 | rail 72 | overlay 412 | 64 |\n| `xl` | 12 | 24 / 24 | fixed 1600 | inline 280 | inline 412 | 64 |\n\n- **Units** - `margin` and `gutter` are `theme.space` keys, so they move with the spacing scale.\n Bar heights, panel widths and `maxWidth` take a space key or any CSS length.\n- **Columns** - 1 to 16. 12 is the default from `md` up.\n- **Panels** - `start` and `end` follow the writing direction (they swap in RTL). `mode` is\n `inline` (beside the content at `width`), `collapsed` (a rail at `railWidth`), `overlay` (over\n the content at `width`) or `hidden`. A panel first declared at a later class needs its `mode`,\n `width` and `railWidth` there.\n- **Bars** - `top` (and an optional `bottom`) heights; `0` removes an inherited bar.\n\nThese are tokens: the app places its own `AppBar`, `Sidebar` and `Drawer` with them, and the\ndesign studio draws them on its frames.\n\n### The `layout` prop - the page frame everywhere, the columns on a Grid\n\n`layout` turns the content tokens into CSS per window class. On any `View`-based component -\n`Flex` included - it is the **frame**: the margin and the max width, and the element keeps its\nown display. `Grid` adds the **columns** on top of that frame:\n\n```tsx\n<View layout>...</View> // the theme's frame\n<Flex layout gap={3}>...</Flex> // the frame, a flex column inside\n<Grid layout>...</Grid> // the frame and the theme's columns\n<Grid layout gap={2}>...</Grid> // its own gutter: 16px at every class\n<Grid layout gap={{ xs: 2, md: 4 }}>...</Grid> // 16px, then 32px from md up\n<Grid layout={{ lg: { columns: 16 } }}>...</Grid> // 16 columns from lg up\n<Grid layout={{ maxWidth: '1280px', md: { columns: 6 } }}>...</Grid> // both\n```\n\n- **The frame** - the full width of its parent (`width: 100%`, border-box) with the margin as\n `padding-inline`; in fixed mode capped by `max-width` and centred. It spans its parent in any\n context - a block, a grid item, a flex column or row - so the frame owns its width: size it\n with `maxWidth`, not `width`.\n- **Grid** - `grid-template-columns: repeat(N, minmax(0, 1fr))` and the gutter as `column-gap`.\n- **The gutter is the grid's `gap`** - its own `gap` or `columnGap` (`columnGap` wins), single,\n per class (`{ md: 4 }`) or as an array, sets `column-gap` at every class it covers; where it is\n not set, the theme's gutter applies. Rows take `gap`'s row half or `rowGap`. On a `Flex` or a\n `View`, `gap` is plain flexbox spacing.\n- **Children take `span`** - how many columns of a grid an element takes, on any `View`-based\n component: `span={6}`, per class `span={{ xs: 4, md: 6 }}`, or `span=\"full\"` for the whole row\n whatever the column count (`grid-column: 1 / -1`, in any grid).\n- A field in the value (`maxWidth: '1280px'`) replaces the theme's at every class; whatever it\n does not set still follows the theme. An entry under a class name replaces it **from that class\n up**, mobile-first like every responsive prop, on top of the fields.\n- **The layout owns the column tracks, inline padding and max width** it writes: an explicit\n `gridTemplateColumns`, padding or `maxWidth` on the same element does not override them from the\n second class up. A grid with tracks of its own leaves `layout` off and sits inside a frame.\n\n### Layout: one way per intent\n\nGenerated code, agents and people write each layout intent one way:\n\n| Intent | Write | Not |\n| ------------------------------------------------ | ----------------------------------------------------------- | --------------------------------------------------------- |\n| Content on the page frame, no columns | `<View layout>`, or `<Flex layout>` for a flex stack or row | `maxWidth` + `mx=\"auto\"` + `px`, a custom frame component |\n| A section on the theme's columns | `<Grid layout>` | hand-written tracks on a page section, `Flex` with widths |\n| The app's layout | `theme.layout`, built with `createTheme` | layout values written on every page |\n| A page's (or a region's) own layout | `<LayoutProvider layout={...}>` around the page | the same `layout` value on each section, a nested theme |\n| A section's own columns, margin or max width | `layout={{ md: { columns: 6 } }}`, `layout={{ maxWidth }}` | helpers that repeat a value per class |\n| A section's own gutter | `gap={2}` / `gap={{ xs: 2, md: 4 }}` on the `Grid` | a `gutter` field, `gap` and `columnGap` both |\n| A child taking N columns | `span={6}` / `span={{ xs: 4, md: 6 }}` | `gridColumn=\"span 6\"` |\n| A child taking the whole row | `span=\"full\"` | `grid-column: 1 / -1`, `style`, column-count objects |\n| Space between rows only | `rowGap` | margins on the children |\n| A grid with tracks of its own (`auto-fill`, ...) | a plain `Grid` without `layout`, inside a frame | `layout` plus `gridTemplateColumns` |\n\nThe same page without the prop needs every value written out - and stops following the theme:\n\n```tsx\n<Grid\n gridTemplateColumns={{\n xs: 'repeat(4, minmax(0, 1fr))',\n sm: 'repeat(8, minmax(0, 1fr))',\n md: 'repeat(12, minmax(0, 1fr))',\n }}\n columnGap={{ xs: 2, md: 3 }}\n px={{ xs: 2, sm: 4, md: 3 }}\n>\n ...\n</Grid>\n```\n\n### Your own breakpoints and layout\n\nOverride values with `createTheme`, like any scale:\n\n```ts\nconst theme = createTheme(baseTheme, {\n breakpoints: { md: '900px' },\n layout: { lg: { content: { maxWidth: '1280px' } } },\n})\n```\n\nThe helpers on `theme.breakpoints` are rebuilt from the merged sizes. `createTheme` merges, so\nit can change values and add a larger breakpoint after the existing ones, but not remove or rename\none. To use your own names, declare them by augmenting `BreakpointOverrides` (`true` adds a name,\n`false` removes a default) and replace the scale and the layout on the base:\n\n```ts\ndeclare module '@soroush.tech/design-system/theme' {\n interface BreakpointOverrides {\n mobile: true\n tablet: true\n web: true\n xs: false\n sm: false\n md: false\n lg: false\n xl: false\n }\n}\n\nconst theme = createTheme(\n {\n ...baseTheme,\n breakpoints: withBreakpointHelpers({ mobile: '0px', tablet: '768px', web: '1280px' }),\n layout: { mobile: { ...a complete entry... }, tablet: { ... }, web: { ... } },\n },\n {}\n)\n```\n\nResponsive props, `cq` keys (`cqTablet`), the helpers and the `layout` keys all follow the new\nnames.\n\n## The scale interfaces\n\n| Scale | Key in Theme | Interface |\n| --------------- | ---------------------- | ------------------------- |\n| Palette | `theme.palette` | `ThemePalette` |\n| Text colors | `theme.text` | `ThemeText` |\n| Backgrounds | `theme.background` | `ThemeBackground` |\n| Borders | `theme.border` | `ThemeBorder` |\n| Space | `theme.space` | `ThemeSpace` |\n| Breakpoints | `theme.breakpoints` | `ThemeBreakpoints` |\n| Layout | `theme.layout` | `ThemeLayout` |\n| Sizes | `theme.sizes` | `ThemeSizes` |\n| Radii | `theme.radii` | `ThemeRadii` |\n| Border widths | `theme.borderWidths` | `ThemeBorderWidths` |\n| Fonts | `theme.fonts` | `ThemeFonts` |\n| Font weights | `theme.fontWeights` | `ThemeFontWeights` |\n| Line heights | `theme.lineHeights` | `ThemeLineHeights` |\n| Letter spacings | `theme.letterSpacings` | `ThemeLetterSpacings` |\n| Typography | `theme.typography` | `ThemeTypographyVariants` |\n| Avatar sizes | `theme.avatar` | `ThemeAvatarSizes` |\n| Icon sizes | `theme.icon` | `ThemeIconSizes` |\n| Switch tokens | `theme.switch` | `ThemeSwitch` |\n| Shadow tokens | `theme.shadow` | `ThemeShadow` |\n\n## The spacing scale\n\n`theme.space` steps on an 8px unit, and every step is a whole pixel. The same steps serve padding,\nmargin, `gap` / `rowGap` / `columnGap`, the `layout` margin and the grid's gutter:\n\n| Step | `0` | `0.125` | `0.25` | `0.5` | `0.75` | `1` | `1.25` | `1.5` | `1.75` | `2` | `3` | `4` | `5` | `6` | `7` | `8` | `9` | `10` |\n| ---- | --- | ------- | ------ | ----- | ------ | --- | ------ | ----- | ------ | --- | --- | --- | --- | --- | --- | --- | --- | ---- |\n| px | 0 | 1 | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 24 | 32 | 40 | 48 | 56 | 64 | 72 | 80 |\n\nBelow 4px, lines are border widths (`theme.borderWidths`). Use `0.125` and `0.25` only for a gap\nthat should be a hairline - a 1px or 2px gap the background shows through, as in a grid of tiles\non a coloured `Grid`: `<Grid layout gap={0.125} bg=\"grid\">`.\n| Defaults | `theme.defaults` | `ThemeDefaults` |\n| Components | `theme.components` | `ThemeComponents` |\n\nThe contract is verified against the real published d.ts by `type-tests/augmentation.ts` (`pnpm test:types`), so it can't silently break in a release.\n",
|
|
1338
1338
|
"url": "https://docs.soroush.tech/design-system/customization/theming/"
|
|
1339
1339
|
},
|
|
1340
1340
|
{
|
|
1341
1341
|
"id": "customization",
|
|
1342
1342
|
"title": "How to customize",
|
|
1343
1343
|
"summary": "Override component styles through theme.components and style props.",
|
|
1344
|
-
"body": "# Per-component customization (`theme.components`)\n\nCustomize one component for the whole app - default prop values, per-slot CSS, and new variant values - without wrapping or forking. Zero-config themes pay nothing: the resolver bails out on its first check when `theme.components` is absent.\n\n```ts\nconst brand = createTheme(baseTheme, {\n components: {\n Button: {\n defaultProps: { size: 'sm', shape: 'rounded' },\n styleOverrides: {\n root: ({ theme, ownerState }) => ({\n letterSpacing: theme.letterSpacings.wide,\n ...(ownerState.variant === 'contained' && { textTransform: 'none' }),\n }),\n label: { fontStyle: 'italic' },\n },\n variants: [\n {\n props: { variant: 'dashed' },\n style: ({ theme }) => ({\n backgroundColor: 'transparent',\n border: `${theme.borderWidths.thin} dashed ${theme.border.primary}`,\n }),\n },\n ],\n },\n },\n})\n```\n\nThe `Theme/Customization` Storybook story renders all three mechanisms under a customized theme and is locked by Chromatic - it is the living contract.\n\nEvery styled element is registered - the `ThemeComponents` interface in `src/theme/themes.ts` is the authoritative key/slot list, so `styleOverrides` reaches every root and every sub-element slot (Switch's `track`/`thumb`/`input`, Select's `listbox`, LinearProgress's bars, ...), including the layout primitives `View`/`Flex`/`Grid`. Two cautions: an override on `View`/`Flex`/`Grid` cascades into the internals of every composed component (use those keys for app-wide policy only), and hidden/structural slots (`input`, `valueGhost`, `positioner`) carry accessibility or layout behavior - restyle their looks, not their geometry/visibility. Note that `defaultProps` is honored only by components that resolve props through `useDefaultProps` (currently `Breadcrumbs`, `Button`, `Card`, `Pressable`, `Rating`, `NumberInput`, `RangeInput`, `TransferList`, `Collapse`, `FabMenu`, `ScrollArea`, `Autocomplete`, `Tooltip`, `Snackbar`, `Fab`, `Alert`, `Badge`, `Chip`, `Accordion`, `AccordionSummary`, `AccordionGroup`, `Tabs`, `Tab`, `TabScrollButton`, `TabPanel`, `Menu`, `ContextMenu`, `MenuList` and `MenuItem`); everywhere else, use `styleOverrides`/`variants`.\n\n---\n\n## `defaultProps`\n\nPer-component default prop values. They sit in the standard resolution chain - later steps only apply when earlier ones are unset:\n\n```\nexplicit prop → group context (e.g. ButtonGroup) → theme.components.X.defaultProps → theme.defaults.* → literal fallback\n```\n\nUse `theme.defaults` for global policy (\"everything compact\") and `defaultProps` for component policy (\"only Buttons compact\"). Components read them via the `useDefaultProps(name)` hook.\n\n## `styleOverrides`\n\nPer-slot CSS merged **after** the component's own styles - the theme wins the cascade - but **before** the styled-system prop parsers, so per-instance props (`m`, `p`, `width`, ...) always beat the theme.\n\nValues are plain CSS objects or callbacks receiving `{ theme, ownerState }`. `ownerState` is the styled root's **resolved** props - after group context, `defaultProps`, and `theme.defaults` have been applied - so a conditional like `ownerState.variant === 'contained'` sees the same value the component's own styles used. Prop-keyed conditionals belong in the callback; there are no magic override keys to memorize.\n\nSlot names (`root`, `label`, `icon`, ...) are typed per component in `ThemeComponents` and are **public API** - renaming one is a breaking change.\n\n## `variants`\n\nExtra variant entries matched by props: an entry applies when every key in its `props` equals the render prop. Matching runs on the component's root slot only. Note that `createTheme` replaces `variants` arrays wholesale - composing two override sets does not concatenate them.\n\n**New variant values** need two things - the type registration and the styles:\n\n```ts\ndeclare module '@soroush.tech/design-system/theme' {\n interface ButtonVariants {\n dashed: true // widens ButtonVariant so variant=\"dashed\" typechecks\n }\n}\n```\n\nRegistering the value without a matching `variants` entry renders an unstyled button - always pair them.\n\n## Slot props - customizing composed sub-elements\n\nSome slots aren't raw CSS surfaces but composed components with their own token props - Card's title is a `Typography` with `variant`/`color`/`fontFamily`. CSS overrides are the wrong tool for \"make every card title a subtitle instead of an overline\"; that's a **prop** change. Such components accept slot prop objects in `defaultProps`, merged under any per-instance props:\n\n```ts\ncomponents: {\n Card: {\n defaultProps: {\n titleProps: { variant: 'subtitle1', color: 'secondary', fontFamily: 'body' },\n captionProps: { mb: 2 },\n },\n // ...and the same slots are still CSS-addressable:\n styleOverrides: {\n title: { letterSpacing: '0.1em' },\n },\n },\n}\n```\n\nResolution per slot prop: component literal → theme `defaultProps.titleProps` → per-instance `titleProps` (instance wins). The slot-prop shapes are token-typed (`CardSlotTypographyProps`), so `variant`/`color`/`mb` autocomplete against your theme scales - including augmented keys.\n\nSo a composed slot is customizable at three levels: **props** (`defaultProps.titleProps`), **CSS** (`styleOverrides.title`), and **structure** (Card's `title` prop accepts a ReactNode for full replacement).\n\n## Registering your own components\n\nThe mechanism is infrastructure, not just configuration. Create your roots with this package's `styled` and register the name:\n\n```ts\nimport { styled } from '@soroush.tech/design-system'\nimport type { ComponentConfig } from '@soroush.tech/design-system/theme'\n\ndeclare module '@soroush.tech/design-system/theme' {\n interface ThemeComponents {\n MyWidget?: ComponentConfig<{ tone?: 'calm' | 'loud' }, 'root' | 'handle'>\n }\n}\n\nconst WidgetRoot = styled('div', { name: 'MyWidget' })({ padding: 8 })\nconst WidgetHandle = styled('span', { name: 'MyWidget', slot: 'handle' })({ cursor: 'grab' })\n```\n\nYour widget now honors `theme.components.MyWidget.styleOverrides` / `.variants` exactly like the built-ins.\n\n## Converting a design-system component (maintainers)\n\n`Button` is the reference implementation. The rules:\n\n1. Pass `name` on the root and `slot` on named sub-elements. Slot names become public API.\n2. Move styled-system parsers (`space`, `layout`, ...) from the style arguments into the `systemProps` option - this is what keeps instance props beating theme overrides.\n3. Resolve `defaultProps` via `useDefaultProps(name)` in the wrapper, in the chain above.\n4. Type the component's `ThemeComponents` entry (`ComponentConfig<OwnerState, Slots>`); if it has variants, expose them via an augmentable interface (see `ButtonVariants`).\n5. Cover all three mechanisms plus the precedence pairs in the component's tests.\n\n## Runtime cost\n\n- **Unused** (`theme.components` absent): one no-op function call and a property lookup per named root per render; anonymous roots are
|
|
1344
|
+
"body": "# Per-component customization (`theme.components`)\n\nCustomize one component for the whole app - default prop values, per-slot CSS, and new variant values - without wrapping or forking. Zero-config themes pay nothing: the resolver bails out on its first check when `theme.components` is absent.\n\n```ts\nconst brand = createTheme(baseTheme, {\n components: {\n Button: {\n defaultProps: { size: 'sm', shape: 'rounded' },\n styleOverrides: {\n root: ({ theme, ownerState }) => ({\n letterSpacing: theme.letterSpacings.wide,\n ...(ownerState.variant === 'contained' && { textTransform: 'none' }),\n }),\n label: { fontStyle: 'italic' },\n },\n variants: [\n {\n props: { variant: 'dashed' },\n style: ({ theme }) => ({\n backgroundColor: 'transparent',\n border: `${theme.borderWidths.thin} dashed ${theme.border.primary}`,\n }),\n },\n ],\n },\n },\n})\n```\n\nThe `Theme/Customization` Storybook story renders all three mechanisms under a customized theme and is locked by Chromatic - it is the living contract.\n\nEvery styled element is registered - the `ThemeComponents` interface in `src/theme/themes.ts` is the authoritative key/slot list, so `styleOverrides` reaches every root and every sub-element slot (Switch's `track`/`thumb`/`input`, Select's `listbox`, LinearProgress's bars, ...), including the layout primitives `View`/`Flex`/`Grid`. Two cautions: an override on `View`/`Flex`/`Grid` cascades into the internals of every composed component (use those keys for app-wide policy only), and hidden/structural slots (`input`, `valueGhost`, `positioner`) carry accessibility or layout behavior - restyle their looks, not their geometry/visibility. Note that `defaultProps` is honored only by components that resolve props through `useDefaultProps` (currently `Breadcrumbs`, `Button`, `Card`, `Pressable`, `Rating`, `NumberInput`, `RangeInput`, `TransferList`, `Collapse`, `FabMenu`, `ScrollArea`, `Autocomplete`, `Tooltip`, `Snackbar`, `Fab`, `Alert`, `Badge`, `Chip`, `Accordion`, `AccordionSummary`, `AccordionGroup`, `Tabs`, `Tab`, `TabScrollButton`, `TabPanel`, `Menu`, `ContextMenu`, `MenuList` and `MenuItem`); everywhere else, use `styleOverrides`/`variants`.\n\n---\n\n## `defaultProps`\n\nPer-component default prop values. They sit in the standard resolution chain - later steps only apply when earlier ones are unset:\n\n```\nexplicit prop → group context (e.g. ButtonGroup) → theme.components.X.defaultProps → theme.defaults.* → literal fallback\n```\n\nUse `theme.defaults` for global policy (\"everything compact\") and `defaultProps` for component policy (\"only Buttons compact\"). Components read them via the `useDefaultProps(name)` hook.\n\n## `styleOverrides`\n\nPer-slot CSS merged **after** the component's own styles - the theme wins the cascade - but **before** the styled-system prop parsers, so per-instance props (`m`, `p`, `width`, ...) always beat the theme.\n\nValues are plain CSS objects or callbacks receiving `{ theme, ownerState }`. `ownerState` is the styled root's **resolved** props - after group context, `defaultProps`, and `theme.defaults` have been applied - so a conditional like `ownerState.variant === 'contained'` sees the same value the component's own styles used. Prop-keyed conditionals belong in the callback; there are no magic override keys to memorize.\n\nSlot names (`root`, `label`, `icon`, ...) are typed per component in `ThemeComponents` and are **public API** - renaming one is a breaking change.\n\n## `variants`\n\nExtra variant entries matched by props: an entry applies when every key in its `props` equals the render prop. Matching runs on the component's root slot only. Note that `createTheme` replaces `variants` arrays wholesale - composing two override sets does not concatenate them.\n\n**New variant values** need two things - the type registration and the styles:\n\n```ts\ndeclare module '@soroush.tech/design-system/theme' {\n interface ButtonVariants {\n dashed: true // widens ButtonVariant so variant=\"dashed\" typechecks\n }\n}\n```\n\nRegistering the value without a matching `variants` entry renders an unstyled button - always pair them.\n\n## Slot props - customizing composed sub-elements\n\nSome slots aren't raw CSS surfaces but composed components with their own token props - Card's title is a `Typography` with `variant`/`color`/`fontFamily`. CSS overrides are the wrong tool for \"make every card title a subtitle instead of an overline\"; that's a **prop** change. Such components accept slot prop objects in `defaultProps`, merged under any per-instance props:\n\n```ts\ncomponents: {\n Card: {\n defaultProps: {\n titleProps: { variant: 'subtitle1', color: 'secondary', fontFamily: 'body' },\n captionProps: { mb: 2 },\n },\n // ...and the same slots are still CSS-addressable:\n styleOverrides: {\n title: { letterSpacing: '0.1em' },\n },\n },\n}\n```\n\nResolution per slot prop: component literal → theme `defaultProps.titleProps` → per-instance `titleProps` (instance wins). The slot-prop shapes are token-typed (`CardSlotTypographyProps`), so `variant`/`color`/`mb` autocomplete against your theme scales - including augmented keys.\n\nSo a composed slot is customizable at three levels: **props** (`defaultProps.titleProps`), **CSS** (`styleOverrides.title`), and **structure** (Card's `title` prop accepts a ReactNode for full replacement).\n\n## Registering your own components\n\nThe mechanism is infrastructure, not just configuration. Create your roots with this package's `styled` and register the name:\n\n```ts\nimport { styled } from '@soroush.tech/design-system'\nimport type { ComponentConfig } from '@soroush.tech/design-system/theme'\n\ndeclare module '@soroush.tech/design-system/theme' {\n interface ThemeComponents {\n MyWidget?: ComponentConfig<{ tone?: 'calm' | 'loud' }, 'root' | 'handle'>\n }\n}\n\nconst WidgetRoot = styled('div', { name: 'MyWidget' })({ padding: 8 })\nconst WidgetHandle = styled('span', { name: 'MyWidget', slot: 'handle' })({ cursor: 'grab' })\n```\n\nYour widget now honors `theme.components.MyWidget.styleOverrides` / `.variants` exactly like the built-ins.\n\n## Converting a design-system component (maintainers)\n\n`Button` is the reference implementation. The rules:\n\n1. Pass `name` on the root and `slot` on named sub-elements. Slot names become public API.\n2. Move styled-system parsers (`space`, `layout`, ...) from the style arguments into the `systemProps` option - this is what keeps instance props beating theme overrides.\n3. Resolve `defaultProps` via `useDefaultProps(name)` in the wrapper, in the chain above.\n4. Type the component's `ThemeComponents` entry (`ComponentConfig<OwnerState, Slots>`); if it has variants, expose them via an augmentable interface (see `ButtonVariants`).\n5. Cover all three mechanisms plus the precedence pairs in the component's tests.\n\n## Runtime cost\n\n- **Unused** (`theme.components` absent): one no-op function call and a property lookup per named root per render; anonymous roots are plain `styled` roots. Bundle cost of the wrapper: well under a kilobyte.\n- **Used**: each overridden component behaves as if it shipped one more style function - the same cost class as its existing `sizeVariants`/`colorStyle` functions. The engine names a class by a hash of its compiled rules, so the same style always gives the same class.\n",
|
|
1345
1345
|
"url": "https://docs.soroush.tech/design-system/customization/how-to/"
|
|
1346
1346
|
},
|
|
1347
1347
|
{
|
|
1348
1348
|
"id": "setup",
|
|
1349
1349
|
"title": "New app setup",
|
|
1350
1350
|
"summary": "End-to-end checklist for a new app: fonts, global reset, providers, theme.",
|
|
1351
|
-
"body": "# New-app checklist\n\nReference wiring: a Next.js App Router app on React 19.\n\n## 1. Install\n\n```jsonc\n// package.json\n\"dependencies\": {\n \"@soroush.tech/design-system\": \"^
|
|
1351
|
+
"body": "# New-app checklist\n\nReference wiring: a Next.js App Router app on React 19.\n\n## 1. Install\n\n```jsonc\n// package.json\n\"dependencies\": {\n \"@soroush.tech/design-system\": \"^3.0.0\",\n \"react\": \"^19.2.8\",\n \"react-dom\": \"^19.2.8\"\n}\n```\n\nThe styling engine (UmberStyle, the `@umber-style/*` packages) comes in as a dependency\nof the design system - don't add it directly. The registry in `providers.tsx` takes\n`createCache` from `@soroush.tech/design-system/engine`. React 19.2 or later is required.\n\n## 2. Theme\n\nCopy `theme.ts` to the app root so it imports as `@/theme`.\nIt exports `light` and `dark`. The color ramps at the top (`carbonBlack`,\n`cyberCyan`, `kineticGreen`, `forestGreen`, `solarAmber`, `neonRed`, `softGreen`,\n`deepCrimson`, `lightSurface`, `kineticSurface`, `blackAlpha`) are the brand: every\napp that copies them shares one color set. Change which ramp fills a palette slot if\nthe app needs to, never the ramp values.\n\n## 3. Provider\n\nCopy `providers.tsx` to `app/providers.tsx`. Two things it does:\n\n- **Style registry** - collects the styles written during the server render and\n re-injects them via `useServerInsertedHTML`, so server markup arrives styled.\n Without it you get an unstyled flash on every hard navigation.\n- **Global reset** - `border-box` everywhere, zero body margin,\n `background.primary` / `text.initial` / `fonts.body` on `<body>`.\n\nThe cache key is the prefix of the class names and the CSS variables under the registry. The\nfile uses `soroush`, the design system's own; an app that already has a key of its own may keep\nit. The registry writes one `<style data-umber=\"<key> ...\">` element per flush into the stream.\n\nThis set-up is tested on Next.js 16.4 with React 19.2, in development and in a production\nbuild, with a page that streams through `Suspense`. Keep styled parts in client components:\nthe registry collects what client components render.\n\nUnder a strict Content Security Policy (a `style-src` with a nonce and no `unsafe-inline`), give\nthe cache the response's nonce, `createCache({ key: 'soroush', nonce })`, and put the same nonce\non the `<style>` element the registry returns, `nonce={cache.nonce}`: that element is the app's\nown. Every style element the engine makes then carries it. Give React the same nonce for its\nrender; it keeps the rules of a style element only when the element's nonce is its own. This\nregistry has not been run under such a policy end to end, so test it in your app.\n\nThen in `app/layout.tsx`:\n\n```tsx\nexport default function RootLayout({ children }: { children: React.ReactNode }) {\n return (\n <html lang=\"en\">\n <body>\n <Providers>\n <TopBar />\n {children}\n </Providers>\n </body>\n </html>\n )\n}\n```\n\n`<Providers>` wraps everything including the chrome. Route groups then supply their\nown inner layout (rail + `Main`).\n\n## 4. Fonts\n\n`theme.fonts` names _Space Grotesk_ and _JetBrains Mono_, but the package does not\nload them. An app that never loads them renders in the system sans and mono fonts.\nTo get the intended look, load them once in the root layout -\n`@fontsource-variable/space-grotesk` + `@fontsource-variable/jetbrains-mono`, or\n`next/font`. Leaving the system fonts is also a valid choice; just make it deliberately.\n\n## 5. Layout scaffold\n\n```\ncomponents/\n chrome/constants.ts TOPBAR_HEIGHT = \"3.5rem\"\n chrome/TopBar.tsx sticky AppBar, brand wordmark, breadcrumb, session cluster\n chrome/Main.tsx 1600px column, 20→40px gutters\n chrome/<Rail>.tsx optional icon rail, bottom bar on mobile\n ui.tsx NavLink, TokenCode, StatusBadge + STATUS_TONE map\n PageCard.tsx PageHeader.tsx SectionLabel.tsx Pill.tsx\n StatStrip.tsx TabNav.tsx SettingCard.tsx SearchInput.tsx Skeletons.tsx\n```\n\nSources in `layout-kit.md`.\n\n## 6. tsconfig\n\n`@/*` path alias to the app root - every import above assumes it.\n\n## 7. Verify\n\n`pnpm typecheck` (`tsc --noEmit`) catches the common mistakes: a `tone` string that\nisn't a `PaletteColor`, a `theme.text.*` key that doesn't exist, a missing\n`shouldForwardProp`. The theme is fully typed - lean on it instead of eyeballing.\n"
|
|
1352
1352
|
},
|
|
1353
1353
|
{
|
|
1354
1354
|
"id": "layout-kit",
|
|
@@ -1365,14 +1365,14 @@ const content = {
|
|
|
1365
1365
|
{
|
|
1366
1366
|
"id": "providers",
|
|
1367
1367
|
"title": "Providers (Next.js App Router)",
|
|
1368
|
-
"summary": "ThemeProvider plus the
|
|
1369
|
-
"body": "Copy this verbatim into your app as `providers.tsx`.\n\n```tsx\n'use client'\n\nimport { useServerInsertedHTML } from 'next/navigation'\nimport { useState } from 'react'\nimport
|
|
1368
|
+
"summary": "ThemeProvider plus the style registry for the Next.js App Router.",
|
|
1369
|
+
"body": "Copy this verbatim into your app as `providers.tsx`.\n\n```tsx\n'use client'\n\nimport { useServerInsertedHTML } from 'next/navigation'\nimport { useState } from 'react'\nimport { CacheProvider, createCache, Global } from '@soroush.tech/design-system/engine'\nimport { ThemeProvider } from '@soroush.tech/design-system/theme'\nimport { light } from '@/theme'\n\n/** Collects the styles rendered on the server and re-injects them into the\n * HTML stream, so server-rendered markup arrives already styled. */\nfunction useStyleRegistry() {\n const [{ cache, flush }] = useState(() => {\n const cache = createCache({ key: 'soroush' })\n cache.compat = true\n const prevInsert = cache.insert\n let inserted: string[] = []\n cache.insert = (...args) => {\n const serialized = args[1]\n if (cache.inserted[serialized.name] === undefined) inserted.push(serialized.name)\n return prevInsert(...args)\n }\n const flush = () => {\n const prev = inserted\n inserted = []\n return prev\n }\n return { cache, flush }\n })\n\n useServerInsertedHTML(() => {\n const names = flush()\n if (names.length === 0) return null\n let styles = ''\n for (const name of names) styles += cache.inserted[name]\n return (\n <style\n key={cache.key}\n data-umber={`${cache.key} ${names.join(' ')}`}\n dangerouslySetInnerHTML={{ __html: styles }}\n />\n )\n })\n\n return cache\n}\n\nexport default function Providers({ children }: Readonly<{ children: React.ReactNode }>) {\n const cache = useStyleRegistry()\n return (\n <CacheProvider value={cache}>\n <ThemeProvider theme={light}>\n <Global\n styles={(theme) => ({\n '*, *::before, *::after': { boxSizing: 'border-box' },\n body: {\n margin: 0,\n backgroundColor: theme.background.primary,\n color: theme.text.initial,\n fontFamily: theme.fonts.body,\n },\n })}\n />\n {children}\n </ThemeProvider>\n </CacheProvider>\n )\n}\n```\n"
|
|
1370
1370
|
},
|
|
1371
1371
|
{
|
|
1372
1372
|
"id": "design-system-overview",
|
|
1373
1373
|
"title": "Design system overview",
|
|
1374
1374
|
"summary": "The package README: what ships, the import contract, and the component inventory.",
|
|
1375
|
-
"body": "**Your design system. Your tokens. Your rules.**\nA fully typed React component library where nothing is hardcoded - every color, scale, and default belongs to you, not the package.\n\nTired of forking a component library just to change a color? Every token here is designed to be overridden - theming isn't an afterthought, it's the whole point.\n\n## Install\n\n```sh\nnpm i @soroush.tech/design-system\n```\n\n`react` and `react-dom` are peer dependencies. Emotion is an internal implementation detail - it ships as a regular dependency, not a peer, so you never install it yourself.\n\n---\n\n## Use it with AI tools\n\nTwo skills teach a coding agent how to build with this library: a house-style skill, and a\nWCAG 2.2 AA skill for contrast, labels, landmarks and accessibility tests. Both install for\nwhichever agents you use:\n\n```sh\nnpx skills add soroush-tech/design-system\n```\n\nAn MCP server serves this library's component inventory, every component's props\nreference, and the live token contract, so an AI assistant writes against the real API\ninstead of guessing. Add the hosted server, `https://mcp.soroush.design/mcp`, to any MCP\nclient; in Claude Code:\n\n```sh\nclaude mcp add --transport http soroush https://mcp.soroush.design/mcp\n```\n\nIt also runs locally over stdio (`npx -y @soroush.design/mcp`). Claude Code users can\ninstall the plugin instead, which brings the skills, the server and a UI review agent in\none step:\n\n```sh\nclaude plugin marketplace add soroush-tech/design-system\nclaude plugin install soroush-design-system@soroush-tech\n```\n\nAny other tool can read [docs.soroush.tech/llms.txt](https://docs.soroush.tech/llms.txt).\nSee [`@soroush.design/mcp`](../mcp) for the full tool list.\n\n---\n\n## Importing\n\nImport components by subpath, styling primitives from the barrel:\n\n```ts\nimport { Typography } from '@soroush.tech/design-system/Typography'\nimport { Flex } from '@soroush.tech/design-system/Flex'\n```\n\nStyling primitives (the engine) come from the barrel `@soroush.tech/design-system` - `styled`, `css`, `keyframes`, the `Theme` type, styled-system functions, and `createShouldForwardProp`. The barrel (`src/index.ts`) is the engine abstraction layer: to swap the CSS-in-JS engine, only that file changes.\n\n```ts\nimport { styled, css, type Theme } from '@soroush.tech/design-system'\n```\n\n`ThemeProvider` and the theme-value hooks (`useTheme`, `useDefaultProps`, `withTheme`) live at their own subpath:\n\n```ts\nimport { ThemeProvider, useTheme } from '@soroush.tech/design-system/theme'\n```\n\nStyle-computation helpers (`useStyle`, `withStyles`, `StylesConsumer`) - resolving a `StyleInput`/`StyleFactory` into a `CSSObject` - live at their own subpath:\n\n```ts\nimport { useStyle } from '@soroush.tech/design-system/style'\n```\n\nRaw engine primitives for building your own global styles - `Global`, `globalStyles`, and the SSR-only `CacheProvider`/`styleCache` pairing - live at their own subpath, not the barrel:\n\n```ts\nimport { Global, globalStyles, CacheProvider, styleCache } from '@soroush.tech/design-system/engine'\n```\n\n`Global` (retyped against this package's `Theme`) applies app-wide CSS and should render inside `ThemeProvider` so it resolves against the active theme. `globalStyles(theme)` is the base reset this package owns - box-sizing, margin/table resets, and theme-driven body colors - compose it into your own `Global` styles array alongside your app's own concerns (font-family, webfont loading, and anything else app-specific stay entirely app policy).\n\nThe component catalog - every component as data, for tools that place and write components (a\ndesign tool's palette, a source writer) - lives at its own subpath and loads in plain Node\n([docs](./docs/catalog.md)):\n\n```ts\nimport { catalog } from '@soroush.tech/design-system/catalog'\n```\n\nSSR critical-CSS extraction (e.g. with `@emotion/server`) is a separate, opt-in concern most apps never need - that's what `CacheProvider` and its paired `styleCache` instance are for.\n\nUnder a strict Content Security Policy, bring your own cache with the response's nonce - `createCache({ key: 'app', nonce })` from `@emotion/cache`, given to `CacheProvider` above `ThemeProvider` - and every style tag the engine inserts carries it. The shipped `styleCache` has no nonce.\n\nThe Emotion packages are regular dependencies of this package, not peers, on purpose: nothing of Emotion is on the public surface, so an app installs nothing extra and has no version to keep in step. An app that brings its own `@emotion/react` of another major gets two copies - the components keep working, as they style through their own copy and `ThemeProvider` - at the cost of the duplicate in the bundle and Emotion's one-time development warning.\n\n---\n\n## Component inventory\n\n### Layout & surfaces\n\n| Component | Purpose |\n| ------------ | ----------------------------------------------------------------------- |\n| `ScrollArea` | A scrolling area with scrollbars drawn over its content, shown on hover |\n| `View` | Styled `div` primitive - the base building block |\n| `Flex` | `View` with flexbox defaults |\n| `Grid` | CSS grid container |\n| `Paper` | Elevated surface with background and shadow |\n| `Card` | Content container built on `Paper` |\n| `Quote` | Bordered quote / terminal-panel surface on `View` |\n| `AppBar` | Top application bar |\n| `Drawer` | Slide-in side panel |\n\n### Content & data display\n\n| Component | Purpose |\n| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `Typography` | Text with variant → element mapping - the reference implementation for all components |\n| `Link` | Anchor with theme-aware styling |\n| `Icon` | Icon renderer |\n| `Image` | Image with styled-system props |\n| `Avatar` | User/entity avatar |\n| `Table` | Compound data table - exports `TableContainer`, `TableHead`, `TableBody`, `TableFooter`, `TableRow`, `TableCell`, `TablePagination`, `TablePaginationActions`, `TableSortLabel`, and `TableControl` from `@soroush.tech/design-system/Table` |\n| `Accordion` | A heading that opens and closes a region - exports `AccordionSummary`, `AccordionDetails`, `AccordionActions` and `AccordionGroup` from `@soroush.tech/design-system/Accordion` |\n\n### Inputs & forms\n\n| Component | Purpose |\n| ---------------------------------------------------- | ----------------------------------------------------------------------------------------- |\n| `Autocomplete` | A field whose text finds an option in a list - one, several as chips, or free text |\n| `Fab` | A floating action button: the one main action of a page, circular or extended |\n| `Button`, `ButtonGroup`, `ToggleButton` | Actions and toggles |\n| `TextInput` | Text field |\n| `Checkbox`, `Radio`, `Switch` | Selection controls |\n| `RangeInput` | A slider - one value on a range, or two or more thumbs for a range of values |\n| `TransferList` | Two lists and the buttons that move the checked items from one to the other |\n| `NumberInput` | A field for a number - read in its locale, clamped to a range, stepped by keys or buttons |\n| `Rating` | A row of icons the user sets as a rating, or a read-only display of one |\n| `NativeSelect` | Low-level platform `<select>` - not recommended; use `Select native` |\n| `Select` | The select to use - custom listbox, or `native` for the platform picker |\n| `MenuItem` | Option row for `Select`'s listbox, and a menu row in a `MenuList` |\n| `Form`, `FormControl`, `FormLabel`, `FormHelperText` | Form composition and labeling |\n| `Pagination` | Page navigation control |\n\n### Navigation & menus\n\n| Component | Purpose |\n| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `NavTree` | A tree of links to the pages of a site - groups of links, which can fold |\n| `Breadcrumbs` | The trail of links from a site's root to the current page - a long one collapses behind a button that shows it all |\n| `Menu` | A trigger and the list of commands it opens - exports `MenuList` (the `role=\"menu\"` list that owns the keyboard), `MenuDivider`, `MenuItems` (rows from data) and `ContextMenu` (the same list, opened at the pointer by a right-click) from `@soroush.tech/design-system/Menu` |\n| `Tabs` | A row of tabs - exports `Tab`, `TabContext` (holds the value for a `TabList` and its panels), `TabList` (the `Tabs` of a `TabContext`), `TabPanel` (the content a tab shows) and `TabScrollButton` from `@soroush.tech/design-system/Tabs` |\n\n### Feedback\n\n| Component | Purpose |\n| ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------- |\n| `FabMenu` | A fab that opens a stack of actions from the corner of a page |\n| `Snackbar` | A transient message in a corner of the window, with auto-hide and an action |\n| `Alert` | An inline message with a severity, an icon, a title and an action - exports `AlertTitle` from `@soroush.tech/design-system/Alert` |\n| `Badge` | A count or a dot anchored over another element |\n| `Chip` | A compact tag: a label, an icon or avatar, a click and a delete |\n| `CircularProgress`, `LinearProgress` | Determinate/indeterminate progress indicators |\n| `Skeleton` | Loading placeholder with pulse/wave animations |\n| `Backdrop` | Dimmed overlay behind modal surfaces |\n\n### Transitions\n\n| Component | Purpose |\n| ------------------------------- | ------------------------------------------------------------------ |\n| `Collapse` | Opens and closes its content by its height, or its width |\n| `Fade`, `Grow`, `Slide`, `Zoom` | Show and hide one child by opacity, scale, an edge or from nothing |\n\n### Overlay & behavior primitives\n\n| Component | Purpose |\n| --------------- | ----------------------------------------------------------------------------------- |\n| `Tooltip` | A short description of one element, shown on hover, keyboard focus and a long touch |\n| `Portal` | Renders children into a DOM node outside the parent hierarchy |\n| `FocusTrap` | Keeps focus inside a subtree |\n| `Modal` | Dialog primitive composing `Portal`, `Backdrop`, and `FocusTrap` |\n| `Popover` | Anchored floating surface built on `Modal` |\n| `ThemeProvider` | Supplies the theme and global styles to the app |\n\n---\n\n## Theme tokens\n\nComponents never hardcode colors or sizes - props resolve against scales on the `Theme` object:\n\n| Group | Scales |\n| ------------------ | ------------------------------------------------------------------------------------------------------------- |\n| Color | `palette` (main/light/dark/contrastText per color) · `text` · `background` · `border` · `colorScheme` |\n| Typography | `typography` (variant map) · `fonts` · `fontSizes` · `fontWeights` · `lineHeights` · `letterSpacings` |\n| Space & shape | `space` · `sizes` · `radii` · `borderWidths` · `shadows` |\n| Layout | `breakpoints` (xs/sm/md/lg/xl window classes) · `layout` (columns, margins, panels, top bar per class) |\n| Component scales | `avatar` (size steps) · `skeleton` (wave highlight) |\n| Layering & effects | `zOrder` (appBar/drawer/modal/snackbar/tooltip) · `blur` · `logoFilter` · `portraitBlend` · `portraitOpacity` |\n\nProp types are derived from the interface (`keyof Theme['text']`), so adding a token to `themes.ts` propagates everywhere automatically. See [`design-system.md`](./design-system.md) for the full scale table and the palette rules.\n\n---\n\n## Theming\n\nThe theme belongs to you - the package only ships defaults. This section is the overview; the full guides are [`docs/theming.md`](./docs/theming.md) and [`docs/customization.md`](./docs/customization.md).\n\n### One theme, yours\n\n`ThemeProvider` provides exactly one theme - the built-in dark theme when you pass nothing. Bring one theme, or as many as you like: switching between them is your state, not the provider's.\n\n```tsx\nimport { ThemeProvider } from '@soroush.tech/design-system/theme'\nimport { baseTheme, createTheme } from '@soroush.tech/design-system/theme'\n\n// Zero-config: the built-in `baseTheme`.\n<ThemeProvider>{app}</ThemeProvider>\n\n// Your theme - written from scratch or extended from the base.\nconst brand = createTheme(baseTheme, { palette: { primary: { main: '#00ff88' } } })\n<ThemeProvider theme={brand}>{app}</ThemeProvider>\n\n// Mode switching is app policy - own the state and pass the active theme:\nconst [isDark, setIsDark] = useState(true)\n<ThemeProvider theme={isDark ? brandDark : brandLight}>{app}</ThemeProvider>\n```\n\n`createTheme(base, overrides)` (exported from `@soroush.tech/design-system/theme`) is the merge primitive: plain objects recurse, arrays (`shadows`, `fontSizes`) and functions replace wholesale, `undefined` values are ignored - keys are added or replaced, never removed.\n\n### Breakpoints and layout\n\n`theme.breakpoints` are Material 3's window classes, each a range from its start until the next:\n`xs` 0-599px (compact, the base), `sm` 600-839 (medium), `md` 840-1199 (expanded), `lg`\n1200-1599 (large), `xl` 1600+ (extra-large). Responsive props use them by name or position -\n`p={{ xs: 2, md: 4 }}`, `p={[2, 3, 4]}` - and `cqSm`-style keys write container queries;\n`theme.breakpoints.up('md')` and its siblings write queries for hand-written styles. Everything is\nCSS, so pages work with JavaScript off. `theme.layout` holds the layout tokens per class (columns,\nmargins, gutters, side panels, top bar); `Grid` and `Flex` apply the column grid with\n`layout` / `layout={{ lg: { columns: 16 } }}`, and apps place `AppBar`, `Sidebar` and `Drawer`\nthemselves. The full guide is the\n[Breakpoints and layout](./docs/theming.md#breakpoints-and-layout) section of the theming guide.\n\n### Component defaults\n\nComponents carry visible literal fallbacks (`size = 'md'`, `variant = 'outside'`, ...) resolved through `themeDefault(theme, key, fallback)` - so every default, including behavioral variants, is overridable via the optional `theme.defaults` map or the provider's `defaults` prop:\n\n| Key | Fallback | Drives |\n| -------------------------------------------- | ---------------------------------- | -------------------------------------- |\n| `size` / `compactSize` | `'md'` / `'sm'` | sized components / dense table actions |\n| `color` / `neutralColor` | `'primary'` / `'default'` | accent controls / toggle controls |\n| `textColor` / `accentTextColor` | `'initial'` / `'primary'` | body text / icons + input labels |\n| `bg` / `surfaceBg` / `inputBg` | `'default'`/`'paper'`/`'terminal'` | switch track / paper surfaces / inputs |\n| `borderRadius` / `surfaceRadius` | `'md'` / `'sq'` | grouped controls / surfaces |\n| `avatarSize` / `borderColor` / `borderWidth` | `'md'` / `'primary'` / `'thin'` | avatars and rings |\n| `iconSize` | `'lg'` | Icon default glyph size (`theme.icon`) |\n| `inputMinWidth` | `'12rem'` | least width of an input not full width |\n| `buttonVariant` / `switchVariant` | `'contained'` / `'outside'` | Button / Switch visual variants |\n| `inputVariant` | `'default'` | TextInput, Select, NativeSelect frames |\n| `avatarVariant` / `cardVariant` | `'circular'` / `'paper'` | Avatar shape / Card treatment |\n| `linkUnderline` | `'always'` | Link underline behavior |\n| `paginationVariant` / `paginationShape` | `'text'` / `'circular'` | Pagination items |\n\nThe built-in themes carry no `defaults` - the literals apply. A theme with entirely different size or palette keys stays valid by pointing the keys at its own tokens:\n\n```tsx\n<ThemeProvider defaults={{ size: 'compact', color: 'brand', switchVariant: 'inside' }}>\n```\n\n### Per-component customization (`theme.components`)\n\nCustomize one component for the whole app - default prop values, per-slot CSS, and new variant values - without wrapping or forking:\n\n```tsx\nconst brand = createTheme(baseTheme, {\n components: {\n Button: {\n // Buttons default to sm + rounded; explicit props and ButtonGroup still win.\n defaultProps: { size: 'sm', shape: 'rounded' },\n\n // Per-slot CSS merged after Button's own styles - the theme wins the cascade,\n // but per-instance props (m, p, width, ...) still beat the theme.\n styleOverrides: {\n root: ({ theme, ownerState }) => ({\n letterSpacing: theme.letterSpacings.wide,\n ...(ownerState.variant === 'contained' && { textTransform: 'none' }),\n }),\n label: { fontStyle: 'italic' },\n },\n\n // A new variant value - register it first so it typechecks:\n // declare module '@soroush.tech/design-system/theme' { interface ButtonVariants { dashed: true } }\n variants: [\n {\n props: { variant: 'dashed' },\n style: ({ theme }) => ({\n backgroundColor: 'transparent',\n border: `${theme.borderWidths.thin} dashed ${theme.border.primary}`,\n }),\n },\n ],\n },\n },\n})\n```\n\nStyle callbacks receive `{ theme, ownerState }`, where `ownerState` is the styled root's **resolved** props (after group context, `defaultProps`, and `theme.defaults`). `defaultProps` sits in the standard precedence chain: explicit prop → group context → `defaultProps` → `theme.defaults.*` → the component's literal fallback. `variants` arrays are replaced wholesale by `createTheme`, never merged.\n\nYour own components can join the same mechanism: create their roots with this package's `styled(tag, { name: 'MyWidget', slot: 'root' })` and register the name by augmenting `ThemeComponents`. Zero-config themes pay nothing - the resolver bails out on the first check when `theme.components` is absent.\n\n### Extending tokens (declaration merging)\n\nEvery scale is an open interface declared on `@soroush.tech/design-system/theme`, so you can add palette colors, tokens, or whole scales - and every component prop union (`color`, `bg`, `size`, ...) widens automatically:\n\n```ts\nimport type { PaletteEntry } from '@soroush.tech/design-system/theme'\n\ndeclare module '@soroush.tech/design-system/theme' {\n interface ThemePalette {\n brand: PaletteEntry // new palette color\n }\n interface ThemeBackground {\n tertiary: string // new background token\n }\n interface Theme {\n elevations: Record<'low' | 'mid' | 'high', string> // whole new scale\n }\n}\n```\n\nThen supply the values with `createTheme` and use the new keys:\n\n```tsx\nconst brandDark = createTheme(baseTheme, {\n palette: { brand: { main: '#00ff88', light: '#66ffb2', dark: '#00b25f', contrastText: '#000' } },\n background: { tertiary: '#101418' },\n elevations: { low: '0 1px 2px', mid: '0 2px 6px', high: '0 6px 18px' },\n})\n\n<ThemeProvider theme={brandDark}>\n <Button color=\"brand\" />\n <View bg=\"tertiary\" />\n</ThemeProvider>\n```\n\nNotes: new object-valued keys (like a `PaletteEntry`) must be supplied complete - components read `.main`/`.contrastText` at runtime; and TypeScript cannot verify at runtime that an augmented token was actually supplied, so always pair an augmentation with the matching override.\n\n---\n\n## Adding a component\n\nScaffold with the skill - it reads the live `Typography` files and `design-system.md` so output matches the codebase:\n\n```\n/new_theme_component ComponentName\n```\n\nThen work through the checklist at the bottom of [`design-system.md`](./design-system.md).\n\n---\n\nThe library takes inspiration from [Material UI](https://mui.com/) - its component vocabulary and prop conventions will feel familiar - but it is written entirely in house. It is not a clone or a fork: every component is built from scratch on our own engine and token system, and the API is free to diverge wherever it serves its consumers better.\n\n---\n\n## Release notes\n\nPer-version notes for every published release live in\n[`release-notes/`](https://github.com/soroush-tech/design-system/tree/main/packages/design-system/release-notes).\n",
|
|
1375
|
+
"body": "**Your design system. Your tokens. Your rules.**\nA fully typed React component library where nothing is hardcoded - every color, scale, and default belongs to you, not the package.\n\nTired of forking a component library just to change a color? Every token here is designed to be overridden - theming isn't an afterthought, it's the whole point.\n\n## Install\n\n```sh\nnpm i @soroush.tech/design-system\n```\n\n`react` and `react-dom` are peer dependencies, and React 19.2 or later is required. The styling engine (UmberStyle, the `@umber-style/*` packages) is an internal implementation detail - it ships as a regular dependency, not a peer, so you never install it yourself.\n\n---\n\n## Use it with AI tools\n\nTwo skills teach a coding agent how to build with this library: a house-style skill, and a\nWCAG 2.2 AA skill for contrast, labels, landmarks and accessibility tests. Both install for\nwhichever agents you use:\n\n```sh\nnpx skills add soroush-tech/design-system\n```\n\nAn MCP server serves this library's component inventory, every component's props\nreference, and the live token contract, so an AI assistant writes against the real API\ninstead of guessing. Add the hosted server, `https://mcp.soroush.design/mcp`, to any MCP\nclient; in Claude Code:\n\n```sh\nclaude mcp add --transport http soroush https://mcp.soroush.design/mcp\n```\n\nIt also runs locally over stdio (`npx -y @soroush.design/mcp`). Claude Code users can\ninstall the plugin instead, which brings the skills, the server and a UI review agent in\none step:\n\n```sh\nclaude plugin marketplace add soroush-tech/design-system\nclaude plugin install soroush-design-system@soroush-tech\n```\n\nAny other tool can read [docs.soroush.tech/llms.txt](https://docs.soroush.tech/llms.txt).\nSee [`@soroush.design/mcp`](../mcp) for the full tool list.\n\n---\n\n## Importing\n\nImport components by subpath, styling primitives from the barrel:\n\n```ts\nimport { Typography } from '@soroush.tech/design-system/Typography'\nimport { Flex } from '@soroush.tech/design-system/Flex'\n```\n\nStyling primitives (the engine) come from the barrel `@soroush.tech/design-system` - `styled`, `css`, `keyframes`, the `Theme` type, styled-system functions, and `createShouldForwardProp`. The barrel (`src/index.ts`) is the engine abstraction layer: to swap the CSS-in-JS engine, only that file changes.\n\n```ts\nimport { styled, css, type Theme } from '@soroush.tech/design-system'\n```\n\n`ThemeProvider` and the theme-value hooks (`useTheme`, `useDefaultProps`, `withTheme`) live at their own subpath:\n\n```ts\nimport { ThemeProvider, useTheme } from '@soroush.tech/design-system/theme'\n```\n\nStyle-computation helpers (`useStyle`, `withStyles`, `StylesConsumer`) - resolving a `StyleInput`/`StyleFactory` into a `CSSObject` - live at their own subpath:\n\n```ts\nimport { useStyle } from '@soroush.tech/design-system/style'\n```\n\nRaw engine primitives for building your own global styles - `Global`, `globalStyles`, and the SSR-only `CacheProvider`/`styleCache` pairing - live at their own subpath, not the barrel:\n\n```ts\nimport { Global, globalStyles, CacheProvider, styleCache } from '@soroush.tech/design-system/engine'\n```\n\n`Global` (retyped against this package's `Theme`) applies app-wide CSS and should render inside `ThemeProvider` so it resolves against the active theme. `globalStyles(theme)` is the base reset this package owns - box-sizing, margin/table resets, and theme-driven body colors - compose it into your own `Global` styles array alongside your app's own concerns (font-family, webfont loading, and anything else app-specific stay entirely app policy).\n\nThe component catalog - every component as data, for tools that place and write components (a\ndesign tool's palette, a source writer) - lives at its own subpath and loads in plain Node\n([docs](./docs/catalog.md)):\n\n```ts\nimport { catalog } from '@soroush.tech/design-system/catalog'\n```\n\nServer rendering with critical CSS (a Vike or other static or server renderer) is a separate, opt-in concern - that's what `CacheProvider` and its paired `styleCache` instance are for. Give `CacheProvider` the `styleCache`, render, then read the CSS of the page from the same cache with `createInstance` from `@umber-style/server/create-instance` (`pnpm add @umber-style/server`): `extractCriticalToChunks(html)` and `constructStyleTagsFromChunks(chunks)` give the `<style data-umber>` tags to put in the head. Next.js App Router apps collect the styles with a registry instead - see `docs/consumer/setup.md`.\n\nThe cache key and class prefix is `soroush`. Server-rendered style elements carry `data-umber=\"soroush ...\"`, and the live element in the browser is `<style data-style=\"soroush\">`.\n\nThe engine packages are regular dependencies of this package, not peers, on purpose: an app installs nothing extra to render the components, and has no version to keep in step. The one package an app adds itself is `@umber-style/server`, and only to extract critical CSS.\n\n---\n\n## Component inventory\n\n### Layout & surfaces\n\n| Component | Purpose |\n| ------------ | ----------------------------------------------------------------------- |\n| `ScrollArea` | A scrolling area with scrollbars drawn over its content, shown on hover |\n| `View` | Styled `div` primitive - the base building block |\n| `Flex` | `View` with flexbox defaults |\n| `Grid` | CSS grid container |\n| `Paper` | Elevated surface with background and shadow |\n| `Card` | Content container built on `Paper` |\n| `Quote` | Bordered quote / terminal-panel surface on `View` |\n| `AppBar` | Top application bar |\n| `Drawer` | Slide-in side panel |\n\n### Content & data display\n\n| Component | Purpose |\n| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `Typography` | Text with variant → element mapping - the reference implementation for all components |\n| `Link` | Anchor with theme-aware styling |\n| `Icon` | Icon renderer |\n| `Image` | Image with styled-system props |\n| `Avatar` | User/entity avatar |\n| `Table` | Compound data table - exports `TableContainer`, `TableHead`, `TableBody`, `TableFooter`, `TableRow`, `TableCell`, `TablePagination`, `TablePaginationActions`, `TableSortLabel`, and `TableControl` from `@soroush.tech/design-system/Table` |\n| `Accordion` | A heading that opens and closes a region - exports `AccordionSummary`, `AccordionDetails`, `AccordionActions` and `AccordionGroup` from `@soroush.tech/design-system/Accordion` |\n\n### Inputs & forms\n\n| Component | Purpose |\n| ---------------------------------------------------- | ----------------------------------------------------------------------------------------- |\n| `Autocomplete` | A field whose text finds an option in a list - one, several as chips, or free text |\n| `Fab` | A floating action button: the one main action of a page, circular or extended |\n| `Button`, `ButtonGroup`, `ToggleButton` | Actions and toggles |\n| `TextInput` | Text field |\n| `Checkbox`, `Radio`, `Switch` | Selection controls |\n| `RangeInput` | A slider - one value on a range, or two or more thumbs for a range of values |\n| `TransferList` | Two lists and the buttons that move the checked items from one to the other |\n| `NumberInput` | A field for a number - read in its locale, clamped to a range, stepped by keys or buttons |\n| `Rating` | A row of icons the user sets as a rating, or a read-only display of one |\n| `NativeSelect` | Low-level platform `<select>` - not recommended; use `Select native` |\n| `Select` | The select to use - custom listbox, or `native` for the platform picker |\n| `MenuItem` | Option row for `Select`'s listbox, and a menu row in a `MenuList` |\n| `Form`, `FormControl`, `FormLabel`, `FormHelperText` | Form composition and labeling |\n| `Pagination` | Page navigation control |\n\n### Navigation & menus\n\n| Component | Purpose |\n| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `NavTree` | A tree of links to the pages of a site - groups of links, which can fold |\n| `Breadcrumbs` | The trail of links from a site's root to the current page - a long one collapses behind a button that shows it all |\n| `Menu` | A trigger and the list of commands it opens - exports `MenuList` (the `role=\"menu\"` list that owns the keyboard), `MenuDivider`, `MenuItems` (rows from data) and `ContextMenu` (the same list, opened at the pointer by a right-click) from `@soroush.tech/design-system/Menu` |\n| `Tabs` | A row of tabs - exports `Tab`, `TabContext` (holds the value for a `TabList` and its panels), `TabList` (the `Tabs` of a `TabContext`), `TabPanel` (the content a tab shows) and `TabScrollButton` from `@soroush.tech/design-system/Tabs` |\n\n### Feedback\n\n| Component | Purpose |\n| ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------- |\n| `FabMenu` | A fab that opens a stack of actions from the corner of a page |\n| `Snackbar` | A transient message in a corner of the window, with auto-hide and an action |\n| `Alert` | An inline message with a severity, an icon, a title and an action - exports `AlertTitle` from `@soroush.tech/design-system/Alert` |\n| `Badge` | A count or a dot anchored over another element |\n| `Chip` | A compact tag: a label, an icon or avatar, a click and a delete |\n| `CircularProgress`, `LinearProgress` | Determinate/indeterminate progress indicators |\n| `Skeleton` | Loading placeholder with pulse/wave animations |\n| `Backdrop` | Dimmed overlay behind modal surfaces |\n\n### Transitions\n\n| Component | Purpose |\n| ------------------------------- | ------------------------------------------------------------------ |\n| `Collapse` | Opens and closes its content by its height, or its width |\n| `Fade`, `Grow`, `Slide`, `Zoom` | Show and hide one child by opacity, scale, an edge or from nothing |\n\n### Overlay & behavior primitives\n\n| Component | Purpose |\n| --------------- | ----------------------------------------------------------------------------------- |\n| `Tooltip` | A short description of one element, shown on hover, keyboard focus and a long touch |\n| `Portal` | Renders children into a DOM node outside the parent hierarchy |\n| `FocusTrap` | Keeps focus inside a subtree |\n| `Modal` | Dialog primitive composing `Portal`, `Backdrop`, and `FocusTrap` |\n| `Popover` | Anchored floating surface built on `Modal` |\n| `ThemeProvider` | Supplies the theme and global styles to the app |\n\n---\n\n## Theme tokens\n\nComponents never hardcode colors or sizes - props resolve against scales on the `Theme` object:\n\n| Group | Scales |\n| ------------------ | ------------------------------------------------------------------------------------------------------------- |\n| Color | `palette` (main/light/dark/contrastText per color) · `text` · `background` · `border` · `colorScheme` |\n| Typography | `typography` (variant map) · `fonts` · `fontSizes` · `fontWeights` · `lineHeights` · `letterSpacings` |\n| Space & shape | `space` · `sizes` · `radii` · `borderWidths` · `shadows` |\n| Layout | `breakpoints` (xs/sm/md/lg/xl window classes) · `layout` (columns, margins, panels, top bar per class) |\n| Component scales | `avatar` (size steps) · `skeleton` (wave highlight) |\n| Layering & effects | `zOrder` (appBar/drawer/modal/snackbar/tooltip) · `blur` · `logoFilter` · `portraitBlend` · `portraitOpacity` |\n\nProp types are derived from the interface (`keyof Theme['text']`), so adding a token to `themes.ts` propagates everywhere automatically. See [`design-system.md`](./design-system.md) for the full scale table and the palette rules.\n\n---\n\n## Theming\n\nThe theme belongs to you - the package only ships defaults. This section is the overview; the full guides are [`docs/theming.md`](./docs/theming.md) and [`docs/customization.md`](./docs/customization.md).\n\n### One theme, yours\n\n`ThemeProvider` provides exactly one theme - the built-in dark theme when you pass nothing. Bring one theme, or as many as you like: switching between them is your state, not the provider's.\n\n```tsx\nimport { ThemeProvider } from '@soroush.tech/design-system/theme'\nimport { baseTheme, createTheme } from '@soroush.tech/design-system/theme'\n\n// Zero-config: the built-in `baseTheme`.\n<ThemeProvider>{app}</ThemeProvider>\n\n// Your theme - written from scratch or extended from the base.\nconst brand = createTheme(baseTheme, { palette: { primary: { main: '#00ff88' } } })\n<ThemeProvider theme={brand}>{app}</ThemeProvider>\n\n// Mode switching is app policy - own the state and pass the active theme:\nconst [isDark, setIsDark] = useState(true)\n<ThemeProvider theme={isDark ? brandDark : brandLight}>{app}</ThemeProvider>\n```\n\n`createTheme(base, overrides)` (exported from `@soroush.tech/design-system/theme`) is the merge primitive: plain objects recurse, arrays (`shadows`, `fontSizes`) and functions replace wholesale, `undefined` values are ignored - keys are added or replaced, never removed.\n\n### Breakpoints and layout\n\n`theme.breakpoints` are Material 3's window classes, each a range from its start until the next:\n`xs` 0-599px (compact, the base), `sm` 600-839 (medium), `md` 840-1199 (expanded), `lg`\n1200-1599 (large), `xl` 1600+ (extra-large). Responsive props use them by name or position -\n`p={{ xs: 2, md: 4 }}`, `p={[2, 3, 4]}` - and `cqSm`-style keys write container queries;\n`theme.breakpoints.up('md')` and its siblings write queries for hand-written styles. Everything is\nCSS, so pages work with JavaScript off. `theme.layout` holds the layout tokens per class (columns,\nmargins, gutters, side panels, top bar); `Grid` and `Flex` apply the column grid with\n`layout` / `layout={{ lg: { columns: 16 } }}`, and apps place `AppBar`, `Sidebar` and `Drawer`\nthemselves. The full guide is the\n[Breakpoints and layout](./docs/theming.md#breakpoints-and-layout) section of the theming guide.\n\n### Component defaults\n\nComponents carry visible literal fallbacks (`size = 'md'`, `variant = 'outside'`, ...) resolved through `themeDefault(theme, key, fallback)` - so every default, including behavioral variants, is overridable via the optional `theme.defaults` map or the provider's `defaults` prop:\n\n| Key | Fallback | Drives |\n| -------------------------------------------- | ---------------------------------- | -------------------------------------- |\n| `size` / `compactSize` | `'md'` / `'sm'` | sized components / dense table actions |\n| `color` / `neutralColor` | `'primary'` / `'default'` | accent controls / toggle controls |\n| `textColor` / `accentTextColor` | `'initial'` / `'primary'` | body text / icons + input labels |\n| `bg` / `surfaceBg` / `inputBg` | `'default'`/`'paper'`/`'terminal'` | switch track / paper surfaces / inputs |\n| `borderRadius` / `surfaceRadius` | `'md'` / `'sq'` | grouped controls / surfaces |\n| `avatarSize` / `borderColor` / `borderWidth` | `'md'` / `'primary'` / `'thin'` | avatars and rings |\n| `iconSize` | `'lg'` | Icon default glyph size (`theme.icon`) |\n| `inputMinWidth` | `'12rem'` | least width of an input not full width |\n| `buttonVariant` / `switchVariant` | `'contained'` / `'outside'` | Button / Switch visual variants |\n| `inputVariant` | `'default'` | TextInput, Select, NativeSelect frames |\n| `avatarVariant` / `cardVariant` | `'circular'` / `'paper'` | Avatar shape / Card treatment |\n| `linkUnderline` | `'always'` | Link underline behavior |\n| `paginationVariant` / `paginationShape` | `'text'` / `'circular'` | Pagination items |\n\nThe built-in themes carry no `defaults` - the literals apply. A theme with entirely different size or palette keys stays valid by pointing the keys at its own tokens:\n\n```tsx\n<ThemeProvider defaults={{ size: 'compact', color: 'brand', switchVariant: 'inside' }}>\n```\n\n### Per-component customization (`theme.components`)\n\nCustomize one component for the whole app - default prop values, per-slot CSS, and new variant values - without wrapping or forking:\n\n```tsx\nconst brand = createTheme(baseTheme, {\n components: {\n Button: {\n // Buttons default to sm + rounded; explicit props and ButtonGroup still win.\n defaultProps: { size: 'sm', shape: 'rounded' },\n\n // Per-slot CSS merged after Button's own styles - the theme wins the cascade,\n // but per-instance props (m, p, width, ...) still beat the theme.\n styleOverrides: {\n root: ({ theme, ownerState }) => ({\n letterSpacing: theme.letterSpacings.wide,\n ...(ownerState.variant === 'contained' && { textTransform: 'none' }),\n }),\n label: { fontStyle: 'italic' },\n },\n\n // A new variant value - register it first so it typechecks:\n // declare module '@soroush.tech/design-system/theme' { interface ButtonVariants { dashed: true } }\n variants: [\n {\n props: { variant: 'dashed' },\n style: ({ theme }) => ({\n backgroundColor: 'transparent',\n border: `${theme.borderWidths.thin} dashed ${theme.border.primary}`,\n }),\n },\n ],\n },\n },\n})\n```\n\nStyle callbacks receive `{ theme, ownerState }`, where `ownerState` is the styled root's **resolved** props (after group context, `defaultProps`, and `theme.defaults`). `defaultProps` sits in the standard precedence chain: explicit prop → group context → `defaultProps` → `theme.defaults.*` → the component's literal fallback. `variants` arrays are replaced wholesale by `createTheme`, never merged.\n\nYour own components can join the same mechanism: create their roots with this package's `styled(tag, { name: 'MyWidget', slot: 'root' })` and register the name by augmenting `ThemeComponents`. Zero-config themes pay nothing - the resolver bails out on the first check when `theme.components` is absent.\n\n### Extending tokens (declaration merging)\n\nEvery scale is an open interface declared on `@soroush.tech/design-system/theme`, so you can add palette colors, tokens, or whole scales - and every component prop union (`color`, `bg`, `size`, ...) widens automatically:\n\n```ts\nimport type { PaletteEntry } from '@soroush.tech/design-system/theme'\n\ndeclare module '@soroush.tech/design-system/theme' {\n interface ThemePalette {\n brand: PaletteEntry // new palette color\n }\n interface ThemeBackground {\n tertiary: string // new background token\n }\n interface Theme {\n elevations: Record<'low' | 'mid' | 'high', string> // whole new scale\n }\n}\n```\n\nThen supply the values with `createTheme` and use the new keys:\n\n```tsx\nconst brandDark = createTheme(baseTheme, {\n palette: { brand: { main: '#00ff88', light: '#66ffb2', dark: '#00b25f', contrastText: '#000' } },\n background: { tertiary: '#101418' },\n elevations: { low: '0 1px 2px', mid: '0 2px 6px', high: '0 6px 18px' },\n})\n\n<ThemeProvider theme={brandDark}>\n <Button color=\"brand\" />\n <View bg=\"tertiary\" />\n</ThemeProvider>\n```\n\nNotes: new object-valued keys (like a `PaletteEntry`) must be supplied complete - components read `.main`/`.contrastText` at runtime; and TypeScript cannot verify at runtime that an augmented token was actually supplied, so always pair an augmentation with the matching override.\n\n---\n\n## Adding a component\n\nScaffold with the skill - it reads the live `Typography` files and `design-system.md` so output matches the codebase:\n\n```\n/new_theme_component ComponentName\n```\n\nThen work through the checklist at the bottom of [`design-system.md`](./design-system.md).\n\n---\n\nThe library takes inspiration from [Material UI](https://mui.com/) - its component vocabulary and prop conventions will feel familiar - but it is written entirely in house. It is not a clone or a fork: every component is built from scratch on our own engine and token system, and the API is free to diverge wherever it serves its consumers better.\n\n---\n\n## Release notes\n\nPer-version notes for every published release live in\n[`release-notes/`](https://github.com/soroush-tech/design-system/tree/main/packages/design-system/release-notes).\n",
|
|
1376
1376
|
"url": "https://docs.soroush.tech/design-system/"
|
|
1377
1377
|
},
|
|
1378
1378
|
{
|
|
@@ -1386,7 +1386,7 @@ const content = {
|
|
|
1386
1386
|
"id": "styled-system-overview",
|
|
1387
1387
|
"title": "Styled-system overview",
|
|
1388
1388
|
"summary": "The style-prop engine underneath the design system.",
|
|
1389
|
-
"body": "A maintained, first-class-TypeScript rewrite of [styled-system](https://github.com/jxnblk/styled-system) v5 - responsive, theme-aware style props for CSS-in-JS.\n\nIt is a **drop-in replacement** for the `styled-system` runtime: the root export surface matches upstream verbatim, and the package ships its own types (replacing `@types/styled-system`).\n\n## Features\n\n- Add style props that hook into your own theme\n- Quickly set responsive `font-size`, `margin`, `padding`, `gap`, `width`, and more with props\n- Influenced by constraint-based design-system principles\n- Typographic scale, and a spacing scale for `margin`, `padding` and `gap`\n- Works with any color palette\n- Works with most CSS-in-JS libraries, including [Emotion](https://emotion.sh) and [styled-components](https://styled-components.com)\n- First-class TypeScript types - theme-scale-aware props, replacing `@types/styled-system`\n\n## Install\n\n```sh\n# npm\nnpm install @soroush.tech/styled-system\n```\n\n```sh\n# pnpm\npnpm add @soroush.tech/styled-system\n```\n\n```sh\n# yarn\nyarn add @soroush.tech/styled-system\n```\n\n
|
|
1389
|
+
"body": "A maintained, first-class-TypeScript rewrite of [styled-system](https://github.com/jxnblk/styled-system) v5 - responsive, theme-aware style props for CSS-in-JS.\n\nIt is a **drop-in replacement** for the `styled-system` runtime: the root export surface matches upstream verbatim, and the package ships its own types (replacing `@types/styled-system`).\n\n## Features\n\n- Add style props that hook into your own theme\n- Quickly set responsive `font-size`, `margin`, `padding`, `gap`, `width`, and more with props\n- Influenced by constraint-based design-system principles\n- Typographic scale, and a spacing scale for `margin`, `padding` and `gap`\n- Works with any color palette\n- Works with most CSS-in-JS libraries, including [Emotion](https://emotion.sh) and [styled-components](https://styled-components.com)\n- First-class TypeScript types - theme-scale-aware props, replacing `@types/styled-system`\n\n## Install\n\n```sh\n# npm\nnpm install @soroush.tech/styled-system\n```\n\n```sh\n# pnpm\npnpm add @soroush.tech/styled-system\n```\n\n```sh\n# yarn\nyarn add @soroush.tech/styled-system\n```\n\n`prop-types` (`^15.8.1`, optional peer) is used by a single [subpath](#subpath-imports),\n`prop-types`. Install it only if you import that subpath. The `should-forward-prop` subpath\nneeds nothing installed: its check for a valid attribute is a dependency of this package. You bring your own CSS-in-JS\nlibrary (Emotion, styled-components, ...); the core carries neither at runtime.\n\n## Usage\n\n```ts\n// Example uses Emotion, but styled-system works with most other CSS-in-JS libraries as well\nimport styled from '@emotion/styled'\nimport { space, layout, typography, color } from '@soroush.tech/styled-system'\n\n// Add styled-system functions to your component\nconst Box = styled.div`\n ${space}\n ${layout}\n ${typography}\n ${color}\n`\n```\n\nEach style function exposes its own set of component props that handle styles based on values defined in a theme.\n\n```tsx\n// width: 50%\n<Box width={1 / 2} />\n\n// font-size: 20px (theme.fontSizes[4])\n<Box fontSize={4} />\n\n// margin: 16px (theme.space[2])\n<Box m={2} />\n\n// padding: 32px (theme.space[3])\n<Box p={3} />\n\n// color\n<Box color=\"tomato\" />\n\n// color: #333 (theme.colors.gray[0])\n<Box color=\"gray.0\" />\n\n// background-color\n<Box bg=\"tomato\" />\n```\n\n### Responsive style props\n\nSet responsive `width`, `margin`, `padding`, `font-size`, and other properties with a shorthand array syntax. See [Responsive Styles](./docs/responsive-styles.md).\n\n```tsx\n// responsive width\n<Box width={[1, 1 / 2, 1 / 4]} />\n\n// responsive font-size\n<Box fontSize={[2, 3, 4]} />\n\n// responsive margin\n<Box m={[1, 2, 3]} />\n\n// responsive padding\n<Box p={[1, 2, 3]} />\n```\n\n### Subpath imports\n\nSubpaths mirror the original `@styled-system/*` packages:\n\n```ts\nimport { css } from '@soroush.tech/styled-system/css'\nimport { themeGet } from '@soroush.tech/styled-system/theme-get'\nimport { pick, omit } from '@soroush.tech/styled-system/props'\nimport propTypes, { createPropTypes } from '@soroush.tech/styled-system/prop-types'\nimport shouldForwardProp, {\n createShouldForwardProp,\n props,\n} from '@soroush.tech/styled-system/should-forward-prop'\n```\n\n## Drop-in via alias\n\nExisting `styled-system` users can swap with a package-manager alias - no code changes:\n\n```jsonc\n\"dependencies\": {\n \"styled-system\": \"npm:@soroush.tech/styled-system@^5\"\n}\n```\n\nThe satellite `@styled-system/*` packages don't need separate aliases - import them as\nsubpaths off the aliased `styled-system` name, and they resolve through this package's\n`exports`:\n\n```ts\nimport themeGet from 'styled-system/theme-get'\nimport propTypes from 'styled-system/prop-types'\nimport { css } from 'styled-system/css'\nimport shouldForwardProp from 'styled-system/should-forward-prop'\n```\n\nTypes resolve under both modern module resolution (`node16`/`nodenext`/`bundler`, via\n`exports`) and classic `node` (via `typesVersions`).\n\n## Documentation\n\nFull docs live in [`docs/`](./docs/README.md):\n\n- [Getting Started](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/docs/getting-started.md)\n- [Responsive Styles](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/docs/responsive-styles.md)\n- [How it Works](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/docs/how-it-works.md)\n- [Custom Props](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/docs/custom-props.md)\n- [Variants](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/docs/variants.md)\n- [API](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/docs/api.md)\n- [Reference Table](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/docs/table.md)\n- [TypeScript](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/docs/typescript.md)\n- [Guides](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/docs/guides/index.md)\n\nRunnable demos live in the [examples repo](https://github.com/soroush-tech/examples/tree/main/styled-system).\n\n## Release notes\n\nPer-version notes for every published release live in\n[`release-notes/`](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/release-notes).\n\n## License\n\nMIT - a rewrite of styled-system (© 2017-2021 Brent Jackson), see [`LICENSE`](https://github.com/soroush-tech/design-system/tree/main/packages/styled-system/LICENSE).\n",
|
|
1390
1390
|
"url": "https://docs.soroush.tech/styled-system/"
|
|
1391
1391
|
},
|
|
1392
1392
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soroush.design/mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4-alpha.0",
|
|
4
4
|
"description": "MCP server for the @soroush.tech design system - serves the component inventory, every component README, and the theme token contract to AI coding tools.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|