страница пакета→ /design/shtukbase-ui-react.md
pages/design/shtukbase-ui-react.md
63 строки, 4.7 КБ. Как страница.
Этот текст ещё не переведён. Ниже английский оригинал.
- ---
- type: Page
- title: "The Shtukbase React component library"
- description: "React components of the Shtukbase design, the same ids and markup as the HTML library: where the code is placed, what the project needs, how a control becomes a prop."
- icon: "⚛️"
- target: src/sb-ui
- css: design/shtukbase-ui-html/ui.css
- ---
- # The Shtukbase React component library
- The same components as the [HTML library](/design/shtukbase-ui-html.md), in React: the same ids, levels, states and controls, the same markup (`data-slot`, classes, `data-<control>` attributes). The six primitives that shadcn has (`button`, `badge`, `input`, `select`, `switch`, `slider`) are the shadcn components, style new-york-v4, with our class and attributes added; the rest are written in the same manner. The look is the CSS of the HTML library, written once; this library imports it and adds behaviour.
- ## How it works
- As with shadcn: the package does not install an npm dependency but copies sources into the project. The code becomes the project's code, and it can be edited.
- - The folder is the `target:` field of this page (now `src/sb-ui`). If you change it, run `shtuk run shtukbase-ui-react place`: the library will be placed in the new folder.
- - The CSS file is the `css:` field (by default the `ui.css` of the HTML library, which joins the CSS of every component). The path to it is written in the `@import` of `styles/index.css`.
- - `place` also adds the folder to `sources:` in the header of [the Components collection](/design/components.md), so that `design-components sync` lists the React component next to its HTML one (the one-line form `sources: [a, b]`; any other form is left alone and `place` says so).
- - Next to the code lies `.shtukbase-ui-react.json`: what is placed and with what hash.
- - A package update places the new version over untouched files. Files the project edited stay as they are; `place` names them. To replace those too: `shtuk run shtukbase-ui-react place --force`.
- What is in the folder:
- | Folder | What |
- |---|---|
- | `primitives/` | `button`, `badge`, `chip`, `icon-plate`, `kicker`, `input`, `select`, `switch`, `slider`, `swatches`, `avatar`, `checkbox`, `label`, `progress`, `radio-group`, `separator`, `skeleton`, `textarea`, `tooltip`, `status-dot` |
- | `composites/` | `card`, `package-card`, `field`, `accordion`, `alert`, `breadcrumb`, `command`, `dialog`, `dropdown-menu`, `popover`, `table`, `tabs`; ours `record-card`, `property-row`, `details-card`, `empty-state`, `tree-item`, `toolbar`, `search-field`, `settings-group` |
- | `blocks/` | `area`, `package-grid`, `settings-bar` |
- | `shell/` | Sidebar, panels, sections, collapsible, scroll area, sheet, and page forms used by a [lens layout](/design/conventions/layout.md) |
- | `lib/define.ts` | the contract of a states file: `defineComponent`, `defineStates` |
- | `lib/controls.ts` | controls as attributes and custom properties: `dataProps`, `rangeStyle` |
- | `lib/utils.ts` | `cn`, class merging |
- | `lib/icons.tsx` | the small line icons of the templates, and two prop helpers |
- | `styles/index.css` | imports the `ui.css` of the HTML library |
- Every component has a header in its first comment and a `<id>.states.tsx` with `meta` and `states`; the state names are those of the header, and each is the props that draw the matching `<template>` of the HTML library.
- ## Controls are props
- The header of a component lists its controls; the same list is in the HTML library. In React a control is a prop named like the control in camelCase:
- ```tsx
- <PackageCard preset="cover" size="l" glow="halo" glowStrength={60} title="Basic" />
- ```
- A `select`, `segment`, `swatch` or `text` control becomes `data-<control>="<value>"` on the root, a `bool` the bare attribute, a `range` the inline custom property `--<id>-<control>`: exactly what the HTML library writes, so one CSS serves both.
- ## What the project needs
- The package does not install dependencies. The project installs them itself:
- - `react` and `react-dom` ^19;
- - `radix-ui` (the shadcn primitives: `Slot`, `Switch`, `Select`, `Slider`), `class-variance-authority` ^0.7, `cn` ^0.5, `lucide-react`;
- - `tailwindcss` ^4 and `tw-animate-css` (the shadcn primitives keep their Tailwind classes; the theme comes from the `shadcn` package and the style);
- - TypeScript with `jsx: react-jsx`.
- Connecting the look is one line in the application's main CSS, after Tailwind: `@import "./sb-ui/styles/index.css";` (the path from your file to the `target` folder). The CSS of the HTML library is plain CSS outside Tailwind's layers, so where a shadcn utility and a component rule set the same property, the component rule wins.
- ## Source
- shadcn/ui components: MIT, © 2023 shadcn, style new-york-v4, read on 28.11.2026 (the `slider`, which the `shadcn` package does not carry, on 29.11.2026).