@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Slot } from "@radix-ui/react-slot";
|
|
3
|
-
import { cva
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
4
|
|
|
5
5
|
import { cn } from "@/lib/utils";
|
|
6
6
|
|
|
@@ -8,25 +8,29 @@ import { cn } from "@/lib/utils";
|
|
|
8
8
|
* Button variant configuration using class-variance-authority
|
|
9
9
|
*
|
|
10
10
|
* Defines all possible visual variants and sizes for the Button component.
|
|
11
|
-
* Uses Tailwind CSS
|
|
11
|
+
* Uses Tailwind CSS with custom CSS properties for theming and comprehensive
|
|
12
|
+
* accessibility features including focus management and ARIA support.
|
|
13
|
+
*
|
|
14
|
+
* @variant default - Primary action button with brand colors and elevated appearance
|
|
15
|
+
* @variant destructive - Dangerous/destructive actions (delete, remove, etc.) with red theming
|
|
16
|
+
* @variant outline - Secondary action with subtle border and background hover states
|
|
17
|
+
* @variant secondary - Alternative secondary styling with muted colors
|
|
18
|
+
* @variant ghost - Minimal styling with hover states, often used in toolbars or menus
|
|
19
|
+
* @variant link - Text-only button styled like a hyperlink with underline on hover
|
|
20
|
+
*
|
|
21
|
+
* @size default - Standard button height (36px) with balanced padding
|
|
22
|
+
* @size sm - Small button height (32px) for compact interfaces
|
|
23
|
+
* @size lg - Large button height (40px) for prominent actions
|
|
24
|
+
* @size icon - Square button (36px × 36px) optimized for icon-only usage
|
|
12
25
|
*
|
|
13
26
|
* @see {@link https://cva.style/docs} - CVA documentation
|
|
27
|
+
* @see {@link https://ui.shadcn.com/docs/components/button} - shadcn/ui button documentation
|
|
14
28
|
* @since 1.0.0
|
|
15
29
|
*/
|
|
16
30
|
const buttonVariants = cva(
|
|
17
31
|
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
18
32
|
{
|
|
19
33
|
variants: {
|
|
20
|
-
/**
|
|
21
|
-
* Visual style variants for the button
|
|
22
|
-
*
|
|
23
|
-
* @variant default - Primary action button with brand colors
|
|
24
|
-
* @variant destructive - Dangerous actions (delete, remove, etc.)
|
|
25
|
-
* @variant outline - Secondary action with border
|
|
26
|
-
* @variant secondary - Alternative secondary styling
|
|
27
|
-
* @variant ghost - Minimal styling, often used in toolbars
|
|
28
|
-
* @variant link - Text-only button that looks like a link
|
|
29
|
-
*/
|
|
30
34
|
variant: {
|
|
31
35
|
default:
|
|
32
36
|
"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",
|
|
@@ -40,14 +44,6 @@ const buttonVariants = cva(
|
|
|
40
44
|
"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
|
41
45
|
link: "text-primary underline-offset-4 hover:underline",
|
|
42
46
|
},
|
|
43
|
-
/**
|
|
44
|
-
* Size variants for the button
|
|
45
|
-
*
|
|
46
|
-
* @size default - Standard button height (36px)
|
|
47
|
-
* @size sm - Small button height (32px)
|
|
48
|
-
* @size lg - Large button height (40px)
|
|
49
|
-
* @size icon - Square button for icons only (36px × 36px)
|
|
50
|
-
*/
|
|
51
47
|
size: {
|
|
52
48
|
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
53
49
|
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
|
|
@@ -63,60 +59,145 @@ const buttonVariants = cva(
|
|
|
63
59
|
);
|
|
64
60
|
|
|
65
61
|
/**
|
|
66
|
-
*
|
|
62
|
+
* Props for Button component (Documentation only - NOT used in component implementation)
|
|
63
|
+
* These types are for documentation generation and should not replace CVA/Radix inferred types
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
type ButtonDocsProps = {
|
|
67
|
+
/** Visual style variant that determines the button's appearance and semantic meaning */
|
|
68
|
+
variant?:
|
|
69
|
+
| "default"
|
|
70
|
+
| "destructive"
|
|
71
|
+
| "outline"
|
|
72
|
+
| "secondary"
|
|
73
|
+
| "ghost"
|
|
74
|
+
| "link";
|
|
75
|
+
/** Size variant that controls the button's dimensions and padding */
|
|
76
|
+
size?: "default" | "sm" | "lg" | "icon";
|
|
77
|
+
/**
|
|
78
|
+
* Render the button as its child element instead of a button element.
|
|
79
|
+
* Enables composition patterns for creating button-styled links or other elements.
|
|
80
|
+
* When true, all props are forwarded to the child element via Radix UI Slot.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```tsx
|
|
84
|
+
* <Button asChild>
|
|
85
|
+
* <Link href="/dashboard">Dashboard</Link>
|
|
86
|
+
* </Button>
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @default false
|
|
90
|
+
*/
|
|
91
|
+
asChild?: boolean;
|
|
92
|
+
/** Content to display inside the button (text, icons, or React components) */
|
|
93
|
+
children?: React.ReactNode;
|
|
94
|
+
/** Additional CSS classes to apply to the button for custom styling */
|
|
95
|
+
className?: string;
|
|
96
|
+
/** Whether the button is disabled and cannot be interacted with @default false */
|
|
97
|
+
disabled?: boolean;
|
|
98
|
+
/** Button type for form submission behavior @default "button" */
|
|
99
|
+
type?: "button" | "submit" | "reset";
|
|
100
|
+
/** Click handler function called when the button is activated */
|
|
101
|
+
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
102
|
+
/** Focus handler called when the button receives focus */
|
|
103
|
+
onFocus?: React.FocusEventHandler<HTMLButtonElement>;
|
|
104
|
+
/** Blur handler called when the button loses focus */
|
|
105
|
+
onBlur?: React.FocusEventHandler<HTMLButtonElement>;
|
|
106
|
+
/** Mouse enter handler for hover interactions */
|
|
107
|
+
onMouseEnter?: React.MouseEventHandler<HTMLButtonElement>;
|
|
108
|
+
/** Mouse leave handler for hover interactions */
|
|
109
|
+
onMouseLeave?: React.MouseEventHandler<HTMLButtonElement>;
|
|
110
|
+
/** Accessible label for screen readers (required for icon-only buttons) */
|
|
111
|
+
"aria-label"?: string;
|
|
112
|
+
/** Describes the button for screen readers */
|
|
113
|
+
"aria-describedby"?: string;
|
|
114
|
+
/** Indicates invalid state for form validation */
|
|
115
|
+
"aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling";
|
|
116
|
+
/** Indicates expanded state for disclosure buttons */
|
|
117
|
+
"aria-expanded"?: React.AriaAttributes['aria-expanded'];
|
|
118
|
+
/** Associates button with elements it controls */
|
|
119
|
+
"aria-controls"?: string;
|
|
120
|
+
/** Indicates pressed state for toggle buttons */
|
|
121
|
+
"aria-pressed"?: boolean | "false" | "true" | "mixed";
|
|
122
|
+
/** Tab index for focus management @default 0 */
|
|
123
|
+
tabIndex?: number;
|
|
124
|
+
/** Auto focus the button when component mounts @default false */
|
|
125
|
+
autoFocus?: boolean;
|
|
126
|
+
/** Form attribute to associate button with a form element */
|
|
127
|
+
form?: string;
|
|
128
|
+
/** Form action URL or function for submit buttons */
|
|
129
|
+
formAction?: string | ((formData: FormData) => void | Promise<void>);
|
|
130
|
+
/** Form encoding type for submit buttons */
|
|
131
|
+
formEncType?: string;
|
|
132
|
+
/** Form method for submit buttons */
|
|
133
|
+
formMethod?: string;
|
|
134
|
+
/** Form validation bypass for submit buttons @default false */
|
|
135
|
+
formNoValidate?: boolean;
|
|
136
|
+
/** Form target for submit buttons */
|
|
137
|
+
formTarget?: string;
|
|
138
|
+
/** Button name for form submission */
|
|
139
|
+
name?: string;
|
|
140
|
+
/** Button value for form submission */
|
|
141
|
+
value?: string | ReadonlyArray<string> | number;
|
|
142
|
+
} & React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
143
|
+
/** Ref to access the button element */
|
|
144
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Button - A versatile, accessible button component with multiple style variants
|
|
67
149
|
*
|
|
68
|
-
*
|
|
69
|
-
* through
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* styled with proper spacing and sizing.
|
|
150
|
+
* A fundamental UI element built on Radix UI's Slot primitive that supports extensive
|
|
151
|
+
* customization through variants, composition patterns, and comprehensive accessibility
|
|
152
|
+
* features. The component automatically handles icon styling, focus management, form
|
|
153
|
+
* integration, and can be rendered as other elements using the asChild pattern.
|
|
73
154
|
*
|
|
74
|
-
* @component
|
|
75
155
|
* @example
|
|
76
156
|
* ```tsx
|
|
77
|
-
* // Basic usage
|
|
78
|
-
* <Button>
|
|
157
|
+
* // Basic usage with different variants
|
|
158
|
+
* <Button>Default Button</Button>
|
|
159
|
+
* <Button variant="destructive">Delete Item</Button>
|
|
160
|
+
* <Button variant="outline" size="lg">Large Outline</Button>
|
|
161
|
+
* <Button variant="ghost" size="sm">Small Ghost</Button>
|
|
162
|
+
* <Button variant="link">Link Button</Button>
|
|
79
163
|
* ```
|
|
80
164
|
*
|
|
81
165
|
* @example
|
|
82
166
|
* ```tsx
|
|
83
|
-
* //
|
|
84
|
-
*
|
|
85
|
-
* <Button variant="destructive" size="sm">Delete</Button>
|
|
86
|
-
* <Button variant="ghost">Ghost Button</Button>
|
|
87
|
-
* ```
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* ```tsx
|
|
91
|
-
* // With icons (automatically styled)
|
|
92
|
-
* import { Download, ArrowRight, Plus } from "lucide-react";
|
|
167
|
+
* // Icon usage (automatically styled with proper spacing)
|
|
168
|
+
* import { Download, ArrowRight, Plus, Trash2 } from "lucide-react";
|
|
93
169
|
*
|
|
94
170
|
* <Button>
|
|
95
|
-
* <Download /> Download File
|
|
171
|
+
* <Download className="mr-2" /> Download File
|
|
96
172
|
* </Button>
|
|
97
173
|
*
|
|
98
|
-
* <Button>
|
|
99
|
-
* Continue <ArrowRight />
|
|
174
|
+
* <Button variant="outline">
|
|
175
|
+
* Continue <ArrowRight className="ml-2" />
|
|
100
176
|
* </Button>
|
|
101
177
|
*
|
|
102
|
-
* // Icon-only button
|
|
103
|
-
* <Button size="icon" aria-label="Add item">
|
|
178
|
+
* // Icon-only button (always include aria-label)
|
|
179
|
+
* <Button size="icon" aria-label="Add new item">
|
|
104
180
|
* <Plus />
|
|
105
181
|
* </Button>
|
|
182
|
+
*
|
|
183
|
+
* <Button size="icon" variant="destructive" aria-label="Delete item">
|
|
184
|
+
* <Trash2 />
|
|
185
|
+
* </Button>
|
|
106
186
|
* ```
|
|
107
187
|
*
|
|
108
188
|
* @example
|
|
109
189
|
* ```tsx
|
|
110
|
-
* //
|
|
190
|
+
* // Composition with asChild (render as different elements)
|
|
111
191
|
* import Link from "next/link";
|
|
192
|
+
* import { ExternalLink } from "lucide-react";
|
|
112
193
|
*
|
|
113
194
|
* <Button asChild>
|
|
114
195
|
* <Link href="/dashboard">Go to Dashboard</Link>
|
|
115
196
|
* </Button>
|
|
116
197
|
*
|
|
117
198
|
* <Button asChild variant="outline">
|
|
118
|
-
* <a href="https://example.com" target="_blank" rel="noopener">
|
|
119
|
-
* External Link
|
|
199
|
+
* <a href="https://example.com" target="_blank" rel="noopener noreferrer">
|
|
200
|
+
* External Link <ExternalLink className="ml-2 h-4 w-4" />
|
|
120
201
|
* </a>
|
|
121
202
|
* </Button>
|
|
122
203
|
* ```
|
|
@@ -124,53 +205,80 @@ const buttonVariants = cva(
|
|
|
124
205
|
* @example
|
|
125
206
|
* ```tsx
|
|
126
207
|
* // Form integration and states
|
|
127
|
-
* <Button disabled>
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
208
|
+
* <Button type="submit" disabled={isSubmitting}>
|
|
209
|
+
* {isSubmitting ? "Submitting..." : "Submit Form"}
|
|
210
|
+
* </Button>
|
|
211
|
+
*
|
|
212
|
+
* <Button
|
|
213
|
+
* variant="destructive"
|
|
214
|
+
* onClick={() => handleDelete()}
|
|
215
|
+
* aria-describedby="delete-warning"
|
|
216
|
+
* >
|
|
217
|
+
* Delete Account
|
|
218
|
+
* </Button>
|
|
219
|
+
* <p id="delete-warning" className="sr-only">
|
|
220
|
+
* This action cannot be undone
|
|
221
|
+
* </p>
|
|
222
|
+
*
|
|
223
|
+
* // Toggle button with pressed state
|
|
224
|
+
* <Button
|
|
225
|
+
* variant="outline"
|
|
226
|
+
* aria-pressed={isToggled}
|
|
227
|
+
* onClick={() => setIsToggled(!isToggled)}
|
|
228
|
+
* >
|
|
229
|
+
* {isToggled ? "Enabled" : "Disabled"}
|
|
230
|
+
* </Button>
|
|
231
|
+
* ```
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```tsx
|
|
235
|
+
* // Loading states and advanced usage
|
|
236
|
+
* import { Loader2, Save } from "lucide-react";
|
|
237
|
+
*
|
|
238
|
+
* <Button disabled={isLoading}>
|
|
239
|
+
* {isLoading && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
|
240
|
+
* {isLoading ? "Saving..." : "Save Changes"}
|
|
241
|
+
* </Button>
|
|
242
|
+
*
|
|
243
|
+
* // With custom styling
|
|
244
|
+
* <Button
|
|
245
|
+
* className="bg-gradient-to-r from-purple-500 to-pink-500 hover:from-purple-600 hover:to-pink-600"
|
|
246
|
+
* size="lg"
|
|
247
|
+
* >
|
|
248
|
+
* Gradient Button
|
|
135
249
|
* </Button>
|
|
136
250
|
* ```
|
|
137
251
|
*
|
|
138
252
|
* @accessibility
|
|
139
|
-
* -
|
|
140
|
-
* -
|
|
141
|
-
* - Focus visible
|
|
142
|
-
* -
|
|
143
|
-
* -
|
|
144
|
-
* -
|
|
145
|
-
* -
|
|
146
|
-
* -
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
* @
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
*
|
|
253
|
+
* - Full keyboard support (Enter/Space activation, Tab navigation)
|
|
254
|
+
* - ARIA attributes for screen readers (role="button" implicit)
|
|
255
|
+
* - Focus management with visible focus indicators (3px ring)
|
|
256
|
+
* - Disabled state properly communicated to assistive technologies
|
|
257
|
+
* - Support for ARIA states (pressed, expanded, invalid, controls)
|
|
258
|
+
* - Icon-only buttons require aria-label for screen reader users
|
|
259
|
+
* - Form integration with proper submit/reset behavior
|
|
260
|
+
* - High contrast focus indicators that meet WCAG 2.1 AA standards
|
|
261
|
+
* - Respects user's reduced motion preferences in transitions
|
|
262
|
+
* - When using asChild, accessibility is inherited from the child element
|
|
263
|
+
*
|
|
264
|
+
* @variant default - Primary action button with brand colors and subtle shadow
|
|
265
|
+
* @variant destructive - For dangerous actions (delete, remove) with red theming
|
|
266
|
+
* @variant outline - Secondary actions with border and subtle background on hover
|
|
267
|
+
* @variant secondary - Alternative styling with muted background colors
|
|
268
|
+
* @variant ghost - Minimal appearance with hover states, ideal for toolbars
|
|
269
|
+
* @variant link - Appears as a text link with underline on hover
|
|
154
270
|
*
|
|
155
|
-
*
|
|
271
|
+
* @size default - Standard height (36px) suitable for most interfaces
|
|
272
|
+
* @size sm - Compact height (32px) for dense layouts or secondary actions
|
|
273
|
+
* @size lg - Large height (40px) for prominent primary actions
|
|
274
|
+
* @size icon - Square (36px × 36px) optimized for single icons
|
|
275
|
+
*
|
|
276
|
+
* @see {@link buttonVariants} CVA configuration with all styling variants
|
|
277
|
+
* @see {@link https://ui.shadcn.com/docs/components/button} shadcn/ui Button documentation
|
|
278
|
+
* @see {@link https://www.radix-ui.com/primitives/docs/utilities/slot} Radix UI Slot for composition patterns
|
|
279
|
+
* @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/button/} WAI-ARIA Button Pattern
|
|
280
|
+
* @since 1.0.0
|
|
156
281
|
*/
|
|
157
|
-
type ButtonProps = React.ComponentProps<"button"> &
|
|
158
|
-
VariantProps<typeof buttonVariants> & {
|
|
159
|
-
/**
|
|
160
|
-
* If true, the button will render its child element instead of a button element.
|
|
161
|
-
* This enables composition patterns like turning links into buttons.
|
|
162
|
-
*
|
|
163
|
-
* @example
|
|
164
|
-
* ```tsx
|
|
165
|
-
* <Button asChild>
|
|
166
|
-
* <Link href="/dashboard">Dashboard</Link>
|
|
167
|
-
* </Button>
|
|
168
|
-
* ```
|
|
169
|
-
*
|
|
170
|
-
* @default false
|
|
171
|
-
*/
|
|
172
|
-
asChild?: boolean;
|
|
173
|
-
};
|
|
174
282
|
|
|
175
283
|
function Button({
|
|
176
284
|
className,
|
|
@@ -178,7 +286,7 @@ function Button({
|
|
|
178
286
|
size,
|
|
179
287
|
asChild = false,
|
|
180
288
|
...props
|
|
181
|
-
}:
|
|
289
|
+
}: ButtonDocsProps) {
|
|
182
290
|
const Comp = asChild ? Slot : "button";
|
|
183
291
|
|
|
184
292
|
return (
|
|
@@ -192,4 +300,4 @@ function Button({
|
|
|
192
300
|
|
|
193
301
|
Button.displayName = "Button";
|
|
194
302
|
|
|
195
|
-
export { Button, buttonVariants
|
|
303
|
+
export { Button, buttonVariants };
|