Design systems
How Dex finds your components, the designSystem setting that describes them to agents, and how styling works.
Files use your project’s own components; when create cannot find them, agents add copies.
Finding components
create looks for, in order:
- A shadcn
components.json, at the root or in a workspace package. Itsuialias is the folder; its Tailwind CSS entry becomes your global styles. - A usual folder with at least three components, at the root then in each workspace package:
components/ui,src/components/ui,app/components/ui,src/design-system,src/ui,ui,lib/components,src/components,components. Components arebutton.tsx,Button.tsxorDatePicker/index.tsx; stories and tests are skipped. - The folder you pass, which skips the search:
npm create dex@latest -- --components packages/ui/src/components.
Workspace packages come from workspaces in package.json or pnpm-workspace.yaml. Imports match the app’s, from tsconfig paths (@/components/ui/button) or a package’s name and exports (@acme/ui/shadcn/button); when the import cannot be worked out, the components are listed without one, for you to set designSystem.components.import. A package whose exports serve only its entry (@dub/ui, @primer/react) is named instead: create writes components: "@dub/ui", and views import each component from the package.
- What it found, confirmed: in a terminal
createshows the folder, how many components and how views will import them, and where it read that; “No” picks another folder (and asks for the import if it cannot tell). A folder that is only a guess (src/components, beside the app’s own) is marked so. Without a terminal it takes what it found and says so beside--components; with components in two folders and nothing to say which, it writes nothing and exits 2, listing--componentsfor each. - Nothing found:
createasks for a folder, offers shadcn (npx shadcn@latest init;--shadcnskips the question) or leavesdesignSystem.componentsto you (--components none). Run by an agent or script, it prints next steps and tells agents never to add a component without asking. - Added later:
npx dex components --components <folder>scans a folder and prints thedesignSystem.componentsto put index.config.ts.npx dex components [--json]lists the components the studio resolved. - Recognised libraries: MUI, Mantine, Chakra UI, Ant Design and Radix Themes get imports and styling filled in. Others get their name and styling. Mantine, Chakra UI and Radix Themes render only inside their provider, so
createwritesstudio/provider.tsxwith it and setsdesignSystem.provider(see below);--provider <module>uses yours,--provider noneskips it.
The design system in dex.config.ts
designSystem in dex.config.ts says what files build with. What it leaves out is read from your project’s own files each time the studio starts, so it holds only what they can’t say, and a value written there wins. In a shadcn project, components.json gives the components’ folder and import, the stylesheet, the styling and the marker, so designSystem can be left out; edit components.json and the next start follows it. The components folder is scanned each time the studio starts, so a new component appears without setting anything up again:
import { defineConfig } from "@dexhq/canvas/config";
export default defineConfig({
content: "./studio",
designSystem: {
name: "Acme UI",
components: {
folder: "./packages/ui/src/components",
import: "@acme/ui/components", // button.tsx → "@acme/ui/components/button"
about: { button: { description: "Actions. One primary per view." } },
ignore: ["sonner"],
},
imports: ["@acme/icons/*"],
styles: ["./packages/ui/src/styles/globals.css"],
styling: "tailwind",
marker: "[data-slot]",
provider: "./packages/ui/src/provider.tsx",
contributing: "./packages/ui/CONTRIBUTING.md",
},
});
| Field | For |
|---|---|
name |
Shown to agents. Default: the name of the package the components are in, else your project’s. |
components |
A folder to scan (folder, import, and about and ignore by slug); a package’s name ("@primer/react"), whose entry’s exported components are listed, each imported from the package itself; or a list ({ slug, name, import } each). Default: the folder components.json’s ui alias names. |
imports |
Paths views may import besides the components (<import>/* is added for a folder, the package for a package). |
styles |
Your global CSS: paths relative to the config, or package specifiers. The studio imports Tailwind v4 first when none of them does, for its own interface. Default: components.json’s stylesheet. Setup never picks a built stylesheet (one in dist/ or another build folder, Tailwind’s output, or minified): it names the source, or says to choose it with --styles. Root-relative URLs in it and in your components (url(/fonts/inter.woff2)) find your app’s public/ folder (SvelteKit’s static/), in dex dev and in a build, after the studio’s own files. |
styling |
tailwind, css-modules, stylex, vanilla-extract, css-in-js, plain-css, other. Default: tailwind with a components.json, else what the components’ package or your project depends on. |
marker |
Selector for your components’ output ([class*="Mui"] for MUI), to spot hand-built markup. Default: [data-slot] with a components.json. |
provider |
A module whose default export wraps every view (on the canvas, in Play, in a built studio): theme providers and global setup, such as MantineProvider or MUI’s ThemeProvider with your theme. A path relative to the config, or a package’s module. See Configuration. |
guide |
Markdown agents read on the design language. Default: the content folder’s DESIGN.md. |
contributing |
Markdown on how to add or change a component. |
links, mcp |
Optional. Docs, Storybook or Figma; your system’s MCP server. |
A design system that ships as one package entry (Primer, Braid, @dub/ui) is named, and views import its components from the entry, as your app does:
designSystem: { components: "@primer/react" }, // import { Button } from "@primer/react"
A design system can ship this as a preset: export default defineDesignSystem({ … }) from @dexhq/canvas/config, then designSystem: acme. The config is checked when it loads, and a mistake is reported with its path (designSystem.components.folder: …).
Agents read what views may import from brief, and the components from components or npx dex components. With ui.primitives: true the studio’s own buttons, menus and dialogs come from the same components, and ui.chromeTheme maps its colours to your tokens.
Studios set up before
The studio no longer reads studio/design-system/index.ts, the adapter init used to write. A studio that still has one has no design system: doctor fails and names npx dex upgrade, which moves it into dex.config.ts and its prose into DESIGN.md (see Upgrading).
Styling
Your global CSS comes first in every view. Views render on a page of their own, with your CSS and none of the interface’s. With Tailwind 3, your tailwind.config applies in views: Tailwind 4 reads it, with no file added to your project. A design system styled some other way (styling other than tailwind, or a project that doesn’t depend on Tailwind) gets Tailwind’s theme and utilities in views but not its reset, which would override its own rules (StyleX’s layers). The interface takes your CSS only with ui.theme: "design-system", or when it renders your components (ui.primitives or ui.components). create detects Tailwind, StyleX, vanilla-extract and CSS-in-JS (Emotion, styled-components); CSS Modules and CSS-in-JS need no setup. Add build-time styling (StyleX, vanilla-extract) as a Vite plugin in plugins in dex.config.ts.
Unbuilt packages
doctor and dev warn when a package’s exports point at a missing build, and say how to build it:
! @acme/ui is not built, so views cannot import it. Build it first (in a monorepo, `npx turbo run build --filter=@acme/ui`).
doctor also warns when the design system lists no components or imports, and fails when its components folder or styles are missing.