The /design-system section

Docs

The /design-system section is your design system shown inside your app: every component in a gallery, every block on its own route, the sample pages, your generated page and your screens, with its own copy of the theme and its own light and dark switch. The starter ships it, and designsource add writes it into an existing app with the full kit.

How to use it

In a Next.js App Router app it is the route /design-system; in a Vite app its own page, /design-system.html. Both open on an index of components by group (Forms and inputs, Overlays, Navigation, Layout, Data and feedback, Chat); each component and each block has a page with a side list of every item, the open one marked. The header's menus jump between components, blocks, screens, the sample pages and the custom page.

It comes with the full kit: a first add run answered All, --all, --yes, a run outside a terminal, or a bare rerun in an app holding every component. add <names…> and Pick some… write no section. --no-blocks writes it without the blocks and their libraries.

How it works

Next.js. The section is a route folder under app/design-system/ (or src/app/), a layout mounting the section shell over your app's own header and footer as a full-window layer, and one catch-all page that prerenders the index, every component, every block, the sample pages and, with a generated page, the custom route. Its pieces go under components/design-system/ and components/blocks/, with the three preview modules in the components folder and two small modules beside lib/utils. The project's variables are declared on the section's own wrapper for light and dark, with a reset scoped to it, so your app's theme rules do not reach it and its theme does not leak out.

Vite. An HTML page beside index.html with its own entry and its own stylesheet (fonts, Tailwind with its reset, the theme), listed among vite.config's build inputs so vite build builds it. A config the command cannot edit safely is left alone and the lines to add are printed.

Screens get a view once the app has any: /design-system/screens lists them by kind and /design-system/screens/<name> draws one (Vite: /design-system.html#/screens). The section renders each screen itself, so nothing needs mounting. Marketing pages sit under a Pages heading and are drawn inside your site's menu and footer, with their links inert. The starter fills it with the project's screens, and in an existing app it lists the screens add --screen pulled in.

Blocks follow what is on disk after the first run: a rerun does not add back blocks a --no-blocks run skipped, and --no-blocks on an app that has them leaves them and says how many. The config's block list is cut to what is there.

Reruns refresh every section file as they do components: a file you edited is kept and named, a foreign file stops the run before setup. The section's JSON data is rewritten every run and never asked about.

An app with its own /design-system route, a Pages Router app, or a library the section needs at another major gets one line and no section; the components are still written.

What can go wrong

  • The /design-system section comes with the full kit: run designsource add --all.: the run named components or picked some.
  • Skipped the /design-system section: this app already has its own /design-system route (…): rename yours, or live without the section.
  • The section shows light while your app is dark: it reads its own switch, stored on its own, by design.