page/design/components-header.md
The component header
One YAML block in the first comment of a component file: id, level, uses, parts, states, status, controls. HTML and React files carry the same block; one parser reads both.
The first comment of a component file holds the record of the component: YAML between --- lines. In HTML it is <!--- … --->, in TS, TSX and JS it is /*--- … ---*/. Only blanks, a 'use client' line and // lines may stand before it. The parser is lib/header.ts of the package (parseHeader), for tests of other packages too.
id: package-card # kebab-case; a shadcn name when shadcn has the component
title: Package card
level: composite # primitive | composite | block | shell | page
description: One sentence.
uses: [icon-plate, chip, kicker]
parts: [card-header, card-title, card-description, card-content, card-footer] # data-slot names
states: [default, hover, selected] # interaction states shown side by side
status: [loading, empty, error] # data states, set as data-status
controls:
preset: {kind: select, options: [base, compact, editorial, cover, tiles], default: base}
cssProperties: [--sb-glow, --sb-edge] # extension tokens it reads
| Field | What it is |
|---|---|
id | The name of the component, kebab-case; the same id in the HTML and the React file means one component. |
level | primitive = registry:ui, composite = registry:component, block = registry:block, shell = registry:block (the lens frame, see The lens shell), page = registry:page (the shadcn registry types). |
uses | Ids of the components it is built from. A component uses only its own level or below (check no-level-up) and every id exists (check uses-exist). |
parts | The data-slot names of the parts: they become the cssParts of the manifest. |
states / status | Interaction states and data states; the catalog shows each side by side, and the stories have one story for each. |
controls | The control schema: {name: {kind, label?, options?, default?, min?, max?, step?, unit?, section?, colors?}}, kind one of select, segment (2 to 4 options), bool, range, swatch, text. |
cssProperties | Extension tokens (--sb-…) the component reads. |
What sync writes
- One page per id in
/design/components/<id>.md(this collection). The HTML and the React implementation are joined on it; the text under the page's header is kept. lib/design/components.data.js(window.SB_COMPONENTS) for the lenses./design/custom-elements.json, a Custom Elements Manifest: one module per component, attributes from the controls (data-<control>),cssProperties,cssPartsfrom the parts./design/stories/<id>.stories.js, Storybook CSF 3:argTypesfrom the controls, one story per state, rendering the HTML template.
The package Design components puts this page at
/design/components-header.md.Source text