@tailor-platform/app-shell 1.15.0 → 1.16.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/dist/app-shell-core.css +1 -1
- package/dist/app-shell.d.ts +208 -114
- package/dist/app-shell.js +3449 -3446
- package/dist/{appshell-DLVBFo5J.js → appshell-B0wh5Lq0.js} +625 -512
- package/dist/style-entry.d.ts +116 -96
- package/dist/testing.d.ts +116 -96
- package/dist/testing.js +1 -1
- package/dist/vite-plugin.d.ts +116 -96
- package/package.json +8 -8
- package/skills/app-shell-patterns/SKILL.md +101 -14
- package/skills/app-shell-patterns/references/api/create-ai-gateway-client.md +115 -0
- package/skills/app-shell-patterns/references/api/create-typed-paths.md +117 -0
- package/skills/app-shell-patterns/references/api/define-i18n-labels.md +143 -0
- package/skills/app-shell-patterns/references/api/define-module.md +247 -0
- package/skills/app-shell-patterns/references/api/define-resource.md +307 -0
- package/skills/app-shell-patterns/references/api/guards/hidden.md +202 -0
- package/skills/app-shell-patterns/references/api/guards/overview.md +354 -0
- package/skills/app-shell-patterns/references/api/guards/pass.md +129 -0
- package/skills/app-shell-patterns/references/api/guards/redirect-to.md +307 -0
- package/skills/app-shell-patterns/references/api/router/use-location.md +240 -0
- package/skills/app-shell-patterns/references/api/router/use-navigate.md +138 -0
- package/skills/app-shell-patterns/references/api/router/use-params.md +218 -0
- package/skills/app-shell-patterns/references/api/use-ai-chat.md +110 -0
- package/skills/app-shell-patterns/references/api/use-app-shell-config.md +126 -0
- package/skills/app-shell-patterns/references/api/use-app-shell-data.md +146 -0
- package/skills/app-shell-patterns/references/api/use-app-shell.md +143 -0
- package/skills/app-shell-patterns/references/api/use-auth.md +145 -0
- package/skills/app-shell-patterns/references/api/use-override-breadcrumb.md +74 -0
- package/skills/app-shell-patterns/references/api/use-page-meta.md +96 -0
- package/skills/app-shell-patterns/references/api/use-register-command-palette-actions.md +90 -0
- package/skills/app-shell-patterns/references/api/use-resolved-locale.md +67 -0
- package/skills/app-shell-patterns/references/api/use-route-error.md +214 -0
- package/skills/app-shell-patterns/references/api/use-theme.md +108 -0
- package/skills/app-shell-patterns/references/api/use-time-zone.md +80 -0
- package/skills/app-shell-patterns/references/api/use-toast.md +107 -0
- package/skills/app-shell-patterns/references/components/action-panel.md +168 -0
- package/skills/app-shell-patterns/references/components/activity-card.md +142 -0
- package/skills/app-shell-patterns/references/components/ai-chat.md +315 -0
- package/skills/app-shell-patterns/references/components/alert.md +202 -0
- package/skills/app-shell-patterns/references/components/app-shell.md +530 -0
- package/skills/app-shell-patterns/references/components/appearance-switcher.md +87 -0
- package/skills/app-shell-patterns/references/components/attachment.md +138 -0
- package/skills/app-shell-patterns/references/components/autocomplete.md +278 -0
- package/skills/app-shell-patterns/references/components/avatar.md +80 -0
- package/skills/app-shell-patterns/references/components/badge.md +309 -0
- package/skills/app-shell-patterns/references/components/button.md +164 -0
- package/skills/app-shell-patterns/references/components/card.md +109 -0
- package/skills/app-shell-patterns/references/components/checkbox.md +169 -0
- package/skills/app-shell-patterns/references/components/combobox.md +318 -0
- package/skills/app-shell-patterns/references/components/command-palette.md +413 -0
- package/skills/app-shell-patterns/references/components/csv-importer.md +214 -0
- package/skills/app-shell-patterns/references/components/data-table.md +953 -0
- package/skills/app-shell-patterns/references/components/date-picker.md +248 -0
- package/skills/app-shell-patterns/references/components/default-header.md +75 -0
- package/skills/app-shell-patterns/references/components/default-sidebar.md +136 -0
- package/skills/app-shell-patterns/references/components/description-card.md +569 -0
- package/skills/app-shell-patterns/references/components/dialog.md +164 -0
- package/skills/app-shell-patterns/references/components/document-progress-card.md +154 -0
- package/skills/app-shell-patterns/references/components/form.md +378 -0
- package/skills/app-shell-patterns/references/components/global-header-layout.md +132 -0
- package/skills/app-shell-patterns/references/components/grid.md +184 -0
- package/skills/app-shell-patterns/references/components/input.md +83 -0
- package/skills/app-shell-patterns/references/components/layout.md +539 -0
- package/skills/app-shell-patterns/references/components/menu.md +218 -0
- package/skills/app-shell-patterns/references/components/metric-card.md +94 -0
- package/skills/app-shell-patterns/references/components/select.md +283 -0
- package/skills/app-shell-patterns/references/components/sheet.md +237 -0
- package/skills/app-shell-patterns/references/components/sidebar-group.md +466 -0
- package/skills/app-shell-patterns/references/components/sidebar-item.md +458 -0
- package/skills/app-shell-patterns/references/components/sidebar-layout.md +258 -0
- package/skills/app-shell-patterns/references/components/spinner.md +81 -0
- package/skills/app-shell-patterns/references/components/table.md +188 -0
- package/skills/app-shell-patterns/references/components/tabs.md +158 -0
- package/skills/app-shell-patterns/references/components/textarea.md +122 -0
- package/skills/app-shell-patterns/references/components/timeline.md +317 -0
- package/skills/app-shell-patterns/references/components/toolbar.md +138 -0
- package/skills/app-shell-patterns/references/components/tooltip.md +144 -0
- package/skills/app-shell-patterns/references/components/with-guard.md +445 -0
- package/skills/app-shell-patterns/references/concepts/authentication.md +301 -0
- package/skills/app-shell-patterns/references/concepts/custom-components.md +59 -0
- package/skills/app-shell-patterns/references/concepts/file-based-routing.md +350 -0
- package/skills/app-shell-patterns/references/{fundamental → concepts}/graphql.md +11 -4
- package/skills/app-shell-patterns/references/concepts/modules-and-resources.md +229 -0
- package/skills/app-shell-patterns/references/concepts/routing-navigation.md +387 -0
- package/skills/app-shell-patterns/references/concepts/sidebar-navigation.md +388 -0
- package/skills/app-shell-patterns/references/{fundamental/design-system.md → concepts/styling-theming.md} +258 -110
- package/skills/app-shell-patterns/references/migrations.md +34 -0
- package/skills/app-shell-patterns/references/pages/{detail.md → document-detail.md} +4 -27
- package/skills/app-shell-patterns/references/patterns/form-composer.md +43 -45
- package/skills/app-shell-patterns/references/patterns/form-modal.md +39 -100
- package/skills/app-shell-patterns/references/patterns/form-sectioned.md +12 -38
- package/skills/app-shell-patterns/references/patterns/form-single-page.md +11 -32
- package/skills/app-shell-patterns/references/patterns/form-wizard.md +12 -53
- package/skills/app-shell-patterns/references/patterns/interaction-confirm.md +11 -27
- package/skills/app-shell-patterns/references/patterns/interaction-multi-select.md +13 -27
- package/skills/app-shell-patterns/references/patterns/interaction-toast.md +10 -34
- package/skills/app-shell-patterns/references/patterns/list-dense-scan.md +11 -86
- package/skills/app-shell-patterns/references/fundamental/components.md +0 -1009
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Badge
|
|
3
|
+
description: Display status, labels, and tags with customizable variants
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<!-- GENERATED by docs-kit from docs-src/components/badge.docs.outline.md — do not edit by hand. -->
|
|
7
|
+
|
|
8
|
+
# Badge
|
|
9
|
+
|
|
10
|
+
The `Badge` component displays status indicators, labels, and tags with multiple style variants. It's commonly used to show document status, priority levels, or categorical information.
|
|
11
|
+
|
|
12
|
+
## Import
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import { Badge, type BadgeVariant, type BadgeOptions } from "@tailor-platform/app-shell";
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Basic Usage
|
|
19
|
+
|
|
20
|
+
<example-preview name="basic-usage"></example-preview>
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
function BasicUsage() {
|
|
24
|
+
return (
|
|
25
|
+
<div className="flex flex-wrap gap-2">
|
|
26
|
+
<Badge>Default</Badge>
|
|
27
|
+
<Badge variant="success">Success</Badge>
|
|
28
|
+
<Badge variant="warning">Warning</Badge>
|
|
29
|
+
<Badge variant="error">Error</Badge>
|
|
30
|
+
<Badge variant="info">Info</Badge>
|
|
31
|
+
<Badge variant="subtle-success">Subtle Success</Badge>
|
|
32
|
+
<Badge variant="subtle-warning">Subtle Warning</Badge>
|
|
33
|
+
<Badge variant="subtle-error">Subtle Error</Badge>
|
|
34
|
+
<Badge variant="subtle-info">Subtle Info</Badge>
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Variants
|
|
41
|
+
|
|
42
|
+
### Solid and Subtle Variants
|
|
43
|
+
|
|
44
|
+
Filled variants for high emphasis, plus subtle variants for lower-emphasis status labels:
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
<Badge variant="default">Default</Badge>
|
|
48
|
+
<Badge variant="success">Approved</Badge>
|
|
49
|
+
<Badge variant="warning">Pending</Badge>
|
|
50
|
+
<Badge variant="error">Rejected</Badge>
|
|
51
|
+
<Badge variant="neutral">Draft</Badge>
|
|
52
|
+
<Badge variant="info">New</Badge>
|
|
53
|
+
<Badge variant="subtle-success">Matched</Badge>
|
|
54
|
+
<Badge variant="subtle-warning">Needs Attention</Badge>
|
|
55
|
+
<Badge variant="subtle-error">Needs Review</Badge>
|
|
56
|
+
<Badge variant="subtle-info">In Progress</Badge>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Outline Variants with Status Dots
|
|
60
|
+
|
|
61
|
+
Outlined badges with colored status dots for subtle emphasis:
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
<Badge variant="outline-success">Active</Badge>
|
|
65
|
+
<Badge variant="outline-warning">In Progress</Badge>
|
|
66
|
+
<Badge variant="outline-error">Failed</Badge>
|
|
67
|
+
<Badge variant="outline-info">Info</Badge>
|
|
68
|
+
<Badge variant="outline-neutral">Inactive</Badge>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Props
|
|
72
|
+
|
|
73
|
+
_Generated from the type surface — first-party props only._
|
|
74
|
+
|
|
75
|
+
### BadgeProps
|
|
76
|
+
|
|
77
|
+
| Prop | Type | Default | Description |
|
|
78
|
+
| ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | -------------------- |
|
|
79
|
+
| `variant?` | `"error" \| "neutral" \| "success" \| "warning" \| "info" \| "default" \| "subtle-success" \| "subtle-warning" \| "subtle-error" \| "subtle-info" \| "outline-success" \| "outline-warning" \| "outline-error" \| "outline-info" \| "outline-neutral" \| null` | `"default"` | Visual style variant |
|
|
80
|
+
|
|
81
|
+
## Exports
|
|
82
|
+
|
|
83
|
+
- `Badge` — function
|
|
84
|
+
- `BadgeProps` — interface
|
|
85
|
+
- `badgeVariants` — const
|
|
86
|
+
|
|
87
|
+
### Badge Variants
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
type BadgeVariant =
|
|
91
|
+
// Solid/subtle variants
|
|
92
|
+
| "default" // Primary color
|
|
93
|
+
| "success" // Green
|
|
94
|
+
| "warning" // Yellow
|
|
95
|
+
| "error" // Red/destructive
|
|
96
|
+
| "neutral" // Gray/secondary
|
|
97
|
+
| "info" // Blue
|
|
98
|
+
| "subtle-success" // Low-emphasis green
|
|
99
|
+
| "subtle-warning" // Low-emphasis yellow
|
|
100
|
+
| "subtle-error" // Low-emphasis red/destructive
|
|
101
|
+
| "subtle-info" // Low-emphasis blue
|
|
102
|
+
// Outline variants with status dots
|
|
103
|
+
| "outline-success"
|
|
104
|
+
| "outline-warning"
|
|
105
|
+
| "outline-error"
|
|
106
|
+
| "outline-info"
|
|
107
|
+
| "outline-neutral";
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### BadgeOptions
|
|
111
|
+
|
|
112
|
+
Shared options used by `DataTable` and `DescriptionCard` badge fields:
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
interface BadgeOptions {
|
|
116
|
+
/** Maps each value (stringified) to a Badge variant. Unmapped values use `defaultBadgeVariant`. */
|
|
117
|
+
badgeVariantMap?: Record<string, BadgeVariant>;
|
|
118
|
+
/** Maps each value (stringified) to a display label. Unmapped values render the raw value. */
|
|
119
|
+
badgeLabelMap?: Record<string, string>;
|
|
120
|
+
/** Variant used when the value is not in `badgeVariantMap`. Default: `"outline-neutral"`. */
|
|
121
|
+
defaultBadgeVariant?: BadgeVariant;
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Examples
|
|
126
|
+
|
|
127
|
+
### Order Status
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
function OrderStatus({ status }: { status: string }) {
|
|
131
|
+
const variantMap: Record<string, BadgeVariant> = {
|
|
132
|
+
pending: "outline-warning",
|
|
133
|
+
processing: "outline-info",
|
|
134
|
+
shipped: "outline-success",
|
|
135
|
+
delivered: "success",
|
|
136
|
+
cancelled: "outline-error",
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
return <Badge variant={variantMap[status] || "neutral"}>{status.toUpperCase()}</Badge>;
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Priority Badges
|
|
144
|
+
|
|
145
|
+
```tsx
|
|
146
|
+
const priorities = [
|
|
147
|
+
{ label: "Low", variant: "outline-neutral" },
|
|
148
|
+
{ label: "Medium", variant: "outline-info" },
|
|
149
|
+
{ label: "High", variant: "outline-warning" },
|
|
150
|
+
{ label: "Critical", variant = "error" },
|
|
151
|
+
];
|
|
152
|
+
|
|
153
|
+
<div className="flex gap-2">
|
|
154
|
+
{priorities.map((p) => (
|
|
155
|
+
<Badge key={p.label} variant={p.variant}>
|
|
156
|
+
{p.label}
|
|
157
|
+
</Badge>
|
|
158
|
+
))}
|
|
159
|
+
</div>;
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### With Icons
|
|
163
|
+
|
|
164
|
+
```tsx
|
|
165
|
+
import { CheckCircle, AlertCircle, XCircle } from "lucide-react";
|
|
166
|
+
|
|
167
|
+
<div className="flex gap-2">
|
|
168
|
+
<Badge variant="success">
|
|
169
|
+
<CheckCircle className="w-3 h-3 mr-1" />
|
|
170
|
+
Verified
|
|
171
|
+
</Badge>
|
|
172
|
+
<Badge variant="warning">
|
|
173
|
+
<AlertCircle className="w-3 h-3 mr-1" />
|
|
174
|
+
Review
|
|
175
|
+
</Badge>
|
|
176
|
+
<Badge variant="error">
|
|
177
|
+
<XCircle className="w-3 h-3 mr-1" />
|
|
178
|
+
Blocked
|
|
179
|
+
</Badge>
|
|
180
|
+
</div>;
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Dynamic Variant Selection
|
|
184
|
+
|
|
185
|
+
```tsx
|
|
186
|
+
interface Product {
|
|
187
|
+
name: string;
|
|
188
|
+
stock: number;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function ProductBadge({ product }: { product: Product }) {
|
|
192
|
+
// Determine variant based on stock level
|
|
193
|
+
let variant: BadgeVariant = "success";
|
|
194
|
+
if (product.stock === 0) {
|
|
195
|
+
variant = "error";
|
|
196
|
+
} else if (product.stock < 10) {
|
|
197
|
+
variant = "warning";
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return <Badge variant={variant}>{product.stock} in stock</Badge>;
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Custom Styling
|
|
205
|
+
|
|
206
|
+
```tsx
|
|
207
|
+
<Badge variant="success" className="uppercase">
|
|
208
|
+
Premium
|
|
209
|
+
</Badge>
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Visual Reference
|
|
213
|
+
|
|
214
|
+
### Solid and Subtle Variants
|
|
215
|
+
|
|
216
|
+
| Variant | Preview | Use Case |
|
|
217
|
+
| ---------------- | ---------------------- | ------------------------------------------ |
|
|
218
|
+
| `default` | ![Blue badge] | Primary actions, default status |
|
|
219
|
+
| `success` | ![Green badge] | Completed, approved, active |
|
|
220
|
+
| `warning` | ![Yellow badge] | Pending, in progress, attention needed |
|
|
221
|
+
| `error` | ![Red badge] | Failed, rejected, critical |
|
|
222
|
+
| `neutral` | ![Gray badge] | Draft, inactive, disabled |
|
|
223
|
+
| `info` | ![Blue badge] | Informational, new, in-progress |
|
|
224
|
+
| `subtle-success` | ![Subtle green badge] | Low-emphasis completed or matched statuses |
|
|
225
|
+
| `subtle-warning` | ![Subtle yellow badge] | Low-emphasis pending or attention states |
|
|
226
|
+
| `subtle-error` | ![Subtle red badge] | Low-emphasis failures or exceptions |
|
|
227
|
+
| `subtle-info` | ![Subtle blue badge] | Low-emphasis informational or in-progress |
|
|
228
|
+
|
|
229
|
+
### Outline Variants
|
|
230
|
+
|
|
231
|
+
| Variant | Preview | Use Case |
|
|
232
|
+
| ----------------- | ----------------------- | -------------------------- |
|
|
233
|
+
| `outline-success` | ![Green dot + outline] | Active, available, healthy |
|
|
234
|
+
| `outline-warning` | ![Orange dot + outline] | In progress, scheduled |
|
|
235
|
+
| `outline-error` | ![Red dot + outline] | Error, unavailable, down |
|
|
236
|
+
| `outline-info` | ![Blue dot + outline] | Information, processing |
|
|
237
|
+
| `outline-neutral` | ![Gray dot + outline] | Neutral state, inactive |
|
|
238
|
+
|
|
239
|
+
## Accessibility
|
|
240
|
+
|
|
241
|
+
- Use semantic color meanings consistently (green = success, red = error, etc.)
|
|
242
|
+
- Don't rely solely on color to convey information
|
|
243
|
+
- Consider adding icons or text labels for clarity
|
|
244
|
+
- Badges are non-interactive: they render with the default cursor (not a pointer) and won't suggest clickability, even when placed inside a clickable container such as a `DataTable` row with `onClickRow`
|
|
245
|
+
|
|
246
|
+
## Usage in DescriptionCard
|
|
247
|
+
|
|
248
|
+
Badges can be used with DescriptionCard for automatic status rendering:
|
|
249
|
+
|
|
250
|
+
```tsx
|
|
251
|
+
import { DescriptionCard } from "@tailor-platform/app-shell";
|
|
252
|
+
|
|
253
|
+
<DescriptionCard
|
|
254
|
+
data={orderData}
|
|
255
|
+
fields={[
|
|
256
|
+
{
|
|
257
|
+
type: "badge",
|
|
258
|
+
key: "status",
|
|
259
|
+
label: "Status",
|
|
260
|
+
meta: {
|
|
261
|
+
sentenceCaseBadges: false,
|
|
262
|
+
badgeVariantMap: {
|
|
263
|
+
pending: "outline-warning",
|
|
264
|
+
shipped: "outline-success",
|
|
265
|
+
delivered: "success",
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
},
|
|
269
|
+
]}
|
|
270
|
+
/>;
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
[Learn more about DescriptionCard →](./description-card.md)
|
|
274
|
+
|
|
275
|
+
## Best Practices
|
|
276
|
+
|
|
277
|
+
### Do:
|
|
278
|
+
|
|
279
|
+
- ✅ Use consistent variants for the same meaning across your app
|
|
280
|
+
- ✅ Keep badge text short (1-2 words)
|
|
281
|
+
- ✅ Use outline variants for subtle emphasis
|
|
282
|
+
- ✅ Use solid variants for important status indicators
|
|
283
|
+
|
|
284
|
+
### Don't:
|
|
285
|
+
|
|
286
|
+
- ❌ Use too many different badge colors (stick to semantic colors)
|
|
287
|
+
- ❌ Put long text in badges (use tooltips instead)
|
|
288
|
+
- ❌ Make badges clickable without visual indication
|
|
289
|
+
- ❌ Use badges for navigation (use links or buttons instead)
|
|
290
|
+
|
|
291
|
+
## Related Components
|
|
292
|
+
|
|
293
|
+
- [DescriptionCard](./description-card.md) - Use badges in structured displays
|
|
294
|
+
- [Layout](./layout.md) - Organize badges in layouts
|
|
295
|
+
|
|
296
|
+
## Styling
|
|
297
|
+
|
|
298
|
+
Badges are styled with the library's internal `astw:`-prefixed utilities. Write **plain** Tailwind utilities in your own markup, and reach for `variant` rather than restyling what `Badge` sets itself — see [Styling AppShell components](../concepts/styling-theming.md#styling-appshell-components). Customize appearance by:
|
|
299
|
+
|
|
300
|
+
1. **Using className prop** for additional styles
|
|
301
|
+
2. **Overriding CSS variables** in your theme
|
|
302
|
+
3. **Creating custom variants** using the `badgeVariants` utility
|
|
303
|
+
|
|
304
|
+
```tsx
|
|
305
|
+
import { badgeVariants } from "@tailor-platform/app-shell";
|
|
306
|
+
import { cn } from "@/lib/utils";
|
|
307
|
+
|
|
308
|
+
<div className={cn(badgeVariants({ variant: "success" }), "mt-2")}>Custom Badge</div>;
|
|
309
|
+
```
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Button
|
|
3
|
+
description: Styled button with multiple variants and sizes
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<!-- GENERATED by docs-kit from docs-src/components/button.docs.outline.md — do not edit by hand. -->
|
|
7
|
+
|
|
8
|
+
# Button
|
|
9
|
+
|
|
10
|
+
The `Button` component is a styled button with multiple visual variants and sizes. It supports rendering as a custom element via the `render` prop (Base UI render pattern).
|
|
11
|
+
|
|
12
|
+
## Import
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import { Button } from "@tailor-platform/app-shell";
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Basic Usage
|
|
19
|
+
|
|
20
|
+
<example-preview name="basic-usage"></example-preview>
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
function BasicUsage() {
|
|
24
|
+
return (
|
|
25
|
+
<div className="flex gap-2">
|
|
26
|
+
<Button>Click me</Button>
|
|
27
|
+
<Button variant="outline">Outline</Button>
|
|
28
|
+
<Button variant="destructive">Delete</Button>
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Props
|
|
35
|
+
|
|
36
|
+
_Generated from the type surface — first-party props only._
|
|
37
|
+
|
|
38
|
+
### ButtonProps
|
|
39
|
+
|
|
40
|
+
| Prop | Type | Default | Description |
|
|
41
|
+
| ---------- | ------------------------------------------------------------------------------------- | ----------- | ------------------------------------------------- |
|
|
42
|
+
| `render?` | `React.ReactElement` | - | Custom element to render as (Base UI render prop) |
|
|
43
|
+
| `size?` | `"default" \| "sm" \| "lg" \| "xs" \| "icon" \| null` | `"default"` | Button size |
|
|
44
|
+
| `variant?` | `"link" \| "default" \| "destructive" \| "outline" \| "secondary" \| "ghost" \| null` | `"default"` | Visual style variant |
|
|
45
|
+
|
|
46
|
+
## Exports
|
|
47
|
+
|
|
48
|
+
- `Button` — function
|
|
49
|
+
- `ButtonProps` — type
|
|
50
|
+
- `buttonVariants` — const
|
|
51
|
+
|
|
52
|
+
All standard HTML `<button>` props are also accepted.
|
|
53
|
+
|
|
54
|
+
## Variants
|
|
55
|
+
|
|
56
|
+
<example-preview name="variants"></example-preview>
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
function Variants() {
|
|
60
|
+
return (
|
|
61
|
+
<div className="flex flex-wrap gap-2">
|
|
62
|
+
<Button variant="default">Primary Action</Button>
|
|
63
|
+
<Button variant="destructive">Delete</Button>
|
|
64
|
+
<Button variant="outline">Secondary Action</Button>
|
|
65
|
+
<Button variant="secondary">Tertiary</Button>
|
|
66
|
+
<Button variant="ghost">Ghost</Button>
|
|
67
|
+
<Button variant="link">Link Style</Button>
|
|
68
|
+
</div>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Sizes
|
|
74
|
+
|
|
75
|
+
<example-preview name="sizes"></example-preview>
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
function Sizes() {
|
|
79
|
+
return (
|
|
80
|
+
<div className="flex items-center gap-2">
|
|
81
|
+
<Button size="xs">Extra Small</Button>
|
|
82
|
+
<Button size="sm">Small</Button>
|
|
83
|
+
<Button size="default">Default</Button>
|
|
84
|
+
<Button size="lg">Large</Button>
|
|
85
|
+
<Button size="icon">
|
|
86
|
+
<PlusIcon />
|
|
87
|
+
</Button>
|
|
88
|
+
</div>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Render Prop
|
|
94
|
+
|
|
95
|
+
The `render` prop lets you use the button's styles on a custom element:
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
import { Button } from "@tailor-platform/app-shell";
|
|
99
|
+
import { Link } from "@tailor-platform/app-shell";
|
|
100
|
+
|
|
101
|
+
<Button render={<Link to="/orders" />} variant="outline">
|
|
102
|
+
View Orders
|
|
103
|
+
</Button>;
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
This is the Base UI render pattern — the button's class names and event handlers are applied to the rendered element.
|
|
107
|
+
|
|
108
|
+
## Examples
|
|
109
|
+
|
|
110
|
+
### Form Actions
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
<div className="flex gap-2 justify-end">
|
|
114
|
+
<Button variant="outline">Cancel</Button>
|
|
115
|
+
<Button>Save Changes</Button>
|
|
116
|
+
</div>
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Destructive Confirmation
|
|
120
|
+
|
|
121
|
+
```tsx
|
|
122
|
+
<Button variant="destructive" onClick={handleDelete}>
|
|
123
|
+
Delete Order
|
|
124
|
+
</Button>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Icon Button
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
import { PlusIcon } from "lucide-react";
|
|
131
|
+
|
|
132
|
+
<Button size="icon" variant="outline">
|
|
133
|
+
<PlusIcon />
|
|
134
|
+
</Button>;
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## TypeScript
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
import { type ButtonProps } from "@tailor-platform/app-shell";
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Styling
|
|
144
|
+
|
|
145
|
+
Use `buttonVariants` to apply button styles to non-button elements:
|
|
146
|
+
|
|
147
|
+
```tsx
|
|
148
|
+
import { buttonVariants } from "@tailor-platform/app-shell";
|
|
149
|
+
|
|
150
|
+
<a href="/orders" className={buttonVariants({ variant: "outline", size: "sm" })}>
|
|
151
|
+
View Orders
|
|
152
|
+
</a>;
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Accessibility
|
|
156
|
+
|
|
157
|
+
- Buttons render with `cursor: pointer` to signal interactivity consistently across all variants and sizes.
|
|
158
|
+
- Disabled buttons suppress the pointer cursor via `pointer-events-none`, so they do not signal clickability.
|
|
159
|
+
|
|
160
|
+
## Related Components
|
|
161
|
+
|
|
162
|
+
- [Dialog](./dialog.md) - Use buttons as dialog triggers and actions
|
|
163
|
+
- [Sheet](./sheet.md) - Use buttons as sheet triggers
|
|
164
|
+
- [Layout](./layout.md) - Use buttons in page header actions
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Card
|
|
3
|
+
description: General-purpose container with consistent styling using a compound component API
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<!-- GENERATED by docs-kit from docs-src/components/card.docs.outline.md — do not edit by hand. -->
|
|
7
|
+
|
|
8
|
+
# Card
|
|
9
|
+
|
|
10
|
+
`Card` is a general-purpose container component with a compound component API (`Card.Root`, `Card.Header`, `Card.Content`). It provides consistent surface styling (background, border, border-radius, shadow) for grouping related content.
|
|
11
|
+
|
|
12
|
+
## Import
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import { Card } from "@tailor-platform/app-shell";
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Basic Usage
|
|
19
|
+
|
|
20
|
+
<example-preview name="basic-usage"></example-preview>
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
function BasicUsage() {
|
|
24
|
+
return (
|
|
25
|
+
<Card.Root>
|
|
26
|
+
<Card.Header title="Order Details" description="Summary of order #1234" />
|
|
27
|
+
<Card.Content>
|
|
28
|
+
<p>Content goes here</p>
|
|
29
|
+
</Card.Content>
|
|
30
|
+
</Card.Root>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Parts
|
|
36
|
+
|
|
37
|
+
| Part | Description |
|
|
38
|
+
| -------------- | ---------------------------------------------------------------- |
|
|
39
|
+
| `Card.Root` | Outer container. Renders a `<div>` with surface styling applied. |
|
|
40
|
+
| `Card.Header` | Top section with an optional title and description. |
|
|
41
|
+
| `Card.Content` | Body section with consistent horizontal and bottom padding. |
|
|
42
|
+
|
|
43
|
+
## Card.Root Props
|
|
44
|
+
|
|
45
|
+
`Card.Root` accepts all standard HTML `<div>` props.
|
|
46
|
+
|
|
47
|
+
| Prop | Type | Default | Description |
|
|
48
|
+
| ----------- | ----------------- | ------- | ---------------------- |
|
|
49
|
+
| `className` | `string` | - | Additional CSS classes |
|
|
50
|
+
| `children` | `React.ReactNode` | - | Card parts and content |
|
|
51
|
+
|
|
52
|
+
## Card.Header Props
|
|
53
|
+
|
|
54
|
+
| Prop | Type | Default | Description |
|
|
55
|
+
| ------------- | ----------------- | ------- | ----------------------------------------------------------- |
|
|
56
|
+
| `title` | `React.ReactNode` | - | Card title rendered in a `<h3>`. |
|
|
57
|
+
| `description` | `React.ReactNode` | - | Supplementary text rendered below the title. |
|
|
58
|
+
| `children` | `React.ReactNode` | - | Additional header content rendered after title/description. |
|
|
59
|
+
| `className` | `string` | - | Additional CSS classes. |
|
|
60
|
+
|
|
61
|
+
## Card.Content Props
|
|
62
|
+
|
|
63
|
+
`Card.Content` accepts all standard HTML `<div>` props.
|
|
64
|
+
|
|
65
|
+
| Prop | Type | Default | Description |
|
|
66
|
+
| ----------- | ----------------- | ------- | ---------------------- |
|
|
67
|
+
| `className` | `string` | - | Additional CSS classes |
|
|
68
|
+
| `children` | `React.ReactNode` | - | Card body content |
|
|
69
|
+
|
|
70
|
+
## Examples
|
|
71
|
+
|
|
72
|
+
### Header only
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
<Card.Root>
|
|
76
|
+
<Card.Header title="Summary" description="Key metrics for this period" />
|
|
77
|
+
</Card.Root>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Content only
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
<Card.Root>
|
|
84
|
+
<Card.Content>
|
|
85
|
+
<p>No header needed for this card.</p>
|
|
86
|
+
</Card.Content>
|
|
87
|
+
</Card.Root>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Custom header content
|
|
91
|
+
|
|
92
|
+
```tsx
|
|
93
|
+
<Card.Root>
|
|
94
|
+
<Card.Header title="Recent Orders">
|
|
95
|
+
<Button size="sm" variant="outline">
|
|
96
|
+
View all
|
|
97
|
+
</Button>
|
|
98
|
+
</Card.Header>
|
|
99
|
+
<Card.Content>
|
|
100
|
+
<Table>{/* ... */}</Table>
|
|
101
|
+
</Card.Content>
|
|
102
|
+
</Card.Root>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Related
|
|
106
|
+
|
|
107
|
+
- [MetricCard](./metric-card.md) — Card variant for KPI / dashboard metric display.
|
|
108
|
+
- [DescriptionCard](./description-card.md) — Card variant for structured key-value data.
|
|
109
|
+
- [ActivityCard](./activity-card.md) — Card variant for timeline activity feeds.
|