@neynar/ui 1.0.1 → 1.0.3
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/context7.json +17 -0
- package/llm/components/accordion.llm.md +205 -0
- package/llm/components/alert-dialog.llm.md +289 -0
- package/llm/components/alert.llm.md +310 -0
- package/llm/components/aspect-ratio.llm.md +110 -0
- package/llm/components/avatar.llm.md +282 -0
- package/llm/components/badge.llm.md +185 -0
- package/llm/components/blockquote.llm.md +86 -0
- package/llm/components/breadcrumb.llm.md +245 -0
- package/llm/components/button-group.llm.md +248 -0
- package/llm/components/button.llm.md +247 -0
- package/llm/components/calendar.llm.md +252 -0
- package/llm/components/card.llm.md +356 -0
- package/llm/components/carousel.llm.md +281 -0
- package/llm/components/chart.llm.md +278 -0
- package/llm/components/checkbox.llm.md +234 -0
- package/llm/components/code.llm.md +75 -0
- package/llm/components/collapsible.llm.md +271 -0
- package/llm/components/color-mode.llm.md +196 -0
- package/llm/components/combobox.llm.md +346 -0
- package/llm/components/command.llm.md +353 -0
- package/llm/components/context-menu.llm.md +368 -0
- package/llm/components/dialog.llm.md +283 -0
- package/llm/components/drawer.llm.md +326 -0
- package/llm/components/dropdown-menu.llm.md +404 -0
- package/llm/components/empty.llm.md +282 -0
- package/llm/components/field.llm.md +303 -0
- package/llm/components/first-light.llm.md +129 -0
- package/llm/components/hover-card.llm.md +278 -0
- package/llm/components/input-group.llm.md +334 -0
- package/llm/components/input-otp.llm.md +270 -0
- package/llm/components/input.llm.md +197 -0
- package/llm/components/item.llm.md +347 -0
- package/llm/components/kbd.llm.md +221 -0
- package/llm/components/label.llm.md +219 -0
- package/llm/components/menubar.llm.md +378 -0
- package/llm/components/navigation-menu.llm.md +320 -0
- package/llm/components/pagination.llm.md +337 -0
- package/llm/components/popover.llm.md +278 -0
- package/llm/components/progress.llm.md +259 -0
- package/llm/components/radio-group.llm.md +269 -0
- package/llm/components/resizable.llm.md +222 -0
- package/llm/components/scroll-area.llm.md +290 -0
- package/llm/components/select.llm.md +338 -0
- package/llm/components/separator.llm.md +129 -0
- package/llm/components/sheet.llm.md +275 -0
- package/llm/components/sidebar.llm.md +528 -0
- package/llm/components/skeleton.llm.md +140 -0
- package/llm/components/slider.llm.md +213 -0
- package/llm/components/sonner.llm.md +299 -0
- package/llm/components/spinner.llm.md +187 -0
- package/llm/components/switch.llm.md +258 -0
- package/llm/components/table.llm.md +334 -0
- package/llm/components/tabs.llm.md +245 -0
- package/llm/components/text.llm.md +108 -0
- package/llm/components/textarea.llm.md +236 -0
- package/llm/components/title.llm.md +88 -0
- package/llm/components/toggle-group.llm.md +228 -0
- package/llm/components/toggle.llm.md +235 -0
- package/llm/components/tooltip.llm.md +191 -0
- package/llm/contributing.llm.md +273 -0
- package/llm/hooks.llm.md +91 -0
- package/llm/index.llm.md +178 -0
- package/llm/theming.llm.md +381 -0
- package/llm/utilities.llm.md +97 -0
- package/llms-full.txt +15995 -0
- package/llms.txt +182 -0
- package/package.json +5 -1
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
# Switch
|
|
2
|
+
|
|
3
|
+
Toggle switch for binary on/off settings with keyboard support and form integration.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Switch } from "@neynar/ui/switch"
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Anatomy
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
<Switch />
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The Switch component is a single component that internally uses `Switch.Root` and `Switch.Thumb` from Base UI.
|
|
18
|
+
|
|
19
|
+
## Props
|
|
20
|
+
|
|
21
|
+
### Switch
|
|
22
|
+
|
|
23
|
+
Extends all props from `Switch.Root.Props` from `@base-ui/react/switch`.
|
|
24
|
+
|
|
25
|
+
| Prop | Type | Default | Description |
|
|
26
|
+
|------|------|---------|-------------|
|
|
27
|
+
| size | "sm" \| "default" | "default" | Size variant of the switch |
|
|
28
|
+
| checked | boolean | - | Controlled checked state |
|
|
29
|
+
| defaultChecked | boolean | false | Initial checked state (uncontrolled) |
|
|
30
|
+
| onCheckedChange | (checked: boolean, eventDetails) => void | - | Called when checked state changes |
|
|
31
|
+
| disabled | boolean | false | Disables interaction |
|
|
32
|
+
| readOnly | boolean | false | Prevents state changes but allows focus |
|
|
33
|
+
| required | boolean | false | Marks as required for form validation |
|
|
34
|
+
| name | string | - | Form field name |
|
|
35
|
+
| id | string | - | Element id for label association |
|
|
36
|
+
| aria-invalid | boolean | - | Shows error styling for validation |
|
|
37
|
+
| className | string | - | Additional CSS classes |
|
|
38
|
+
|
|
39
|
+
## Sizes
|
|
40
|
+
|
|
41
|
+
| Size | Dimensions | Use Case |
|
|
42
|
+
|------|------------|----------|
|
|
43
|
+
| sm | 14px × 24px | Compact layouts, dense settings panels |
|
|
44
|
+
| default | 18.4px × 32px | Standard size for most use cases |
|
|
45
|
+
|
|
46
|
+
## Data Attributes
|
|
47
|
+
|
|
48
|
+
The following data attributes are automatically applied for styling:
|
|
49
|
+
|
|
50
|
+
| Attribute | When Present |
|
|
51
|
+
|-----------|--------------|
|
|
52
|
+
| data-checked | Switch is on |
|
|
53
|
+
| data-unchecked | Switch is off |
|
|
54
|
+
| data-disabled | Switch is disabled |
|
|
55
|
+
| data-size="sm" \| "default" | Current size variant |
|
|
56
|
+
|
|
57
|
+
## Examples
|
|
58
|
+
|
|
59
|
+
### Basic Usage
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
import { Switch } from "@neynar/ui/switch"
|
|
63
|
+
import { Label } from "@neynar/ui/label"
|
|
64
|
+
|
|
65
|
+
function Example() {
|
|
66
|
+
return (
|
|
67
|
+
<div className="flex items-center gap-3">
|
|
68
|
+
<Switch id="notifications" />
|
|
69
|
+
<Label htmlFor="notifications">Enable notifications</Label>
|
|
70
|
+
</div>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Controlled State
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
import { useState } from "react"
|
|
79
|
+
import { Switch } from "@neynar/ui/switch"
|
|
80
|
+
import { Label } from "@neynar/ui/label"
|
|
81
|
+
|
|
82
|
+
function ControlledExample() {
|
|
83
|
+
const [enabled, setEnabled] = useState(false)
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<div className="space-y-2">
|
|
87
|
+
<div className="flex items-center gap-3">
|
|
88
|
+
<Switch
|
|
89
|
+
id="webhooks"
|
|
90
|
+
checked={enabled}
|
|
91
|
+
onCheckedChange={setEnabled}
|
|
92
|
+
/>
|
|
93
|
+
<Label htmlFor="webhooks">Enable webhooks</Label>
|
|
94
|
+
</div>
|
|
95
|
+
<p className="text-sm text-muted-foreground">
|
|
96
|
+
Status: {enabled ? "Enabled" : "Disabled"}
|
|
97
|
+
</p>
|
|
98
|
+
</div>
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Settings Panel
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
import { Switch } from "@neynar/ui/switch"
|
|
107
|
+
import { Label } from "@neynar/ui/label"
|
|
108
|
+
|
|
109
|
+
function SettingsPanel() {
|
|
110
|
+
return (
|
|
111
|
+
<div className="border-border divide-border divide-y rounded-lg border">
|
|
112
|
+
<div className="flex items-center justify-between p-4">
|
|
113
|
+
<div className="space-y-0.5">
|
|
114
|
+
<Label htmlFor="email" className="text-sm font-medium">
|
|
115
|
+
Email Notifications
|
|
116
|
+
</Label>
|
|
117
|
+
<p className="text-muted-foreground text-xs">
|
|
118
|
+
Receive alerts about important updates
|
|
119
|
+
</p>
|
|
120
|
+
</div>
|
|
121
|
+
<Switch id="email" size="sm" defaultChecked />
|
|
122
|
+
</div>
|
|
123
|
+
<div className="flex items-center justify-between p-4">
|
|
124
|
+
<div className="space-y-0.5">
|
|
125
|
+
<Label htmlFor="marketing" className="text-sm font-medium">
|
|
126
|
+
Marketing Emails
|
|
127
|
+
</Label>
|
|
128
|
+
<p className="text-muted-foreground text-xs">
|
|
129
|
+
Product updates and announcements
|
|
130
|
+
</p>
|
|
131
|
+
</div>
|
|
132
|
+
<Switch id="marketing" size="sm" />
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Form Integration
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
import { Switch } from "@neynar/ui/switch"
|
|
143
|
+
import { Label } from "@neynar/ui/label"
|
|
144
|
+
|
|
145
|
+
function FormExample() {
|
|
146
|
+
return (
|
|
147
|
+
<form>
|
|
148
|
+
<div className="space-y-4">
|
|
149
|
+
<div className="flex items-center justify-between">
|
|
150
|
+
<Label htmlFor="terms" className="text-sm">
|
|
151
|
+
I agree to the terms and conditions
|
|
152
|
+
</Label>
|
|
153
|
+
<Switch id="terms" name="terms" required />
|
|
154
|
+
</div>
|
|
155
|
+
<button type="submit">Submit</button>
|
|
156
|
+
</div>
|
|
157
|
+
</form>
|
|
158
|
+
)
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### With Disabled State
|
|
163
|
+
|
|
164
|
+
```tsx
|
|
165
|
+
import { Switch } from "@neynar/ui/switch"
|
|
166
|
+
import { Label } from "@neynar/ui/label"
|
|
167
|
+
|
|
168
|
+
function DisabledExample() {
|
|
169
|
+
const [parentEnabled, setParentEnabled] = useState(false)
|
|
170
|
+
|
|
171
|
+
return (
|
|
172
|
+
<div className="space-y-4">
|
|
173
|
+
<div className="flex items-center justify-between">
|
|
174
|
+
<Label htmlFor="main">Enable Feature</Label>
|
|
175
|
+
<Switch
|
|
176
|
+
id="main"
|
|
177
|
+
checked={parentEnabled}
|
|
178
|
+
onCheckedChange={setParentEnabled}
|
|
179
|
+
/>
|
|
180
|
+
</div>
|
|
181
|
+
<div className="flex items-center justify-between">
|
|
182
|
+
<Label htmlFor="sub" className="text-muted-foreground">
|
|
183
|
+
Sub-option (requires feature)
|
|
184
|
+
</Label>
|
|
185
|
+
<Switch
|
|
186
|
+
id="sub"
|
|
187
|
+
size="sm"
|
|
188
|
+
disabled={!parentEnabled}
|
|
189
|
+
defaultChecked
|
|
190
|
+
/>
|
|
191
|
+
</div>
|
|
192
|
+
</div>
|
|
193
|
+
)
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Invalid State
|
|
198
|
+
|
|
199
|
+
```tsx
|
|
200
|
+
import { Switch } from "@neynar/ui/switch"
|
|
201
|
+
import { Label } from "@neynar/ui/label"
|
|
202
|
+
|
|
203
|
+
function ValidationExample() {
|
|
204
|
+
const [agreed, setAgreed] = useState(false)
|
|
205
|
+
const [submitted, setSubmitted] = useState(false)
|
|
206
|
+
|
|
207
|
+
const isInvalid = submitted && !agreed
|
|
208
|
+
|
|
209
|
+
return (
|
|
210
|
+
<div className="space-y-2">
|
|
211
|
+
<div className="flex items-center justify-between">
|
|
212
|
+
<Label htmlFor="required">Accept terms (required)</Label>
|
|
213
|
+
<Switch
|
|
214
|
+
id="required"
|
|
215
|
+
checked={agreed}
|
|
216
|
+
onCheckedChange={setAgreed}
|
|
217
|
+
aria-invalid={isInvalid}
|
|
218
|
+
/>
|
|
219
|
+
</div>
|
|
220
|
+
{isInvalid && (
|
|
221
|
+
<p className="text-destructive text-sm">
|
|
222
|
+
You must accept the terms to continue
|
|
223
|
+
</p>
|
|
224
|
+
)}
|
|
225
|
+
<button onClick={() => setSubmitted(true)}>Submit</button>
|
|
226
|
+
</div>
|
|
227
|
+
)
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## Keyboard Interaction
|
|
232
|
+
|
|
233
|
+
| Key | Action |
|
|
234
|
+
|-----|--------|
|
|
235
|
+
| Space | Toggle checked state |
|
|
236
|
+
| Enter | Toggle checked state |
|
|
237
|
+
| Tab | Move focus to/from switch |
|
|
238
|
+
|
|
239
|
+
## Accessibility
|
|
240
|
+
|
|
241
|
+
- Renders a native `<input type="checkbox">` for form integration and screen readers
|
|
242
|
+
- Supports `aria-invalid` for validation error states
|
|
243
|
+
- Automatically manages focus states with visible focus ring
|
|
244
|
+
- Works with `<Label>` via `htmlFor` prop for clickable labels
|
|
245
|
+
- Disabled switches are properly announced and non-interactive
|
|
246
|
+
|
|
247
|
+
## Styling Notes
|
|
248
|
+
|
|
249
|
+
- Use `aria-invalid` prop to show error state (red border and ring)
|
|
250
|
+
- The switch has an extended click area (`after:absolute after:-inset-x-3 after:-inset-y-2`) for easier interaction
|
|
251
|
+
- Dark mode automatically adjusts colors for unchecked state background
|
|
252
|
+
- Focus ring uses `ring-ring/50` with 3px width for accessibility
|
|
253
|
+
|
|
254
|
+
## Related
|
|
255
|
+
|
|
256
|
+
- [Label](./label.llm.md) - Associate labels with switches
|
|
257
|
+
- [Checkbox](./checkbox.llm.md) - Alternative for yes/no choices
|
|
258
|
+
- [RadioGroup](./radio-group.llm.md) - Multiple exclusive options
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
# Table
|
|
2
|
+
|
|
3
|
+
Compound component for displaying tabular data with semantic HTML table structure and automatic responsive scrolling.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import {
|
|
9
|
+
Table,
|
|
10
|
+
TableHeader,
|
|
11
|
+
TableBody,
|
|
12
|
+
TableFooter,
|
|
13
|
+
TableHead,
|
|
14
|
+
TableRow,
|
|
15
|
+
TableCell,
|
|
16
|
+
TableCaption,
|
|
17
|
+
} from "@neynar/ui/table"
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Anatomy
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
<Table>
|
|
24
|
+
<TableCaption>Optional description</TableCaption>
|
|
25
|
+
<TableHeader>
|
|
26
|
+
<TableRow>
|
|
27
|
+
<TableHead>Column 1</TableHead>
|
|
28
|
+
<TableHead>Column 2</TableHead>
|
|
29
|
+
</TableRow>
|
|
30
|
+
</TableHeader>
|
|
31
|
+
<TableBody>
|
|
32
|
+
<TableRow>
|
|
33
|
+
<TableCell>Data 1</TableCell>
|
|
34
|
+
<TableCell>Data 2</TableCell>
|
|
35
|
+
</TableRow>
|
|
36
|
+
</TableBody>
|
|
37
|
+
<TableFooter>
|
|
38
|
+
<TableRow>
|
|
39
|
+
<TableCell colSpan={2}>Summary</TableCell>
|
|
40
|
+
</TableRow>
|
|
41
|
+
</TableFooter>
|
|
42
|
+
</Table>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Components
|
|
46
|
+
|
|
47
|
+
| Component | Description |
|
|
48
|
+
|-----------|-------------|
|
|
49
|
+
| Table | Root container with automatic horizontal scroll |
|
|
50
|
+
| TableHeader | Header section containing column titles |
|
|
51
|
+
| TableBody | Body section containing data rows |
|
|
52
|
+
| TableFooter | Footer section for summary rows (totals, etc.) |
|
|
53
|
+
| TableRow | Individual row within header, body, or footer |
|
|
54
|
+
| TableHead | Header cell for column titles |
|
|
55
|
+
| TableCell | Data cell for row content |
|
|
56
|
+
| TableCaption | Accessible description rendered below table |
|
|
57
|
+
|
|
58
|
+
## Props
|
|
59
|
+
|
|
60
|
+
All components extend standard HTML table element props (`React.ComponentProps<"table">`, `React.ComponentProps<"thead">`, etc.).
|
|
61
|
+
|
|
62
|
+
### Table
|
|
63
|
+
|
|
64
|
+
Automatically wraps content in a responsive scroll container.
|
|
65
|
+
|
|
66
|
+
| Prop | Type | Default | Description |
|
|
67
|
+
|------|------|---------|-------------|
|
|
68
|
+
| className | string | - | Additional classes for the table element |
|
|
69
|
+
| ...props | ComponentProps<"table"> | - | Standard table element props |
|
|
70
|
+
|
|
71
|
+
### TableHeader
|
|
72
|
+
|
|
73
|
+
| Prop | Type | Default | Description |
|
|
74
|
+
|------|------|---------|-------------|
|
|
75
|
+
| className | string | - | Additional classes for thead element |
|
|
76
|
+
| ...props | ComponentProps<"thead"> | - | Standard thead element props |
|
|
77
|
+
|
|
78
|
+
### TableBody
|
|
79
|
+
|
|
80
|
+
| Prop | Type | Default | Description |
|
|
81
|
+
|------|------|---------|-------------|
|
|
82
|
+
| className | string | - | Additional classes for tbody element |
|
|
83
|
+
| ...props | ComponentProps<"tbody"> | - | Standard tbody element props |
|
|
84
|
+
|
|
85
|
+
### TableFooter
|
|
86
|
+
|
|
87
|
+
Styled with muted background for visual distinction.
|
|
88
|
+
|
|
89
|
+
| Prop | Type | Default | Description |
|
|
90
|
+
|------|------|---------|-------------|
|
|
91
|
+
| className | string | - | Additional classes for tfoot element |
|
|
92
|
+
| ...props | ComponentProps<"tfoot"> | - | Standard tfoot element props |
|
|
93
|
+
|
|
94
|
+
### TableRow
|
|
95
|
+
|
|
96
|
+
| Prop | Type | Default | Description |
|
|
97
|
+
|------|------|---------|-------------|
|
|
98
|
+
| data-state | "selected" | - | Apply selected styling to row |
|
|
99
|
+
| className | string | - | Additional classes for tr element |
|
|
100
|
+
| ...props | ComponentProps<"tr"> | - | Standard tr element props |
|
|
101
|
+
|
|
102
|
+
### TableHead
|
|
103
|
+
|
|
104
|
+
| Prop | Type | Default | Description |
|
|
105
|
+
|------|------|---------|-------------|
|
|
106
|
+
| className | string | - | Additional classes for th element |
|
|
107
|
+
| ...props | ComponentProps<"th"> | - | Standard th element props (scope, etc.) |
|
|
108
|
+
|
|
109
|
+
### TableCell
|
|
110
|
+
|
|
111
|
+
| Prop | Type | Default | Description |
|
|
112
|
+
|------|------|---------|-------------|
|
|
113
|
+
| colSpan | number | - | Number of columns to span |
|
|
114
|
+
| className | string | - | Additional classes for td element |
|
|
115
|
+
| ...props | ComponentProps<"td"> | - | Standard td element props |
|
|
116
|
+
|
|
117
|
+
### TableCaption
|
|
118
|
+
|
|
119
|
+
| Prop | Type | Default | Description |
|
|
120
|
+
|------|------|---------|-------------|
|
|
121
|
+
| className | string | - | Additional classes for caption element |
|
|
122
|
+
| ...props | ComponentProps<"caption"> | - | Standard caption element props |
|
|
123
|
+
|
|
124
|
+
## Data Attributes
|
|
125
|
+
|
|
126
|
+
| Attribute | Element | When Present |
|
|
127
|
+
|-----------|---------|--------------|
|
|
128
|
+
| data-state="selected" | TableRow | Row is visually highlighted as selected |
|
|
129
|
+
| data-slot | All | Identifies component part for styling ("table", "table-header", etc.) |
|
|
130
|
+
|
|
131
|
+
## Examples
|
|
132
|
+
|
|
133
|
+
### Basic Table
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
<Table>
|
|
137
|
+
<TableHeader>
|
|
138
|
+
<TableRow>
|
|
139
|
+
<TableHead>Invoice</TableHead>
|
|
140
|
+
<TableHead>Status</TableHead>
|
|
141
|
+
<TableHead className="text-right">Amount</TableHead>
|
|
142
|
+
</TableRow>
|
|
143
|
+
</TableHeader>
|
|
144
|
+
<TableBody>
|
|
145
|
+
<TableRow>
|
|
146
|
+
<TableCell className="font-medium">INV001</TableCell>
|
|
147
|
+
<TableCell>Paid</TableCell>
|
|
148
|
+
<TableCell className="text-right">$250.00</TableCell>
|
|
149
|
+
</TableRow>
|
|
150
|
+
<TableRow>
|
|
151
|
+
<TableCell className="font-medium">INV002</TableCell>
|
|
152
|
+
<TableCell>Pending</TableCell>
|
|
153
|
+
<TableCell className="text-right">$150.00</TableCell>
|
|
154
|
+
</TableRow>
|
|
155
|
+
</TableBody>
|
|
156
|
+
<TableFooter>
|
|
157
|
+
<TableRow>
|
|
158
|
+
<TableCell colSpan={2}>Total</TableCell>
|
|
159
|
+
<TableCell className="text-right">$400.00</TableCell>
|
|
160
|
+
</TableRow>
|
|
161
|
+
</TableFooter>
|
|
162
|
+
</Table>
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### With Status Badges
|
|
166
|
+
|
|
167
|
+
```tsx
|
|
168
|
+
import { Badge } from "@neynar/ui/badge"
|
|
169
|
+
|
|
170
|
+
<Table>
|
|
171
|
+
<TableHeader>
|
|
172
|
+
<TableRow>
|
|
173
|
+
<TableHead>Service</TableHead>
|
|
174
|
+
<TableHead>Status</TableHead>
|
|
175
|
+
<TableHead>Uptime</TableHead>
|
|
176
|
+
</TableRow>
|
|
177
|
+
</TableHeader>
|
|
178
|
+
<TableBody>
|
|
179
|
+
<TableRow>
|
|
180
|
+
<TableCell className="font-medium">API Gateway</TableCell>
|
|
181
|
+
<TableCell>
|
|
182
|
+
<Badge variant="secondary">
|
|
183
|
+
<CheckCircle2Icon className="size-3" />
|
|
184
|
+
Operational
|
|
185
|
+
</Badge>
|
|
186
|
+
</TableCell>
|
|
187
|
+
<TableCell>99.99%</TableCell>
|
|
188
|
+
</TableRow>
|
|
189
|
+
<TableRow>
|
|
190
|
+
<TableCell className="font-medium">Webhooks</TableCell>
|
|
191
|
+
<TableCell>
|
|
192
|
+
<Badge variant="destructive">
|
|
193
|
+
<XCircleIcon className="size-3" />
|
|
194
|
+
Offline
|
|
195
|
+
</Badge>
|
|
196
|
+
</TableCell>
|
|
197
|
+
<TableCell>85.20%</TableCell>
|
|
198
|
+
</TableRow>
|
|
199
|
+
</TableBody>
|
|
200
|
+
</Table>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### With Action Buttons
|
|
204
|
+
|
|
205
|
+
```tsx
|
|
206
|
+
import { Button } from "@neynar/ui/button"
|
|
207
|
+
|
|
208
|
+
<Table>
|
|
209
|
+
<TableHeader>
|
|
210
|
+
<TableRow>
|
|
211
|
+
<TableHead>API Key</TableHead>
|
|
212
|
+
<TableHead>Environment</TableHead>
|
|
213
|
+
<TableHead className="text-right">Actions</TableHead>
|
|
214
|
+
</TableRow>
|
|
215
|
+
</TableHeader>
|
|
216
|
+
<TableBody>
|
|
217
|
+
<TableRow>
|
|
218
|
+
<TableCell className="font-mono text-xs">neynar_sk_***_8f3d</TableCell>
|
|
219
|
+
<TableCell>
|
|
220
|
+
<Badge variant="default">Production</Badge>
|
|
221
|
+
</TableCell>
|
|
222
|
+
<TableCell className="text-right">
|
|
223
|
+
<div className="flex justify-end gap-2">
|
|
224
|
+
<Button variant="ghost" size="icon-sm">
|
|
225
|
+
<ExternalLinkIcon className="size-4" />
|
|
226
|
+
</Button>
|
|
227
|
+
<Button variant="ghost" size="icon-sm">
|
|
228
|
+
<MoreHorizontalIcon className="size-4" />
|
|
229
|
+
</Button>
|
|
230
|
+
</div>
|
|
231
|
+
</TableCell>
|
|
232
|
+
</TableRow>
|
|
233
|
+
</TableBody>
|
|
234
|
+
</Table>
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Selectable Rows
|
|
238
|
+
|
|
239
|
+
```tsx
|
|
240
|
+
<Table>
|
|
241
|
+
<TableHeader>
|
|
242
|
+
<TableRow>
|
|
243
|
+
<TableHead>Name</TableHead>
|
|
244
|
+
<TableHead>Role</TableHead>
|
|
245
|
+
</TableRow>
|
|
246
|
+
</TableHeader>
|
|
247
|
+
<TableBody>
|
|
248
|
+
<TableRow>
|
|
249
|
+
<TableCell className="font-medium">Alice Johnson</TableCell>
|
|
250
|
+
<TableCell>Admin</TableCell>
|
|
251
|
+
</TableRow>
|
|
252
|
+
<TableRow data-state="selected">
|
|
253
|
+
<TableCell className="font-medium">Bob Smith</TableCell>
|
|
254
|
+
<TableCell>Developer</TableCell>
|
|
255
|
+
</TableRow>
|
|
256
|
+
<TableRow>
|
|
257
|
+
<TableCell className="font-medium">Carol White</TableCell>
|
|
258
|
+
<TableCell>Designer</TableCell>
|
|
259
|
+
</TableRow>
|
|
260
|
+
</TableBody>
|
|
261
|
+
</Table>
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### With Caption
|
|
265
|
+
|
|
266
|
+
```tsx
|
|
267
|
+
<Table>
|
|
268
|
+
<TableCaption>A list of your recent transactions</TableCaption>
|
|
269
|
+
<TableHeader>
|
|
270
|
+
<TableRow>
|
|
271
|
+
<TableHead>Transaction</TableHead>
|
|
272
|
+
<TableHead>Date</TableHead>
|
|
273
|
+
<TableHead className="text-right">Amount</TableHead>
|
|
274
|
+
</TableRow>
|
|
275
|
+
</TableHeader>
|
|
276
|
+
<TableBody>
|
|
277
|
+
<TableRow>
|
|
278
|
+
<TableCell className="font-medium">Purchase</TableCell>
|
|
279
|
+
<TableCell>2025-12-29</TableCell>
|
|
280
|
+
<TableCell className="text-right">$99.00</TableCell>
|
|
281
|
+
</TableRow>
|
|
282
|
+
</TableBody>
|
|
283
|
+
</Table>
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## Styling
|
|
287
|
+
|
|
288
|
+
### Responsive Scrolling
|
|
289
|
+
|
|
290
|
+
The Table component automatically provides horizontal scrolling for tables that exceed viewport width. No additional configuration needed.
|
|
291
|
+
|
|
292
|
+
### Compact Tables
|
|
293
|
+
|
|
294
|
+
Reduce spacing for dense data:
|
|
295
|
+
|
|
296
|
+
```tsx
|
|
297
|
+
<Table className="text-xs">
|
|
298
|
+
<TableHeader>
|
|
299
|
+
<TableRow>
|
|
300
|
+
<TableHead className="h-8 px-2">ID</TableHead>
|
|
301
|
+
<TableHead className="h-8 px-2">Event</TableHead>
|
|
302
|
+
</TableRow>
|
|
303
|
+
</TableHeader>
|
|
304
|
+
<TableBody>
|
|
305
|
+
<TableRow>
|
|
306
|
+
<TableCell className="p-1 px-2 font-mono">001</TableCell>
|
|
307
|
+
<TableCell className="p-1 px-2">cast.created</TableCell>
|
|
308
|
+
</TableRow>
|
|
309
|
+
</TableBody>
|
|
310
|
+
</Table>
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### Alignment
|
|
314
|
+
|
|
315
|
+
Use Tailwind utility classes for text alignment:
|
|
316
|
+
|
|
317
|
+
```tsx
|
|
318
|
+
<TableHead className="text-right">Amount</TableHead>
|
|
319
|
+
<TableCell className="text-center">Status</TableCell>
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
## Accessibility
|
|
323
|
+
|
|
324
|
+
- Semantic HTML table structure (`<table>`, `<thead>`, `<tbody>`, `<tfoot>`)
|
|
325
|
+
- TableCaption provides accessible description for screen readers
|
|
326
|
+
- TableHead uses `<th>` elements with implicit scope
|
|
327
|
+
- Proper heading hierarchy maintained
|
|
328
|
+
- All standard table ARIA attributes supported via props
|
|
329
|
+
|
|
330
|
+
## Related
|
|
331
|
+
|
|
332
|
+
- [Badge](/components/badge) - Status indicators within table cells
|
|
333
|
+
- [Button](/components/button) - Action buttons for row operations
|
|
334
|
+
- [Checkbox](/components/checkbox) - Selectable rows
|