@neynar/ui 0.1.1 → 0.1.2
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/components/ui/accordion.d.ts +1 -25
- package/dist/components/ui/accordion.d.ts.map +1 -1
- package/dist/components/ui/alert-dialog.d.ts +240 -46
- package/dist/components/ui/alert-dialog.d.ts.map +1 -1
- package/dist/components/ui/alert.d.ts +73 -11
- package/dist/components/ui/alert.d.ts.map +1 -1
- package/dist/components/ui/aspect-ratio.d.ts +44 -10
- package/dist/components/ui/aspect-ratio.d.ts.map +1 -1
- package/dist/components/ui/avatar.d.ts +117 -33
- package/dist/components/ui/avatar.d.ts.map +1 -1
- package/dist/components/ui/badge.d.ts +50 -71
- package/dist/components/ui/badge.d.ts.map +1 -1
- package/dist/components/ui/breadcrumb.d.ts +231 -49
- package/dist/components/ui/breadcrumb.d.ts.map +1 -1
- package/dist/components/ui/button.d.ts +189 -71
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/calendar.d.ts +197 -40
- package/dist/components/ui/calendar.d.ts.map +1 -1
- package/dist/components/ui/card.d.ts +7 -22
- package/dist/components/ui/card.d.ts.map +1 -1
- package/dist/components/ui/carousel.d.ts +369 -99
- package/dist/components/ui/carousel.d.ts.map +1 -1
- package/dist/components/ui/chart.d.ts.map +1 -1
- package/dist/components/ui/checkbox.d.ts +110 -38
- package/dist/components/ui/checkbox.d.ts.map +1 -1
- package/dist/components/ui/collapsible.d.ts +246 -61
- package/dist/components/ui/collapsible.d.ts.map +1 -1
- package/dist/components/ui/combobox.d.ts +207 -159
- package/dist/components/ui/combobox.d.ts.map +1 -1
- package/dist/components/ui/command.d.ts +336 -67
- package/dist/components/ui/command.d.ts.map +1 -1
- package/dist/components/ui/container.d.ts +159 -64
- package/dist/components/ui/container.d.ts.map +1 -1
- package/dist/components/ui/context-menu.d.ts +321 -39
- package/dist/components/ui/context-menu.d.ts.map +1 -1
- package/dist/components/ui/date-picker.d.ts +113 -86
- package/dist/components/ui/date-picker.d.ts.map +1 -1
- package/dist/components/ui/dialog.d.ts +106 -25
- package/dist/components/ui/dialog.d.ts.map +1 -1
- package/dist/components/ui/drawer.d.ts +388 -59
- package/dist/components/ui/drawer.d.ts.map +1 -1
- package/dist/components/ui/dropdown-menu.d.ts +521 -74
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -1
- package/dist/components/ui/empty-state.d.ts +148 -76
- package/dist/components/ui/empty-state.d.ts.map +1 -1
- package/dist/components/ui/hover-card.d.ts +253 -34
- package/dist/components/ui/hover-card.d.ts.map +1 -1
- package/dist/components/ui/input.d.ts +143 -44
- package/dist/components/ui/input.d.ts.map +1 -1
- package/dist/components/ui/label.d.ts +0 -8
- package/dist/components/ui/label.d.ts.map +1 -1
- package/dist/components/ui/menubar.d.ts +288 -46
- package/dist/components/ui/menubar.d.ts.map +1 -1
- package/dist/components/ui/navigation-menu.d.ts +444 -127
- package/dist/components/ui/navigation-menu.d.ts.map +1 -1
- package/dist/components/ui/pagination.d.ts +342 -66
- package/dist/components/ui/pagination.d.ts.map +1 -1
- package/dist/components/ui/popover.d.ts +0 -8
- package/dist/components/ui/popover.d.ts.map +1 -1
- package/dist/components/ui/progress.d.ts +88 -30
- package/dist/components/ui/progress.d.ts.map +1 -1
- package/dist/components/ui/radio-group.d.ts +189 -45
- package/dist/components/ui/radio-group.d.ts.map +1 -1
- package/dist/components/ui/resizable.d.ts +178 -62
- package/dist/components/ui/resizable.d.ts.map +1 -1
- package/dist/components/ui/scroll-area.d.ts +180 -21
- package/dist/components/ui/scroll-area.d.ts.map +1 -1
- package/dist/components/ui/select.d.ts +382 -60
- package/dist/components/ui/select.d.ts.map +1 -1
- package/dist/components/ui/separator.d.ts +52 -39
- package/dist/components/ui/separator.d.ts.map +1 -1
- package/dist/components/ui/sheet.d.ts +144 -27
- package/dist/components/ui/sheet.d.ts.map +1 -1
- package/dist/components/ui/sidebar.d.ts +81 -31
- package/dist/components/ui/sidebar.d.ts.map +1 -1
- package/dist/components/ui/skeleton.d.ts +94 -32
- package/dist/components/ui/skeleton.d.ts.map +1 -1
- package/dist/components/ui/slider.d.ts +37 -31
- package/dist/components/ui/slider.d.ts.map +1 -1
- package/dist/components/ui/sonner.d.ts +280 -46
- package/dist/components/ui/sonner.d.ts.map +1 -1
- package/dist/components/ui/stack.d.ts +289 -148
- package/dist/components/ui/stack.d.ts.map +1 -1
- package/dist/components/ui/stories/aspect-ratio.stories.d.ts +1 -2
- package/dist/components/ui/stories/aspect-ratio.stories.d.ts.map +1 -1
- package/dist/components/ui/stories/container.stories.d.ts +2 -3
- package/dist/components/ui/stories/container.stories.d.ts.map +1 -1
- package/dist/components/ui/stories/empty-state.stories.d.ts +2 -2
- package/dist/components/ui/stories/scroll-area.stories.d.ts +1 -2
- package/dist/components/ui/stories/scroll-area.stories.d.ts.map +1 -1
- package/dist/components/ui/stories/stack.stories.d.ts +1 -1
- package/dist/components/ui/stories/text-field.stories.d.ts +7 -1
- package/dist/components/ui/stories/text-field.stories.d.ts.map +1 -1
- package/dist/components/ui/switch.d.ts +44 -38
- package/dist/components/ui/switch.d.ts.map +1 -1
- package/dist/components/ui/table.d.ts +33 -0
- package/dist/components/ui/table.d.ts.map +1 -1
- package/dist/components/ui/tabs.d.ts +4 -22
- package/dist/components/ui/tabs.d.ts.map +1 -1
- package/dist/components/ui/text-field.d.ts +170 -84
- package/dist/components/ui/text-field.d.ts.map +1 -1
- package/dist/components/ui/textarea.d.ts +106 -29
- package/dist/components/ui/textarea.d.ts.map +1 -1
- package/dist/components/ui/theme-toggle.d.ts +190 -65
- package/dist/components/ui/theme-toggle.d.ts.map +1 -1
- package/dist/components/ui/theme.d.ts +107 -23
- package/dist/components/ui/theme.d.ts.map +1 -1
- package/dist/components/ui/toggle-group.d.ts +143 -67
- package/dist/components/ui/toggle-group.d.ts.map +1 -1
- package/dist/components/ui/toggle.d.ts +118 -30
- package/dist/components/ui/toggle.d.ts.map +1 -1
- package/dist/components/ui/tooltip.d.ts +152 -28
- package/dist/components/ui/tooltip.d.ts.map +1 -1
- package/dist/components/ui/typography.d.ts +452 -134
- package/dist/components/ui/typography.d.ts.map +1 -1
- package/dist/index.js +9388 -8281
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/llms.txt +173 -3
- package/package.json +5 -2
- package/src/components/ui/accordion.tsx +112 -27
- package/src/components/ui/alert-dialog.tsx +401 -46
- package/src/components/ui/alert.tsx +114 -11
- package/src/components/ui/aspect-ratio.tsx +69 -14
- package/src/components/ui/avatar.tsx +179 -33
- package/src/components/ui/badge.tsx +74 -75
- package/src/components/ui/breadcrumb.tsx +335 -50
- package/src/components/ui/button.tsx +198 -90
- package/src/components/ui/calendar.tsx +867 -43
- package/src/components/ui/card.tsx +140 -33
- package/src/components/ui/carousel.tsx +529 -98
- package/src/components/ui/chart.tsx +222 -1
- package/src/components/ui/checkbox.tsx +176 -38
- package/src/components/ui/collapsible.tsx +321 -67
- package/src/components/ui/combobox.tsx +284 -83
- package/src/components/ui/command.tsx +527 -67
- package/src/components/ui/container.tsx +217 -65
- package/src/components/ui/context-menu.tsx +716 -51
- package/src/components/ui/date-picker.tsx +228 -38
- package/src/components/ui/dialog.tsx +270 -33
- package/src/components/ui/drawer.tsx +546 -67
- package/src/components/ui/dropdown-menu.tsx +657 -74
- package/src/components/ui/empty-state.tsx +241 -82
- package/src/components/ui/hover-card.tsx +328 -39
- package/src/components/ui/input.tsx +207 -44
- package/src/components/ui/label.tsx +98 -8
- package/src/components/ui/menubar.tsx +587 -54
- package/src/components/ui/navigation-menu.tsx +557 -128
- package/src/components/ui/pagination.tsx +561 -79
- package/src/components/ui/popover.tsx +119 -8
- package/src/components/ui/progress.tsx +131 -29
- package/src/components/ui/radio-group.tsx +260 -51
- package/src/components/ui/resizable.tsx +289 -63
- package/src/components/ui/scroll-area.tsx +377 -66
- package/src/components/ui/select.tsx +545 -60
- package/src/components/ui/separator.tsx +146 -40
- package/src/components/ui/sheet.tsx +348 -31
- package/src/components/ui/sidebar.tsx +471 -29
- package/src/components/ui/skeleton.tsx +114 -32
- package/src/components/ui/slider.tsx +77 -31
- package/src/components/ui/sonner.tsx +574 -46
- package/src/components/ui/stack.tsx +423 -101
- package/src/components/ui/switch.tsx +78 -39
- package/src/components/ui/table.tsx +170 -4
- package/src/components/ui/tabs.tsx +108 -22
- package/src/components/ui/text-field.tsx +226 -81
- package/src/components/ui/textarea.tsx +180 -29
- package/src/components/ui/theme-toggle.tsx +313 -65
- package/src/components/ui/theme.tsx +117 -23
- package/src/components/ui/toggle-group.tsx +280 -69
- package/src/components/ui/toggle.tsx +124 -35
- package/src/components/ui/tooltip.tsx +239 -29
- package/src/components/ui/typography.tsx +1115 -165
|
@@ -2,58 +2,158 @@ import * as React from "react";
|
|
|
2
2
|
import { cn } from "@/lib/utils";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Spacing options for Stack component using Tailwind CSS spacing scale
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* Maps to Tailwind spacing utilities:
|
|
8
|
+
* - 1 = 0.25rem (4px) - Ultra-tight spacing for dense layouts
|
|
9
|
+
* - 2 = 0.5rem (8px) - Tight spacing for compact components
|
|
10
|
+
* - 3 = 0.75rem (12px) - Close spacing for related items
|
|
11
|
+
* - 4 = 1rem (16px) - Default spacing for general layouts
|
|
12
|
+
* - 6 = 1.5rem (24px) - Loose spacing for section separation
|
|
13
|
+
* - 8 = 2rem (32px) - Wide spacing for distinct content areas
|
|
14
|
+
* - 12 = 3rem (48px) - Extra-wide spacing for major layout divisions
|
|
15
|
+
*/
|
|
16
|
+
type StackSpacing = 1 | 2 | 3 | 4 | 6 | 8 | 12;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Layout direction options for Stack component
|
|
20
|
+
*
|
|
21
|
+
* - "vertical" - Flex column layout with space-y-* utilities
|
|
22
|
+
* - "horizontal" - Flex row layout with space-x-* utilities
|
|
8
23
|
*/
|
|
9
|
-
|
|
24
|
+
type StackDirection = "vertical" | "horizontal";
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Props for Stack (Documentation only - NOT used in component implementation)
|
|
28
|
+
*
|
|
29
|
+
* Extends standard HTML div attributes for flexible layout containers.
|
|
30
|
+
* Stack provides consistent spacing between child elements in either
|
|
31
|
+
* vertical or horizontal direction using Tailwind's spacing scale.
|
|
32
|
+
*
|
|
33
|
+
* Inherits all standard HTML div props including:
|
|
34
|
+
* - className: Additional CSS classes for custom styling
|
|
35
|
+
* - id: Element identifier for targeting and accessibility
|
|
36
|
+
* - role: ARIA role for semantic meaning
|
|
37
|
+
* - tabIndex: Tab order control for keyboard navigation
|
|
38
|
+
* - onClick, onKeyDown, etc.: Standard event handlers
|
|
39
|
+
* - data-*: Custom data attributes
|
|
40
|
+
* - aria-*: Accessibility attributes
|
|
41
|
+
*/
|
|
42
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
43
|
+
type StackDocsProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
10
44
|
/**
|
|
11
45
|
* The spacing between stack items using Tailwind CSS spacing scale
|
|
12
46
|
*
|
|
13
47
|
* Controls the gap between child elements using Tailwind's space utilities.
|
|
14
|
-
* Each value corresponds to a Tailwind spacing unit
|
|
48
|
+
* Each value corresponds to a Tailwind spacing unit mapped to consistent
|
|
49
|
+
* rem values for predictable visual hierarchy.
|
|
50
|
+
*
|
|
51
|
+
* **Spacing Guidelines:**
|
|
52
|
+
* - Use `1-2` for tightly related items (button groups, form fields)
|
|
53
|
+
* - Use `3-4` for standard component spacing (default recommended)
|
|
54
|
+
* - Use `6-8` for section separation and content areas
|
|
55
|
+
* - Use `12` for major layout divisions and page sections
|
|
56
|
+
*
|
|
57
|
+
* **Technical Details:**
|
|
58
|
+
* - Uses `space-y-*` utilities for vertical stacks
|
|
59
|
+
* - Uses `space-x-*` utilities for horizontal stacks
|
|
60
|
+
* - Applies margin to all children except the first
|
|
61
|
+
* - Compatible with Tailwind's JIT compilation
|
|
15
62
|
*
|
|
16
63
|
* @defaultValue 4
|
|
17
64
|
* @example
|
|
18
65
|
* ```tsx
|
|
19
|
-
* //
|
|
66
|
+
* // Ultra-tight spacing for button groups
|
|
67
|
+
* <Stack spacing={1} direction="horizontal">
|
|
68
|
+
* <Button size="sm">Edit</Button>
|
|
69
|
+
* <Button size="sm" variant="outline">Delete</Button>
|
|
70
|
+
* </Stack>
|
|
71
|
+
*
|
|
72
|
+
* // Tight spacing for form fields
|
|
20
73
|
* <Stack spacing={2}>
|
|
21
|
-
* <
|
|
22
|
-
* <
|
|
74
|
+
* <Label htmlFor="email">Email</Label>
|
|
75
|
+
* <Input id="email" type="email" />
|
|
76
|
+
* <Input type="password" placeholder="Password" />
|
|
23
77
|
* </Stack>
|
|
24
78
|
*
|
|
25
|
-
* //
|
|
79
|
+
* // Standard spacing for content sections (default)
|
|
80
|
+
* <Stack spacing={4}>
|
|
81
|
+
* <Card>User Profile</Card>
|
|
82
|
+
* <Card>Account Settings</Card>
|
|
83
|
+
* <Card>Privacy Controls</Card>
|
|
84
|
+
* </Stack>
|
|
85
|
+
*
|
|
86
|
+
* // Generous spacing for major page sections
|
|
26
87
|
* <Stack spacing={8}>
|
|
27
|
-
* <
|
|
28
|
-
* <
|
|
88
|
+
* <header>Page Header</header>
|
|
89
|
+
* <main>Main Content</main>
|
|
90
|
+
* <footer>Page Footer</footer>
|
|
29
91
|
* </Stack>
|
|
30
92
|
* ```
|
|
31
93
|
*/
|
|
32
|
-
spacing?:
|
|
94
|
+
spacing?: StackSpacing;
|
|
33
95
|
|
|
34
96
|
/**
|
|
35
97
|
* The layout direction of the stack
|
|
36
98
|
*
|
|
37
|
-
*
|
|
38
|
-
* - `
|
|
99
|
+
* **Vertical Direction (default):**
|
|
100
|
+
* - Uses `flex flex-col` for column layout
|
|
101
|
+
* - Applies `space-y-*` utilities for vertical spacing
|
|
102
|
+
* - Ideal for forms, content sections, navigation lists
|
|
103
|
+
* - Maintains natural document flow for screen readers
|
|
104
|
+
*
|
|
105
|
+
* **Horizontal Direction:**
|
|
106
|
+
* - Uses `flex flex-row` for row layout
|
|
107
|
+
* - Applies `space-x-*` utilities for horizontal spacing
|
|
108
|
+
* - Perfect for button groups, navigation bars, toolbars
|
|
109
|
+
* - Consider using `flex-wrap` class for responsive layouts
|
|
110
|
+
*
|
|
111
|
+
* **Responsive Considerations:**
|
|
112
|
+
* - Can be combined with responsive classes for adaptive layouts
|
|
113
|
+
* - Consider switching from horizontal to vertical on smaller screens
|
|
114
|
+
* - Use additional Tailwind classes for overflow handling
|
|
39
115
|
*
|
|
40
116
|
* @defaultValue "vertical"
|
|
41
117
|
* @example
|
|
42
118
|
* ```tsx
|
|
43
|
-
* // Vertical stack (default)
|
|
119
|
+
* // Vertical stack for content hierarchy (default)
|
|
44
120
|
* <Stack>
|
|
45
|
-
* <
|
|
46
|
-
* <
|
|
121
|
+
* <h2>Section Title</h2>
|
|
122
|
+
* <p>Section description text</p>
|
|
123
|
+
* <Card>Card content</Card>
|
|
124
|
+
* <Card>Another card</Card>
|
|
47
125
|
* </Stack>
|
|
48
126
|
*
|
|
49
127
|
* // Horizontal stack for action buttons
|
|
50
|
-
* <Stack direction="horizontal">
|
|
51
|
-
* <Button>Primary</Button>
|
|
128
|
+
* <Stack direction="horizontal" spacing={3}>
|
|
129
|
+
* <Button>Primary Action</Button>
|
|
52
130
|
* <Button variant="outline">Secondary</Button>
|
|
131
|
+
* <Button variant="ghost">Tertiary</Button>
|
|
132
|
+
* </Stack>
|
|
133
|
+
*
|
|
134
|
+
* // Responsive horizontal to vertical stack
|
|
135
|
+
* <Stack
|
|
136
|
+
* direction="horizontal"
|
|
137
|
+
* spacing={2}
|
|
138
|
+
* className="flex-col sm:flex-row"
|
|
139
|
+
* >
|
|
140
|
+
* <Button className="w-full sm:w-auto">Mobile Full Width</Button>
|
|
141
|
+
* <Button variant="outline" className="w-full sm:w-auto">Desktop Inline</Button>
|
|
142
|
+
* </Stack>
|
|
143
|
+
*
|
|
144
|
+
* // Horizontal navigation with overflow scroll
|
|
145
|
+
* <Stack
|
|
146
|
+
* direction="horizontal"
|
|
147
|
+
* spacing={1}
|
|
148
|
+
* className="overflow-x-auto pb-2"
|
|
149
|
+
* >
|
|
150
|
+
* <Badge variant="secondary">Tag 1</Badge>
|
|
151
|
+
* <Badge variant="secondary">Tag 2</Badge>
|
|
152
|
+
* <Badge variant="secondary">Long Tag Name</Badge>
|
|
53
153
|
* </Stack>
|
|
54
154
|
* ```
|
|
55
155
|
*/
|
|
56
|
-
direction?:
|
|
156
|
+
direction?: StackDirection;
|
|
57
157
|
};
|
|
58
158
|
|
|
59
159
|
/**
|
|
@@ -61,119 +161,341 @@ export type StackProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
61
161
|
*
|
|
62
162
|
* Stack is a fundamental layout primitive that arranges child elements in either
|
|
63
163
|
* vertical or horizontal direction with consistent spacing. Built on flexbox principles,
|
|
64
|
-
* it provides a clean API for common layout patterns without requiring
|
|
164
|
+
* it provides a clean, declarative API for common layout patterns without requiring
|
|
165
|
+
* custom CSS or complex flex configurations.
|
|
65
166
|
*
|
|
66
|
-
*
|
|
167
|
+
* **Core Features:**
|
|
168
|
+
* - Consistent spacing using Tailwind's design system
|
|
169
|
+
* - Flexible direction control (vertical/horizontal)
|
|
170
|
+
* - Zero-config flexbox layouts with predictable behavior
|
|
171
|
+
* - Composable with other UI components and layout utilities
|
|
172
|
+
* - Full accessibility support with semantic HTML structure
|
|
173
|
+
* - TypeScript-first with comprehensive prop validation
|
|
174
|
+
*
|
|
175
|
+
* **Common Use Cases:**
|
|
67
176
|
* - Form layouts with consistent field spacing
|
|
68
177
|
* - Button groups and action bars
|
|
69
178
|
* - Content sections with uniform gaps
|
|
70
|
-
* - Navigation lists and
|
|
71
|
-
* - Card layouts and
|
|
179
|
+
* - Navigation lists and menu structures
|
|
180
|
+
* - Card layouts and dashboard grids
|
|
181
|
+
* - Page sections and content hierarchy
|
|
182
|
+
* - Responsive component layouts
|
|
183
|
+
*
|
|
184
|
+
* **Design System Integration:**
|
|
185
|
+
* Stack integrates seamlessly with design systems by providing consistent
|
|
186
|
+
* spacing that aligns with Tailwind's spacing scale. This ensures visual
|
|
187
|
+
* harmony across your application and reduces the need for custom spacing
|
|
188
|
+
* utilities in most common layout scenarios.
|
|
72
189
|
*
|
|
73
|
-
* @example Basic vertical layout (default)
|
|
190
|
+
* @example Basic vertical content layout (default behavior)
|
|
74
191
|
* ```tsx
|
|
75
192
|
* <Stack>
|
|
76
|
-
* <
|
|
77
|
-
* <Card>
|
|
78
|
-
*
|
|
193
|
+
* <h1>Dashboard</h1>
|
|
194
|
+
* <Card>
|
|
195
|
+
* <CardHeader>Profile Information</CardHeader>
|
|
196
|
+
* <CardContent>User profile details</CardContent>
|
|
197
|
+
* </Card>
|
|
198
|
+
* <Card>
|
|
199
|
+
* <CardHeader>Account Settings</CardHeader>
|
|
200
|
+
* <CardContent>Account configuration options</CardContent>
|
|
201
|
+
* </Card>
|
|
202
|
+
* <Card>
|
|
203
|
+
* <CardHeader>Privacy Controls</CardHeader>
|
|
204
|
+
* <CardContent>Privacy and security settings</CardContent>
|
|
205
|
+
* </Card>
|
|
79
206
|
* </Stack>
|
|
80
207
|
* ```
|
|
81
208
|
*
|
|
82
|
-
* @example Horizontal action bar
|
|
209
|
+
* @example Horizontal action button bar
|
|
83
210
|
* ```tsx
|
|
84
|
-
* <Stack direction="horizontal" spacing={3}>
|
|
85
|
-
* <Button>
|
|
86
|
-
* <Button variant="outline">
|
|
87
|
-
* <Button
|
|
211
|
+
* <Stack direction="horizontal" spacing={3} className="justify-end">
|
|
212
|
+
* <Button variant="ghost">Cancel</Button>
|
|
213
|
+
* <Button variant="outline">Save Draft</Button>
|
|
214
|
+
* <Button>Publish</Button>
|
|
88
215
|
* </Stack>
|
|
89
216
|
* ```
|
|
90
217
|
*
|
|
91
|
-
* @example
|
|
218
|
+
* @example Complex form layout with nested stacks
|
|
92
219
|
* ```tsx
|
|
93
|
-
* <
|
|
94
|
-
* <
|
|
95
|
-
*
|
|
96
|
-
* <
|
|
97
|
-
* <
|
|
98
|
-
* <
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
220
|
+
* <form>
|
|
221
|
+
* <Stack spacing={6}>
|
|
222
|
+
* // Personal Information Section
|
|
223
|
+
* <fieldset>
|
|
224
|
+
* <legend className="text-lg font-semibold mb-4">Personal Information</legend>
|
|
225
|
+
* <Stack spacing={3}>
|
|
226
|
+
* <Stack spacing={1}>
|
|
227
|
+
* <Label htmlFor="fullName">Full Name</Label>
|
|
228
|
+
* <Input id="fullName" placeholder="Enter your full name" />
|
|
229
|
+
* </Stack>
|
|
230
|
+
* <Stack spacing={1}>
|
|
231
|
+
* <Label htmlFor="email">Email Address</Label>
|
|
232
|
+
* <Input id="email" type="email" placeholder="you@example.com" />
|
|
233
|
+
* </Stack>
|
|
234
|
+
* </Stack>
|
|
235
|
+
* </fieldset>
|
|
236
|
+
*
|
|
237
|
+
* // Preferences Section
|
|
238
|
+
* <fieldset>
|
|
239
|
+
* <legend className="text-lg font-semibold mb-4">Preferences</legend>
|
|
240
|
+
* <Stack spacing={2}>
|
|
241
|
+
* <div className="flex items-center space-x-2">
|
|
242
|
+
* <Checkbox id="emailNotifications" />
|
|
243
|
+
* <Label htmlFor="emailNotifications">Email notifications</Label>
|
|
244
|
+
* </div>
|
|
245
|
+
* <div className="flex items-center space-x-2">
|
|
246
|
+
* <Checkbox id="marketingUpdates" />
|
|
247
|
+
* <Label htmlFor="marketingUpdates">Marketing updates</Label>
|
|
248
|
+
* </div>
|
|
249
|
+
* </Stack>
|
|
250
|
+
* </fieldset>
|
|
251
|
+
*
|
|
252
|
+
* // Form Actions
|
|
253
|
+
* <Stack direction="horizontal" spacing={2} className="justify-end">
|
|
254
|
+
* <Button type="button" variant="outline">Reset</Button>
|
|
255
|
+
* <Button type="submit">Save Changes</Button>
|
|
106
256
|
* </Stack>
|
|
107
|
-
* </
|
|
108
|
-
* </
|
|
257
|
+
* </Stack>
|
|
258
|
+
* </form>
|
|
109
259
|
* ```
|
|
110
260
|
*
|
|
111
|
-
* @example Responsive
|
|
261
|
+
* @example Responsive navigation with adaptive direction
|
|
112
262
|
* ```tsx
|
|
113
263
|
* <Stack
|
|
114
|
-
*
|
|
115
|
-
*
|
|
264
|
+
* direction="horizontal"
|
|
265
|
+
* spacing={1}
|
|
266
|
+
* className="flex-col sm:flex-row overflow-x-auto sm:overflow-visible"
|
|
116
267
|
* >
|
|
117
|
-
* <
|
|
118
|
-
* <
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
* </Stack>
|
|
268
|
+
* <Button variant="ghost" className="w-full sm:w-auto">Dashboard</Button>
|
|
269
|
+
* <Button variant="ghost" className="w-full sm:w-auto">Analytics</Button>
|
|
270
|
+
* <Button variant="ghost" className="w-full sm:w-auto">Settings</Button>
|
|
271
|
+
* <Button variant="ghost" className="w-full sm:w-auto">Help</Button>
|
|
122
272
|
* </Stack>
|
|
123
273
|
* ```
|
|
124
274
|
*
|
|
275
|
+
* @example Dashboard layout with mixed content types
|
|
276
|
+
* ```tsx
|
|
277
|
+
* <div className="container mx-auto p-6">
|
|
278
|
+
* <Stack spacing={8}>
|
|
279
|
+
* // Page Header
|
|
280
|
+
* <Stack spacing={2}>
|
|
281
|
+
* <h1 className="text-3xl font-bold">Analytics Dashboard</h1>
|
|
282
|
+
* <p className="text-muted-foreground">Overview of your application metrics</p>
|
|
283
|
+
* </Stack>
|
|
284
|
+
*
|
|
285
|
+
* // Stats Cards
|
|
286
|
+
* <Stack direction="horizontal" spacing={4} className="grid grid-cols-1 md:grid-cols-3 gap-4">
|
|
287
|
+
* <Card>
|
|
288
|
+
* <CardHeader>
|
|
289
|
+
* <CardTitle>Total Users</CardTitle>
|
|
290
|
+
* </CardHeader>
|
|
291
|
+
* <CardContent>
|
|
292
|
+
* <div className="text-2xl font-bold">2,543</div>
|
|
293
|
+
* </CardContent>
|
|
294
|
+
* </Card>
|
|
295
|
+
* <Card>
|
|
296
|
+
* <CardHeader>
|
|
297
|
+
* <CardTitle>Revenue</CardTitle>
|
|
298
|
+
* </CardHeader>
|
|
299
|
+
* <CardContent>
|
|
300
|
+
* <div className="text-2xl font-bold">$12,543</div>
|
|
301
|
+
* </CardContent>
|
|
302
|
+
* </Card>
|
|
303
|
+
* <Card>
|
|
304
|
+
* <CardHeader>
|
|
305
|
+
* <CardTitle>Growth</CardTitle>
|
|
306
|
+
* </CardHeader>
|
|
307
|
+
* <CardContent>
|
|
308
|
+
* <div className="text-2xl font-bold text-green-600">+12.5%</div>
|
|
309
|
+
* </CardContent>
|
|
310
|
+
* </Card>
|
|
311
|
+
* </Stack>
|
|
312
|
+
*
|
|
313
|
+
* // Content Sections
|
|
314
|
+
* <Stack spacing={6}>
|
|
315
|
+
* <Card>
|
|
316
|
+
* <CardHeader>
|
|
317
|
+
* <CardTitle>Recent Activity</CardTitle>
|
|
318
|
+
* </CardHeader>
|
|
319
|
+
* <CardContent>Activity timeline content</CardContent>
|
|
320
|
+
* </Card>
|
|
321
|
+
* <Card>
|
|
322
|
+
* <CardHeader>
|
|
323
|
+
* <CardTitle>Performance Metrics</CardTitle>
|
|
324
|
+
* </CardHeader>
|
|
325
|
+
* <CardContent>Charts and graphs</CardContent>
|
|
326
|
+
* </Card>
|
|
327
|
+
* </Stack>
|
|
328
|
+
* </Stack>
|
|
329
|
+
* </div>
|
|
330
|
+
* ```
|
|
331
|
+
*
|
|
332
|
+
* @example Advanced usage with custom styling and semantic elements
|
|
333
|
+
* ```tsx
|
|
334
|
+
* <article className="prose max-w-none">
|
|
335
|
+
* <Stack spacing={6}>
|
|
336
|
+
* <header>
|
|
337
|
+
* <Stack spacing={2}>
|
|
338
|
+
* <h1>The Future of Web Development</h1>
|
|
339
|
+
* <Stack direction="horizontal" spacing={4} className="text-sm text-muted-foreground">
|
|
340
|
+
* <time dateTime="2024-01-15">January 15, 2024</time>
|
|
341
|
+
* <address className="not-italic">By Jane Developer</address>
|
|
342
|
+
* <span>5 min read</span>
|
|
343
|
+
* </Stack>
|
|
344
|
+
* </Stack>
|
|
345
|
+
* </header>
|
|
346
|
+
*
|
|
347
|
+
* <main>
|
|
348
|
+
* <Stack spacing={4}>
|
|
349
|
+
* <p>Introduction paragraph with key concepts...</p>
|
|
350
|
+
* <section>
|
|
351
|
+
* <h2>Key Technologies</h2>
|
|
352
|
+
* <Stack spacing={3}>
|
|
353
|
+
* <p>Discussion of modern web technologies...</p>
|
|
354
|
+
* <ul>
|
|
355
|
+
* <li>React and component architecture</li>
|
|
356
|
+
* <li>Server-side rendering with Next.js</li>
|
|
357
|
+
* <li>Type-safe development with TypeScript</li>
|
|
358
|
+
* </ul>
|
|
359
|
+
* </Stack>
|
|
360
|
+
* </section>
|
|
361
|
+
* <section>
|
|
362
|
+
* <h2>Best Practices</h2>
|
|
363
|
+
* <p>Guidelines for effective development...</p>
|
|
364
|
+
* </section>
|
|
365
|
+
* </Stack>
|
|
366
|
+
* </main>
|
|
367
|
+
*
|
|
368
|
+
* <footer>
|
|
369
|
+
* <Stack direction="horizontal" spacing={2} className="justify-between items-center">
|
|
370
|
+
* <Stack direction="horizontal" spacing={1}>
|
|
371
|
+
* <Badge variant="secondary">React</Badge>
|
|
372
|
+
* <Badge variant="secondary">TypeScript</Badge>
|
|
373
|
+
* <Badge variant="secondary">Next.js</Badge>
|
|
374
|
+
* </Stack>
|
|
375
|
+
* <Stack direction="horizontal" spacing={2}>
|
|
376
|
+
* <Button variant="outline" size="sm">Share</Button>
|
|
377
|
+
* <Button variant="outline" size="sm">Save</Button>
|
|
378
|
+
* </Stack>
|
|
379
|
+
* </Stack>
|
|
380
|
+
* </footer>
|
|
381
|
+
* </Stack>
|
|
382
|
+
* </article>
|
|
383
|
+
* ```
|
|
384
|
+
*
|
|
125
385
|
* @remarks
|
|
126
386
|
* **Design Philosophy:**
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* **
|
|
133
|
-
* -
|
|
134
|
-
* -
|
|
135
|
-
* -
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
* -
|
|
141
|
-
* -
|
|
387
|
+
* Stack follows the principle of consistent spacing throughout the UI, using Tailwind's
|
|
388
|
+
* carefully crafted spacing scale to create visual hierarchy and rhythm. The component
|
|
389
|
+
* prioritizes composability, allowing complex layouts to be built from simple, predictable
|
|
390
|
+
* building blocks while maintaining semantic HTML structure.
|
|
391
|
+
*
|
|
392
|
+
* **Technical Implementation:**
|
|
393
|
+
* - Uses CSS Flexbox for reliable cross-browser layout behavior
|
|
394
|
+
* - Leverages Tailwind's space-* utilities for optimal performance
|
|
395
|
+
* - Applies margins only to children (not first child) for clean edge handling
|
|
396
|
+
* - Compatible with Tailwind's JIT compilation for minimal bundle size
|
|
397
|
+
* - Supports all standard HTML div attributes for maximum flexibility
|
|
398
|
+
*
|
|
399
|
+
* **Performance Considerations:**
|
|
400
|
+
* - Zero JavaScript runtime overhead - pure CSS-based layout
|
|
401
|
+
* - Optimized for Tailwind's purging and JIT compilation
|
|
402
|
+
* - Efficient rendering with no layout calculation overhead
|
|
403
|
+
* - Scales well with large numbers of child elements
|
|
404
|
+
* - Memory-efficient with minimal DOM structure impact
|
|
405
|
+
*
|
|
406
|
+
* **Responsive Design Integration:**
|
|
407
|
+
* Stack works seamlessly with Tailwind's responsive utilities. You can easily
|
|
408
|
+
* create adaptive layouts that change direction, spacing, or additional styling
|
|
409
|
+
* based on screen size breakpoints.
|
|
410
|
+
*
|
|
411
|
+
* **Common Patterns:**
|
|
412
|
+
* - **Form Layouts**: Use nested stacks for sections, fields, and actions
|
|
413
|
+
* - **Content Hierarchies**: Vary spacing to create visual importance levels
|
|
414
|
+
* - **Component Composition**: Combine with Cards, Buttons, and other components
|
|
415
|
+
* - **Responsive Grids**: Use with CSS Grid classes for complex layouts
|
|
416
|
+
* - **Navigation Patterns**: Create horizontal and vertical navigation structures
|
|
417
|
+
*
|
|
418
|
+
* @accessibility
|
|
419
|
+
* **Keyboard Navigation:**
|
|
420
|
+
* - Preserves natural document flow and tab order
|
|
421
|
+
* - Does not interfere with focus management of child components
|
|
422
|
+
* - Maintains logical reading order for screen readers
|
|
423
|
+
* - Supports all standard keyboard navigation patterns
|
|
424
|
+
*
|
|
425
|
+
* **Screen Reader Support:**
|
|
426
|
+
* - Uses semantic HTML div element with no interference
|
|
427
|
+
* - Preserves natural content structure and hierarchy
|
|
428
|
+
* - Compatible with all ARIA attributes on child elements
|
|
429
|
+
* - Supports landmark roles when used with semantic HTML
|
|
430
|
+
* - Maintains proper heading structure and content relationships
|
|
431
|
+
*
|
|
432
|
+
* **ARIA Compatibility:**
|
|
433
|
+
* - Accepts all ARIA attributes for enhanced accessibility
|
|
434
|
+
* - Does not modify or interfere with child component ARIA properties
|
|
435
|
+
* - Supports role attributes for semantic meaning
|
|
436
|
+
* - Compatible with aria-label, aria-describedby, and other ARIA properties
|
|
437
|
+
*
|
|
438
|
+
* **Focus Management:**
|
|
439
|
+
* - Transparent to focus behavior - delegates to child components
|
|
440
|
+
* - Supports tabIndex for custom focus control when needed
|
|
441
|
+
* - Does not trap or redirect focus automatically
|
|
442
|
+
* - Maintains predictable focus flow in both directions
|
|
443
|
+
*
|
|
444
|
+
* @performance
|
|
445
|
+
* **Bundle Impact:**
|
|
446
|
+
* - Minimal JavaScript bundle size (primarily TypeScript types)
|
|
447
|
+
* - CSS-only layout solution with no runtime calculations
|
|
448
|
+
* - Leverages Tailwind's tree-shaking for optimal CSS output
|
|
449
|
+
* - No external dependencies beyond React and utility functions
|
|
450
|
+
*
|
|
451
|
+
* **Runtime Performance:**
|
|
452
|
+
* - Zero-cost abstraction over native flexbox
|
|
453
|
+
* - No re-renders triggered by prop changes (style-based)
|
|
454
|
+
* - Efficient DOM structure with single wrapper element
|
|
455
|
+
* - Compatible with React's concurrent features and optimizations
|
|
142
456
|
*
|
|
143
457
|
* @public
|
|
144
458
|
* @since 1.0.0
|
|
459
|
+
* @see {@link Button} For action elements commonly used in horizontal stacks
|
|
460
|
+
* @see {@link Card} For content containers commonly arranged in stacks
|
|
145
461
|
* @see {@link https://tailwindcss.com/docs/space} Tailwind CSS spacing utilities
|
|
462
|
+
* @see {@link https://tailwindcss.com/docs/flexbox-direction} Tailwind CSS flex direction
|
|
463
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout} MDN CSS Flexbox Guide
|
|
146
464
|
*/
|
|
147
|
-
const Stack = React.forwardRef<
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
)
|
|
465
|
+
const Stack = React.forwardRef<
|
|
466
|
+
HTMLDivElement,
|
|
467
|
+
React.HTMLAttributes<HTMLDivElement> & {
|
|
468
|
+
spacing?: StackSpacing;
|
|
469
|
+
direction?: StackDirection;
|
|
470
|
+
}
|
|
471
|
+
>(({ className, spacing = 4, direction = "vertical", ...props }, ref) => {
|
|
472
|
+
return (
|
|
473
|
+
<div
|
|
474
|
+
ref={ref}
|
|
475
|
+
className={cn(
|
|
476
|
+
direction === "vertical" ? "flex flex-col" : "flex flex-row",
|
|
477
|
+
{
|
|
478
|
+
"space-y-1": direction === "vertical" && spacing === 1,
|
|
479
|
+
"space-y-2": direction === "vertical" && spacing === 2,
|
|
480
|
+
"space-y-3": direction === "vertical" && spacing === 3,
|
|
481
|
+
"space-y-4": direction === "vertical" && spacing === 4,
|
|
482
|
+
"space-y-6": direction === "vertical" && spacing === 6,
|
|
483
|
+
"space-y-8": direction === "vertical" && spacing === 8,
|
|
484
|
+
"space-y-12": direction === "vertical" && spacing === 12,
|
|
485
|
+
"space-x-1": direction === "horizontal" && spacing === 1,
|
|
486
|
+
"space-x-2": direction === "horizontal" && spacing === 2,
|
|
487
|
+
"space-x-3": direction === "horizontal" && spacing === 3,
|
|
488
|
+
"space-x-4": direction === "horizontal" && spacing === 4,
|
|
489
|
+
"space-x-6": direction === "horizontal" && spacing === 6,
|
|
490
|
+
"space-x-8": direction === "horizontal" && spacing === 8,
|
|
491
|
+
"space-x-12": direction === "horizontal" && spacing === 12,
|
|
492
|
+
},
|
|
493
|
+
className,
|
|
494
|
+
)}
|
|
495
|
+
{...props}
|
|
496
|
+
/>
|
|
497
|
+
);
|
|
498
|
+
});
|
|
177
499
|
|
|
178
500
|
Stack.displayName = "Stack";
|
|
179
501
|
|