@you-agent-factory/components 0.0.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/README.md +223 -0
- package/docs/README.md +83 -0
- package/docs/button.md +119 -0
- package/docs/charts.md +325 -0
- package/docs/data-display-code-panel.md +120 -0
- package/docs/feedback-alert-panel.md +117 -0
- package/docs/feedback-skeleton.md +54 -0
- package/docs/forms-form-field.md +490 -0
- package/docs/forms-input-primitives.md +311 -0
- package/docs/forms-select-primitives.md +362 -0
- package/docs/graphs.md +250 -0
- package/docs/layout-display-primitives.md +211 -0
- package/docs/overlays.md +414 -0
- package/docs/table-data-table.md +331 -0
- package/docs/typography-roles.md +182 -0
- package/docs/widget-frame-recipes.md +273 -0
- package/package.json +161 -0
- package/src/category-paths.ts +20 -0
- package/src/charts/chart-state-panel.tsx +103 -0
- package/src/charts/chart.tsx +287 -0
- package/src/charts/index.ts +21 -0
- package/src/data-display/code-panel.tsx +67 -0
- package/src/data-display/data-table.tsx +180 -0
- package/src/data-display/description-list.tsx +24 -0
- package/src/data-display/index.ts +34 -0
- package/src/data-display/table-layout.ts +12 -0
- package/src/data-display/table.tsx +131 -0
- package/src/feedback/alert-panel-semantics.ts +75 -0
- package/src/feedback/alert-panel.tsx +187 -0
- package/src/feedback/index.ts +21 -0
- package/src/feedback/skeleton.tsx +16 -0
- package/src/forms/index.ts +73 -0
- package/src/forms/package-checkbox.tsx +50 -0
- package/src/forms/package-enum-select.tsx +185 -0
- package/src/forms/package-file-input.tsx +25 -0
- package/src/forms/package-form-field.tsx +202 -0
- package/src/forms/package-input.tsx +25 -0
- package/src/forms/package-native-select.tsx +25 -0
- package/src/forms/package-select.tsx +209 -0
- package/src/forms/package-textarea.tsx +35 -0
- package/src/forms/select-icons.tsx +35 -0
- package/src/graphs/graph-edge-path.ts +241 -0
- package/src/graphs/graph-edge.tsx +130 -0
- package/src/graphs/graph-interactive-example.tsx +187 -0
- package/src/graphs/graph-node-button.tsx +51 -0
- package/src/graphs/graph-node-handle-badge.tsx +108 -0
- package/src/graphs/graph-node-handle.ts +28 -0
- package/src/graphs/graph-node-shell.tsx +111 -0
- package/src/graphs/graph-node-state-indicator.tsx +47 -0
- package/src/graphs/graph-node-state.ts +111 -0
- package/src/graphs/graph-viewport-surface.tsx +27 -0
- package/src/graphs/index.ts +41 -0
- package/src/icons/index.ts +4 -0
- package/src/index.ts +209 -0
- package/src/layout/action-row.tsx +53 -0
- package/src/layout/index.ts +9 -0
- package/src/layout/surface-panel.tsx +91 -0
- package/src/navigation/index.ts +4 -0
- package/src/overlays/collapsible.tsx +22 -0
- package/src/overlays/dialog.tsx +148 -0
- package/src/overlays/index.ts +31 -0
- package/src/overlays/overlay-layout.ts +9 -0
- package/src/overlays/popover.tsx +29 -0
- package/src/overlays/scroll-area.tsx +78 -0
- package/src/primitives/button-link.tsx +22 -0
- package/src/primitives/button.tsx +258 -0
- package/src/primitives/icon-button-shell.tsx +49 -0
- package/src/primitives/index.ts +31 -0
- package/src/primitives/package-text.tsx +29 -0
- package/src/primitives/typography-roles.ts +12 -0
- package/src/primitives/typography.tsx +165 -0
- package/src/recipes/index.ts +61 -0
- package/src/recipes/widget-frame-content.tsx +114 -0
- package/src/recipes/widget-frame-disclosure.tsx +161 -0
- package/src/recipes/widget-frame-layout.ts +40 -0
- package/src/recipes/widget-frame-skeleton.tsx +16 -0
- package/src/recipes/widget-frame-states.tsx +99 -0
- package/src/recipes/widget-frame-typography.ts +19 -0
- package/src/recipes/widget-frame.tsx +84 -0
- package/src/styles/color-palette-presets.css +167 -0
- package/src/styles/color-role-tokens.css +163 -0
- package/src/styles/layout-role-tokens.css +27 -0
- package/src/styles/text-color-role-tokens.css +29 -0
- package/src/styles/typography-role-tokens.css +72 -0
- package/src/styles/typography-role-utilities.css +73 -0
- package/src/styles/typography-roles.css +53 -0
- package/src/styles.css +32 -0
- package/src/testing/index.ts +13 -0
- package/src/testing/render.tsx +16 -0
- package/src/tokens/index.ts +4 -0
- package/src/utilities/cn.ts +5 -0
- package/src/utilities/index.ts +6 -0
package/README.md
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# @you-agent-factory/components
|
|
2
|
+
|
|
3
|
+
Presentation components, shared design tokens, and small utilities for building
|
|
4
|
+
factory-style UIs outside the dashboard. The package is domain-free: it does not
|
|
5
|
+
ship data fetching, durable state, business workflows, or product copy.
|
|
6
|
+
|
|
7
|
+
## Install and workspace setup
|
|
8
|
+
|
|
9
|
+
Add the package to your application dependencies. In this monorepo the dashboard
|
|
10
|
+
uses a workspace link:
|
|
11
|
+
|
|
12
|
+
```json
|
|
13
|
+
{
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@you-agent-factory/components": "file:./packages/components"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Published consumers should depend on the same package name
|
|
21
|
+
(`@you-agent-factory/components`) from their chosen distribution channel.
|
|
22
|
+
|
|
23
|
+
Peer dependencies:
|
|
24
|
+
|
|
25
|
+
- `react` ^19.0.0
|
|
26
|
+
- `react-dom` ^19.0.0
|
|
27
|
+
|
|
28
|
+
Some category entrypoints (for example charts and graphs) also require the
|
|
29
|
+
package's direct dependencies (`recharts`, `@xyflow/react`). Install those in
|
|
30
|
+
the host app when you import those categories.
|
|
31
|
+
|
|
32
|
+
## Import package styles
|
|
33
|
+
|
|
34
|
+
Import the package styles entrypoint once in your application CSS (or an
|
|
35
|
+
equivalent global stylesheet hook) before rendering components:
|
|
36
|
+
|
|
37
|
+
```css
|
|
38
|
+
@import "@you-agent-factory/components/styles.css";
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
With Tailwind CSS v4, a typical host `styles.css` also imports Tailwind and may
|
|
42
|
+
layer app-specific utilities after the package tokens:
|
|
43
|
+
|
|
44
|
+
```css
|
|
45
|
+
@import "tailwindcss";
|
|
46
|
+
@import "@you-agent-factory/components/styles.css";
|
|
47
|
+
|
|
48
|
+
/* Host-only utilities and foundation overrides */
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The entrypoint exposes shared role tokens, palette presets, typography tokens,
|
|
52
|
+
and layout tokens. Host applications do not need dashboard routes, providers,
|
|
53
|
+
API clients, or generated OpenAPI types to use these tokens.
|
|
54
|
+
|
|
55
|
+
## Import components and utilities
|
|
56
|
+
|
|
57
|
+
Category entrypoints are deep imports under the package name:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { COMPONENTS_PACKAGE_NAME } from "@you-agent-factory/components";
|
|
61
|
+
import * as primitives from "@you-agent-factory/components/primitives";
|
|
62
|
+
import * as forms from "@you-agent-factory/components/forms";
|
|
63
|
+
import { cn } from "@you-agent-factory/components/utilities";
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`COMPONENTS_PACKAGE_NAME` is the stable package identifier
|
|
67
|
+
(`"@you-agent-factory/components"`). Category paths include `primitives`, `forms`,
|
|
68
|
+
`layout`, `feedback`, `data-display`, `navigation`, `overlays`, `charts`,
|
|
69
|
+
`graphs`, `recipes`, `icons`, `utilities`, `testing`, and `tokens`.
|
|
70
|
+
|
|
71
|
+
Use `cn` from `@you-agent-factory/components/utilities` for class name composition
|
|
72
|
+
in component code instead of dashboard-local helpers.
|
|
73
|
+
|
|
74
|
+
## Consumer responsibilities
|
|
75
|
+
|
|
76
|
+
The component package owns presentation: markup, styles, tokens, and generic
|
|
77
|
+
utilities. Host applications own everything domain-specific:
|
|
78
|
+
|
|
79
|
+
- **Data fetching** — API calls, caching, and synchronization with backend
|
|
80
|
+
services.
|
|
81
|
+
- **Durable state** — session persistence, undo/redo, and cross-route state
|
|
82
|
+
that outlives a single render.
|
|
83
|
+
- **Business workflows** — factory orchestration, validation rules, and product
|
|
84
|
+
behavior tied to your domain model.
|
|
85
|
+
- **Domain copy** — user-visible strings, labels, and messaging for your
|
|
86
|
+
product.
|
|
87
|
+
|
|
88
|
+
Pass data and callbacks into components as props; do not expect the package to
|
|
89
|
+
reach into your app's stores, routers, or API layer.
|
|
90
|
+
|
|
91
|
+
## Theming
|
|
92
|
+
|
|
93
|
+
Theme through package tokens and semantic roles, not dashboard-specific CSS.
|
|
94
|
+
|
|
95
|
+
1. **Palette presets** — Set `data-color-palette` on a root element (or
|
|
96
|
+
`:root`) to select a built-in preset. Available presets include
|
|
97
|
+
`factory-dark`, `factory-light`, `material-baseline`, `slate`, and `olive`.
|
|
98
|
+
Presets override `--color-af-foundation-*` keys defined in the package token
|
|
99
|
+
layer.
|
|
100
|
+
|
|
101
|
+
```html
|
|
102
|
+
<html data-color-palette="factory-dark">
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
2. **Semantic role tokens** — Components consume roles such as
|
|
106
|
+
`--color-background`, `--color-surface`, `--color-primary`, and typography
|
|
107
|
+
roles from the package token CSS. Prefer these roles in custom styles
|
|
108
|
+
instead of hard-coded hex values or dashboard-only class names.
|
|
109
|
+
|
|
110
|
+
3. **Host foundation keys** — When you need a custom brand baseline, override
|
|
111
|
+
`--color-af-foundation-*` variables in your host stylesheet after importing
|
|
112
|
+
package styles. Role tokens and palette presets cascade from those keys.
|
|
113
|
+
|
|
114
|
+
The package does not require the dashboard `styles.css` or dashboard-only
|
|
115
|
+
utility sheets.
|
|
116
|
+
|
|
117
|
+
## Source-copy guidance (documentation only)
|
|
118
|
+
|
|
119
|
+
Some teams copy component source into their repository to customize markup or
|
|
120
|
+
styles while keeping the same token foundation. Supported patterns today:
|
|
121
|
+
|
|
122
|
+
1. Import `@you-agent-factory/components/styles.css` in the host app so copied
|
|
123
|
+
components receive the same tokens.
|
|
124
|
+
2. Copy the component files you need from the package category you depend on.
|
|
125
|
+
3. Keep copied code on the package side of your boundary — do not pull in
|
|
126
|
+
dashboard modules, API clients, or generated OpenAPI types.
|
|
127
|
+
|
|
128
|
+
**This README describes source-copy as guidance only.** No source-copy CLI,
|
|
129
|
+
install command, or code generator is shipped as part of this package. Any
|
|
130
|
+
copy-and-adapt workflow is manual and maintained by the host application.
|
|
131
|
+
|
|
132
|
+
## Per-component documentation
|
|
133
|
+
|
|
134
|
+
Per-component usage notes, props tables, and examples live in the package docs
|
|
135
|
+
directory:
|
|
136
|
+
|
|
137
|
+
- [`docs/`](./docs/)
|
|
138
|
+
- [Button primitives](./docs/button.md) — semantic variants, `ButtonLink`
|
|
139
|
+
guidance, loading behavior, and icon-only accessibility labels.
|
|
140
|
+
- [Typography roles](./docs/typography-roles.md) — `Text`, `Heading`, `Label`,
|
|
141
|
+
`Code`, dense text, truncation, and wrapping
|
|
142
|
+
- [Layout and display primitives](./docs/layout-display-primitives.md) —
|
|
143
|
+
`SurfacePanel`, `ActionRow`, `DescriptionList`, and responsive layout guidance
|
|
144
|
+
- [`docs/graphs.md`](./docs/graphs.md) — graph node shell, node button, edge,
|
|
145
|
+
viewport surface, handle badge, edge path helpers, React Flow boundary, and
|
|
146
|
+
Storybook example map
|
|
147
|
+
- [AlertPanel semantic feedback variants](./docs/feedback-alert-panel.md)
|
|
148
|
+
- [Skeleton loading placeholders](./docs/feedback-skeleton.md)
|
|
149
|
+
- [CodePanel long-content containment](./docs/data-display-code-panel.md)
|
|
150
|
+
- [Table primitives and DataTable](./docs/table-data-table.md)
|
|
151
|
+
- [Form input primitives](./docs/forms-input-primitives.md)
|
|
152
|
+
- [Form field structure and messaging](./docs/forms-form-field.md) — `FormField`,
|
|
153
|
+
labels, descriptions, helper text, warnings, errors, success messages,
|
|
154
|
+
grouped-control semantics, and host validation responsibilities
|
|
155
|
+
- [Form select primitives](./docs/forms-select-primitives.md) — `Select`,
|
|
156
|
+
`NativeSelect`, `EnumSelect`, keyboard behavior, and option contracts
|
|
157
|
+
- [Overlay and disclosure primitives](./docs/overlays.md)
|
|
158
|
+
- [Widget frame and layout recipes](./docs/widget-frame-recipes.md)
|
|
159
|
+
|
|
160
|
+
See that directory for component-level documentation as it is added. The docs
|
|
161
|
+
shell is plain markdown in version control; it does not require a docs-site
|
|
162
|
+
route, generated registry, or additional build-time documentation tooling.
|
|
163
|
+
|
|
164
|
+
- [Charts](./docs/charts.md) — config, presentation, tooltip and legend,
|
|
165
|
+
state panels, and caller-owned series state
|
|
166
|
+
|
|
167
|
+
## Development
|
|
168
|
+
|
|
169
|
+
From `ui/packages/components`:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
bun run typecheck
|
|
173
|
+
bun run test
|
|
174
|
+
bun run check:package-boundary
|
|
175
|
+
bun run check:package-dependency-direction
|
|
176
|
+
bun run build-storybook
|
|
177
|
+
bun run verify:storybook-browser
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Package tests use `src/testing/vitest.setup.ts` and `src/testing/render.tsx`
|
|
181
|
+
for DOM cleanup, accessible assertions, and user interactions. They do not
|
|
182
|
+
require dashboard routes, providers, generated clients, API mocks, React
|
|
183
|
+
Query, Zustand, Monaco, or Sonner.
|
|
184
|
+
|
|
185
|
+
Package Storybook lives in `.storybook/` and discovers `src/**/*.stories.tsx`
|
|
186
|
+
files. Preview decorators import the package token fixture stylesheet and
|
|
187
|
+
apply `data-color-palette` locally; they do not mount dashboard session,
|
|
188
|
+
i18n, API, React Query, Zustand, Monaco, or Sonner providers.
|
|
189
|
+
|
|
190
|
+
`check:package-boundary` scans package production source and fails when files
|
|
191
|
+
import dashboard API modules, feature modules, generated OpenAPI clients,
|
|
192
|
+
dashboard i18n providers, dashboard session providers, React Query, Zustand,
|
|
193
|
+
Monaco, or Sonner. Violations report the package file and import path.
|
|
194
|
+
|
|
195
|
+
`check:package-dependency-direction` scans package production source and fails
|
|
196
|
+
when a lower package layer imports a higher layer (for example primitives
|
|
197
|
+
importing recipes) or when production source imports testing support modules.
|
|
198
|
+
Violations report the package file, import path, and both source and target
|
|
199
|
+
layers.
|
|
200
|
+
|
|
201
|
+
From the repository root:
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
make ui-components-typecheck
|
|
205
|
+
make ui-components-test
|
|
206
|
+
make ui-components-storybook
|
|
207
|
+
make ui-components-boundary
|
|
208
|
+
make ui-components-dependency-direction
|
|
209
|
+
make ui-components-verify
|
|
210
|
+
make ui-lint
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
`make ui-components-verify` runs the full component package harness with labeled
|
|
214
|
+
failure output for typecheck, tests, Storybook build, boundary checks, and
|
|
215
|
+
dependency-direction checks. CI runs the same harness in the Build, Lint, and API
|
|
216
|
+
workflow after dashboard lint.
|
|
217
|
+
|
|
218
|
+
From the `ui` workspace root:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
make ui-lint
|
|
222
|
+
bun run check:semantic-colors
|
|
223
|
+
```
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Component package documentation
|
|
2
|
+
|
|
3
|
+
Per-component usage notes, props tables, and examples belong in this
|
|
4
|
+
directory. Add one markdown file per component (or small component group) as
|
|
5
|
+
those surfaces are documented.
|
|
6
|
+
|
|
7
|
+
## What belongs here
|
|
8
|
+
|
|
9
|
+
- Import paths and category entrypoints for a component
|
|
10
|
+
- Props, variants, and accessibility notes
|
|
11
|
+
- Short usage examples that do not depend on dashboard routes or API clients
|
|
12
|
+
|
|
13
|
+
## What does not belong here
|
|
14
|
+
|
|
15
|
+
- Dashboard-only wiring, data fetching, or business workflow guides
|
|
16
|
+
- Generated docs registries, docs-site routes, or build-time documentation
|
|
17
|
+
tooling
|
|
18
|
+
|
|
19
|
+
This docs shell is plain markdown kept under version control. Host applications
|
|
20
|
+
read it directly from the package; no docs-site implementation is required.
|
|
21
|
+
|
|
22
|
+
## Documented components
|
|
23
|
+
|
|
24
|
+
- [Button primitives](./button.md) — `Button`, `ButtonLink`, `IconButtonShell`,
|
|
25
|
+
semantic variants, loading behavior, and icon-only accessibility labels.
|
|
26
|
+
- [Typography roles](./typography-roles.md) — `Text`, `Heading`, `Label`,
|
|
27
|
+
`Code`, dense text, truncation, and wrapping
|
|
28
|
+
- [Layout and display primitives](./layout-display-primitives.md) —
|
|
29
|
+
`SurfacePanel`, `ActionRow`, `DescriptionList`, and responsive layout guidance
|
|
30
|
+
- [Form select primitives](./forms-select-primitives.md) — `Select`,
|
|
31
|
+
`NativeSelect`, `EnumSelect`, keyboard behavior, and option contracts
|
|
32
|
+
- [Form field structure and messaging](./forms-form-field.md) — `FormField`,
|
|
33
|
+
labels, descriptions, helper text, warnings, errors, success messages,
|
|
34
|
+
grouped-control semantics, and host validation responsibilities
|
|
35
|
+
- [Overlay and disclosure primitives](./overlays.md) — Dialog, Popover,
|
|
36
|
+
Collapsible, and ScrollArea accessibility, labeling, focus, and overflow
|
|
37
|
+
guidance.
|
|
38
|
+
|
|
39
|
+
## Getting started
|
|
40
|
+
|
|
41
|
+
See the package [README](../README.md) for install, CSS import setup, theming,
|
|
42
|
+
and consumer dependency boundaries. Link new component docs from that README or
|
|
43
|
+
from sibling files in this directory as the library grows.
|
|
44
|
+
|
|
45
|
+
## Component guides
|
|
46
|
+
|
|
47
|
+
- [Charts](./charts.md) — `ChartContainer`, tooltip and legend content, state
|
|
48
|
+
panels, config types, and host-owned data boundaries
|
|
49
|
+
|
|
50
|
+
## Form input primitives
|
|
51
|
+
|
|
52
|
+
- [Form input primitives](./forms-input-primitives.md) — import paths, controlled
|
|
53
|
+
versus uncontrolled usage, host accessibility responsibilities, and
|
|
54
|
+
presentation-only boundaries for text input, textarea, checkbox, and file input.
|
|
55
|
+
- [Form field structure and messaging](./forms-form-field.md) — `FormField`,
|
|
56
|
+
labels, descriptions, helper text, warnings, errors, success messages,
|
|
57
|
+
grouped-control semantics, `buildFormFieldAriaDescribedBy`, and host validation
|
|
58
|
+
responsibilities.
|
|
59
|
+
|
|
60
|
+
## Feedback and code display
|
|
61
|
+
|
|
62
|
+
- [AlertPanel](./feedback-alert-panel.md) — semantic feedback variants, token
|
|
63
|
+
mapping, accessibility, and Storybook references
|
|
64
|
+
- [Skeleton](./feedback-skeleton.md) — loading placeholders, busy regions, and
|
|
65
|
+
empty vs loading feedback
|
|
66
|
+
- [CodePanel](./data-display-code-panel.md) — long-line and long-block
|
|
67
|
+
containment, scrolling, and responsive layout expectations
|
|
68
|
+
|
|
69
|
+
## Table data display
|
|
70
|
+
|
|
71
|
+
- [Table primitives and DataTable](./table-data-table.md) — generic row contract,
|
|
72
|
+
explicit data states, density and responsive layout helpers, accessibility,
|
|
73
|
+
and Storybook references for domain-free tabular data display.
|
|
74
|
+
|
|
75
|
+
## Widget layout recipes
|
|
76
|
+
|
|
77
|
+
- [Graph primitives](./graphs.md) — `@you-agent-factory/components/graphs`
|
|
78
|
+
contracts, React Flow boundary, host responsibilities, and Storybook example
|
|
79
|
+
map
|
|
80
|
+
- [Widget frame and layout recipes](./widget-frame-recipes.md) — import paths,
|
|
81
|
+
state ownership, accessibility, Storybook references, and source-copy guidance
|
|
82
|
+
for domain-free framed panels.
|
|
83
|
+
|
package/docs/button.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Button primitives
|
|
2
|
+
|
|
3
|
+
`Button`, `ButtonLink`, and `IconButtonShell` are the reusable action primitives in
|
|
4
|
+
`@you-agent-factory/components`. They provide semantic tones, loading behavior,
|
|
5
|
+
icon-only sizing, and shared focus-visible treatment without dashboard routes,
|
|
6
|
+
providers, API clients, or generated OpenAPI types.
|
|
7
|
+
|
|
8
|
+
## Import paths
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import {
|
|
12
|
+
Button,
|
|
13
|
+
ButtonLink,
|
|
14
|
+
IconButtonShell,
|
|
15
|
+
buttonVariants,
|
|
16
|
+
type ButtonProps,
|
|
17
|
+
type ButtonLinkProps,
|
|
18
|
+
type IconButtonShellProps,
|
|
19
|
+
} from "@you-agent-factory/components";
|
|
20
|
+
|
|
21
|
+
import {
|
|
22
|
+
Button as PrimitiveButton,
|
|
23
|
+
ButtonLink as PrimitiveButtonLink,
|
|
24
|
+
IconButtonShell as PrimitiveIconButtonShell,
|
|
25
|
+
} from "@you-agent-factory/components/primitives";
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Import `@you-agent-factory/components/styles.css` once in the host application
|
|
29
|
+
before rendering buttons. See the package [README](../README.md) for CSS setup.
|
|
30
|
+
|
|
31
|
+
## Button vs ButtonLink
|
|
32
|
+
|
|
33
|
+
| Primitive | Renders | Use when |
|
|
34
|
+
| --- | --- | --- |
|
|
35
|
+
| `Button` | `<button>` (or child via `asChild`) | The action stays on the current view: submit forms, open dialogs, trigger async work, or run in-place commands. |
|
|
36
|
+
| `ButtonLink` | `<a>` styled with shared button tokens | Navigation should use a real link: route changes, external URLs, or downloads where anchor semantics and `href` behavior are required. |
|
|
37
|
+
|
|
38
|
+
`ButtonLink` does not support `loading` because anchor elements do not expose the
|
|
39
|
+
same busy/disabled interaction model as buttons. Show progress elsewhere when a
|
|
40
|
+
navigation target is not yet ready.
|
|
41
|
+
|
|
42
|
+
`Button` supports `asChild` for composition, but prefer `ButtonLink` when the
|
|
43
|
+
rendered element must be an anchor.
|
|
44
|
+
|
|
45
|
+
## Semantic button variants
|
|
46
|
+
|
|
47
|
+
Set `tone` on `Button` and `ButtonLink`, or on `IconButtonShell` for toolbar
|
|
48
|
+
actions. Variants map to semantic roles rather than dashboard feature styling.
|
|
49
|
+
|
|
50
|
+
| `tone` | Role | When to use |
|
|
51
|
+
| --- | --- | --- |
|
|
52
|
+
| `default` | Primary | The single most important action in a section or dialog footer. |
|
|
53
|
+
| `secondary` | Secondary | Supporting actions that still need button emphasis, such as "Save draft". |
|
|
54
|
+
| `outline` | Outline | Neutral actions on busy surfaces or paired secondary controls in toolbars. |
|
|
55
|
+
| `ghost` | Ghost | Low-emphasis actions on dense panels where borders would add noise. |
|
|
56
|
+
| `destructive` | Destructive | Irreversible or high-risk operations such as delete or remove. Keep the label specific; do not rely on color alone. |
|
|
57
|
+
| `warning` | Warning | Actions that need caution but are not strictly destructive, such as "Review warnings". |
|
|
58
|
+
|
|
59
|
+
`IconButtonShell` also supports `tone="dangerGhost"` for compact destructive icon
|
|
60
|
+
actions. It keeps icon-button sizing while applying destructive hover treatment.
|
|
61
|
+
|
|
62
|
+
### Sizes
|
|
63
|
+
|
|
64
|
+
`Button` and `ButtonLink` accept `size` values such as `default`, `sm`, `lg`,
|
|
65
|
+
`pill`, `icon`, and `iconPill`. `IconButtonShell` fixes toolbar-friendly
|
|
66
|
+
`h-10 w-10` icon sizing and should be used for compact icon-only controls.
|
|
67
|
+
|
|
68
|
+
## Loading buttons
|
|
69
|
+
|
|
70
|
+
Pass `loading` to `Button` (including `IconButtonShell`) when an action is in
|
|
71
|
+
progress:
|
|
72
|
+
|
|
73
|
+
- Sets `aria-busy="true"` and disables the control to prevent duplicate activation.
|
|
74
|
+
- Preserves the accessible name from visible text or `aria-label`.
|
|
75
|
+
- Renders a centered spinner overlay while keeping label content in the accessibility tree.
|
|
76
|
+
|
|
77
|
+
Do not attach separate click handlers that ignore the disabled state while
|
|
78
|
+
`loading` is true.
|
|
79
|
+
|
|
80
|
+
## Icon-only accessibility
|
|
81
|
+
|
|
82
|
+
Icon-only buttons must expose a clear accessible name:
|
|
83
|
+
|
|
84
|
+
- Prefer visible text when space allows.
|
|
85
|
+
- Otherwise provide `aria-label` with a specific action name such as
|
|
86
|
+
`"Refresh jobs"` or `"Export dashboard"`.
|
|
87
|
+
- Mark decorative icons with `aria-hidden="true"` so screen readers use the
|
|
88
|
+
button label only.
|
|
89
|
+
|
|
90
|
+
`IconButtonShell` inherits the `h-11 w-11` / toolbar touch target from the
|
|
91
|
+
shared button size tokens. Avoid shrinking icon-only controls below the package
|
|
92
|
+
defaults unless the host design system documents an exception.
|
|
93
|
+
|
|
94
|
+
## Host application responsibilities
|
|
95
|
+
|
|
96
|
+
The component package owns presentation: markup, semantic tones, focus rings,
|
|
97
|
+
loading overlays, and token-backed styling.
|
|
98
|
+
|
|
99
|
+
Host applications own:
|
|
100
|
+
|
|
101
|
+
- **Action copy** — button labels, `aria-label` text, and confirmation messaging.
|
|
102
|
+
- **Click handlers** — business logic, validation, and error handling.
|
|
103
|
+
- **Routing** — `href` values, client-side navigation, and download targets for `ButtonLink`.
|
|
104
|
+
- **Domain workflows** — when an action is enabled, loading, or destructive in product context.
|
|
105
|
+
|
|
106
|
+
Pass data and callbacks into button primitives as props. Do not expect the
|
|
107
|
+
package to read app stores, routers, or API layers.
|
|
108
|
+
|
|
109
|
+
## Storybook examples
|
|
110
|
+
|
|
111
|
+
Package Storybook stories demonstrate expected states with package imports only:
|
|
112
|
+
|
|
113
|
+
- `Primitives/Button/Semantic variants` — normal, disabled, destructive, warning,
|
|
114
|
+
and link-like examples.
|
|
115
|
+
- `Primitives/Button/Loading and icon only` — loading, focus-visible, icon-only,
|
|
116
|
+
and destructive icon shell examples.
|
|
117
|
+
|
|
118
|
+
Run `bun run storybook` from `ui/packages/components` or inspect the static
|
|
119
|
+
build with `bun run build-storybook`.
|