@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
|
@@ -5,23 +5,50 @@ import { ChevronDownIcon } from "lucide-react";
|
|
|
5
5
|
|
|
6
6
|
import { cn } from "@/lib/utils";
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Props for NavigationMenu component (Documentation only - NOT used in component implementation)
|
|
10
|
+
* These types are for documentation generation and should not replace Radix inferred types
|
|
11
|
+
*/
|
|
12
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
13
|
+
type NavigationMenuDocsProps = {
|
|
14
|
+
/** The value of the menu item that should be active when initially rendered. Use when not controlling the value state */
|
|
15
|
+
defaultValue?: string;
|
|
16
|
+
/** The controlled value of the menu item that should be active. Should be used in conjunction with onValueChange */
|
|
17
|
+
value?: string;
|
|
18
|
+
/** Event handler called when the value changes */
|
|
19
|
+
onValueChange?: (value: string) => void;
|
|
20
|
+
/** The duration from when the pointer enters the trigger until the tooltip gets opened. @default 200 */
|
|
21
|
+
delayDuration?: number;
|
|
22
|
+
/** How much time a user has to enter another trigger without incurring a delay again. @default 300 */
|
|
23
|
+
skipDelayDuration?: number;
|
|
24
|
+
/** The reading direction when applicable. If omitted, inherits globally from DirectionProvider or assumes LTR */
|
|
25
|
+
dir?: "ltr" | "rtl";
|
|
26
|
+
/** The orientation of the menu. @default "horizontal" */
|
|
27
|
+
orientation?: "horizontal" | "vertical";
|
|
28
|
+
/** Whether to render the navigation viewport container for dropdown content positioning. @default true */
|
|
29
|
+
viewport?: boolean;
|
|
30
|
+
} & React.ComponentProps<"nav">;
|
|
31
|
+
|
|
8
32
|
/**
|
|
9
33
|
* NavigationMenu - A collection of links for navigating websites
|
|
10
34
|
*
|
|
11
|
-
* A
|
|
12
|
-
*
|
|
13
|
-
* keyboard navigation, accessibility compliance,
|
|
35
|
+
* A flexible navigation component built on Radix UI primitives that provides
|
|
36
|
+
* sophisticated navigation patterns with dropdown content support. Features full
|
|
37
|
+
* keyboard navigation, accessibility compliance, controlled/uncontrolled states,
|
|
38
|
+
* and responsive design. Supports both horizontal and vertical orientations.
|
|
14
39
|
*
|
|
15
|
-
* @component
|
|
16
40
|
* @example
|
|
17
41
|
* ```tsx
|
|
18
42
|
* // Basic navigation with dropdown
|
|
19
43
|
* <NavigationMenu>
|
|
20
44
|
* <NavigationMenuList>
|
|
21
|
-
* <NavigationMenuItem>
|
|
45
|
+
* <NavigationMenuItem value="products">
|
|
22
46
|
* <NavigationMenuTrigger>Products</NavigationMenuTrigger>
|
|
23
47
|
* <NavigationMenuContent>
|
|
24
|
-
* <
|
|
48
|
+
* <div className="grid gap-3 p-6 w-[400px]">
|
|
49
|
+
* <NavigationMenuLink href="/products/analytics">Analytics</NavigationMenuLink>
|
|
50
|
+
* <NavigationMenuLink href="/products/dashboard">Dashboard</NavigationMenuLink>
|
|
51
|
+
* </div>
|
|
25
52
|
* </NavigationMenuContent>
|
|
26
53
|
* </NavigationMenuItem>
|
|
27
54
|
* </NavigationMenuList>
|
|
@@ -30,14 +57,35 @@ import { cn } from "@/lib/utils";
|
|
|
30
57
|
*
|
|
31
58
|
* @example
|
|
32
59
|
* ```tsx
|
|
33
|
-
* //
|
|
60
|
+
* // Controlled navigation with state
|
|
61
|
+
* const [value, setValue] = React.useState<string | undefined>();
|
|
62
|
+
*
|
|
63
|
+
* <NavigationMenu value={value} onValueChange={setValue}>
|
|
64
|
+
* <NavigationMenuList>
|
|
65
|
+
* <NavigationMenuItem value="features">
|
|
66
|
+
* <NavigationMenuTrigger>Features</NavigationMenuTrigger>
|
|
67
|
+
* <NavigationMenuContent>
|
|
68
|
+
* <NavigationMenuLink href="/features">All Features</NavigationMenuLink>
|
|
69
|
+
* </NavigationMenuContent>
|
|
70
|
+
* </NavigationMenuItem>
|
|
71
|
+
* </NavigationMenuList>
|
|
72
|
+
* </NavigationMenu>
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```tsx
|
|
77
|
+
* // Simple navigation links without dropdowns
|
|
34
78
|
* <NavigationMenu>
|
|
35
79
|
* <NavigationMenuList>
|
|
36
80
|
* <NavigationMenuItem>
|
|
37
|
-
* <NavigationMenuLink href="/about">
|
|
81
|
+
* <NavigationMenuLink href="/about" className={navigationMenuTriggerStyle()}>
|
|
82
|
+
* About
|
|
83
|
+
* </NavigationMenuLink>
|
|
38
84
|
* </NavigationMenuItem>
|
|
39
85
|
* <NavigationMenuItem>
|
|
40
|
-
* <NavigationMenuLink href="/contact">
|
|
86
|
+
* <NavigationMenuLink href="/contact" className={navigationMenuTriggerStyle()}>
|
|
87
|
+
* Contact
|
|
88
|
+
* </NavigationMenuLink>
|
|
41
89
|
* </NavigationMenuItem>
|
|
42
90
|
* </NavigationMenuList>
|
|
43
91
|
* </NavigationMenu>
|
|
@@ -45,11 +93,11 @@ import { cn } from "@/lib/utils";
|
|
|
45
93
|
*
|
|
46
94
|
* @example
|
|
47
95
|
* ```tsx
|
|
48
|
-
* // With Next.js Link using asChild
|
|
96
|
+
* // With Next.js Link integration using asChild
|
|
49
97
|
* <NavigationMenu>
|
|
50
98
|
* <NavigationMenuList>
|
|
51
99
|
* <NavigationMenuItem>
|
|
52
|
-
* <NavigationMenuLink asChild>
|
|
100
|
+
* <NavigationMenuLink asChild className={navigationMenuTriggerStyle()}>
|
|
53
101
|
* <Link href="/dashboard">Dashboard</Link>
|
|
54
102
|
* </NavigationMenuLink>
|
|
55
103
|
* </NavigationMenuItem>
|
|
@@ -59,14 +107,32 @@ import { cn } from "@/lib/utils";
|
|
|
59
107
|
*
|
|
60
108
|
* @example
|
|
61
109
|
* ```tsx
|
|
62
|
-
* //
|
|
110
|
+
* // Vertical navigation menu
|
|
111
|
+
* <NavigationMenu orientation="vertical">
|
|
112
|
+
* <NavigationMenuList>
|
|
113
|
+
* <NavigationMenuItem value="settings">
|
|
114
|
+
* <NavigationMenuTrigger>Settings</NavigationMenuTrigger>
|
|
115
|
+
* <NavigationMenuContent>
|
|
116
|
+
* <div className="p-4 w-[200px]">
|
|
117
|
+
* <NavigationMenuLink href="/settings/profile">Profile</NavigationMenuLink>
|
|
118
|
+
* <NavigationMenuLink href="/settings/account">Account</NavigationMenuLink>
|
|
119
|
+
* </div>
|
|
120
|
+
* </NavigationMenuContent>
|
|
121
|
+
* </NavigationMenuItem>
|
|
122
|
+
* </NavigationMenuList>
|
|
123
|
+
* </NavigationMenu>
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```tsx
|
|
128
|
+
* // Without viewport for custom dropdown styling
|
|
63
129
|
* <NavigationMenu viewport={false}>
|
|
64
130
|
* <NavigationMenuList>
|
|
65
|
-
* <NavigationMenuItem>
|
|
66
|
-
* <NavigationMenuTrigger>
|
|
131
|
+
* <NavigationMenuItem value="docs">
|
|
132
|
+
* <NavigationMenuTrigger>Documentation</NavigationMenuTrigger>
|
|
67
133
|
* <NavigationMenuContent>
|
|
68
|
-
* <div className="p-
|
|
69
|
-
* <NavigationMenuLink href="/
|
|
134
|
+
* <div className="bg-white border rounded-lg shadow-lg p-6 w-[500px]">
|
|
135
|
+
* <NavigationMenuLink href="/docs/getting-started">Getting Started</NavigationMenuLink>
|
|
70
136
|
* </div>
|
|
71
137
|
* </NavigationMenuContent>
|
|
72
138
|
* </NavigationMenuItem>
|
|
@@ -74,34 +140,55 @@ import { cn } from "@/lib/utils";
|
|
|
74
140
|
* </NavigationMenu>
|
|
75
141
|
* ```
|
|
76
142
|
*
|
|
77
|
-
* @
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```tsx
|
|
145
|
+
* // With custom timing and active indicator
|
|
146
|
+
* <NavigationMenu
|
|
147
|
+
* delayDuration={100}
|
|
148
|
+
* skipDelayDuration={200}
|
|
149
|
+
* defaultValue="home"
|
|
150
|
+
* >
|
|
151
|
+
* <NavigationMenuList>
|
|
152
|
+
* <NavigationMenuItem value="home">
|
|
153
|
+
* <NavigationMenuTrigger>Home</NavigationMenuTrigger>
|
|
154
|
+
* <NavigationMenuContent>
|
|
155
|
+
* <NavigationMenuLink href="/">Homepage</NavigationMenuLink>
|
|
156
|
+
* </NavigationMenuContent>
|
|
157
|
+
* </NavigationMenuItem>
|
|
158
|
+
* <NavigationMenuIndicator />
|
|
159
|
+
* </NavigationMenuList>
|
|
160
|
+
* </NavigationMenu>
|
|
161
|
+
* ```
|
|
85
162
|
*
|
|
163
|
+
* @accessibility
|
|
164
|
+
* - Full keyboard navigation with arrow keys for horizontal/vertical menu traversal
|
|
165
|
+
* - Tab key moves between focusable menu items and maintains logical tab sequence
|
|
166
|
+
* - Escape key closes open dropdown menus and returns focus to trigger
|
|
167
|
+
* - Enter and Space keys activate triggers and follow links
|
|
168
|
+
* - Home/End keys jump to first/last menu items
|
|
169
|
+
* - ARIA expanded/collapsed states automatically managed for triggers
|
|
170
|
+
* - ARIA current="page" support through active prop on links
|
|
171
|
+
* - Focus management with automatic focus trapping in dropdown content
|
|
172
|
+
* - Screen reader announcements for state changes and navigation
|
|
173
|
+
* - Semantic HTML nav structure for navigation landmarks
|
|
174
|
+
* - Proper ARIA labeling and relationships between triggers and content
|
|
175
|
+
*
|
|
176
|
+
* @see {@link NavigationMenuList} Container for menu items
|
|
177
|
+
* @see {@link NavigationMenuItem} Individual menu item wrapper
|
|
178
|
+
* @see {@link NavigationMenuTrigger} Dropdown trigger button
|
|
179
|
+
* @see {@link NavigationMenuContent} Dropdown content panel
|
|
180
|
+
* @see {@link NavigationMenuLink} Navigation link component
|
|
86
181
|
* @see {@link https://ui.shadcn.com/docs/components/navigation-menu} shadcn/ui Navigation Menu
|
|
87
182
|
* @see {@link https://www.radix-ui.com/primitives/docs/components/navigation-menu} Radix UI Navigation Menu
|
|
88
183
|
* @since 1.0.0
|
|
89
184
|
*/
|
|
90
|
-
/**
|
|
91
|
-
* Main NavigationMenu component props
|
|
92
|
-
*
|
|
93
|
-
* @param viewport - Whether to render the navigation viewport container. Defaults to true.
|
|
94
|
-
* Set to false for simpler dropdown styling without viewport positioning.
|
|
95
|
-
* @param className - Additional CSS classes to apply to the navigation menu root
|
|
96
|
-
* @param children - NavigationMenuList and NavigationMenuViewport components
|
|
97
|
-
*/
|
|
98
185
|
function NavigationMenu({
|
|
99
186
|
className,
|
|
100
187
|
children,
|
|
101
188
|
viewport = true,
|
|
102
189
|
...props
|
|
103
190
|
}: React.ComponentProps<typeof NavigationMenuPrimitive.Root> & {
|
|
104
|
-
/** Whether to render the navigation viewport container for dropdown positioning */
|
|
191
|
+
/** Whether to render the navigation viewport container for dropdown content positioning. @default true */
|
|
105
192
|
viewport?: boolean;
|
|
106
193
|
}) {
|
|
107
194
|
return (
|
|
@@ -120,26 +207,60 @@ function NavigationMenu({
|
|
|
120
207
|
);
|
|
121
208
|
}
|
|
122
209
|
|
|
210
|
+
/**
|
|
211
|
+
* Props for NavigationMenuList component (Documentation only - NOT used in component implementation)
|
|
212
|
+
* These types are for documentation generation and should not replace Radix inferred types
|
|
213
|
+
*/
|
|
214
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
215
|
+
type NavigationMenuListDocsProps = {
|
|
216
|
+
/** Change the default rendered element for the one passed as a child, merging their props and behavior */
|
|
217
|
+
asChild?: boolean;
|
|
218
|
+
} & React.ComponentProps<"ul">;
|
|
219
|
+
|
|
123
220
|
/**
|
|
124
221
|
* NavigationMenuList - Container for navigation menu items
|
|
125
222
|
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
223
|
+
* The list container that groups NavigationMenuItem components within a NavigationMenu.
|
|
224
|
+
* Renders as an unordered list (ul) by default and provides the foundational layout
|
|
225
|
+
* structure for the navigation menu. Supports both horizontal and vertical orientations
|
|
226
|
+
* based on the parent NavigationMenu orientation prop.
|
|
128
227
|
*
|
|
129
|
-
* @component
|
|
130
228
|
* @example
|
|
131
229
|
* ```tsx
|
|
132
230
|
* <NavigationMenuList>
|
|
133
|
-
* <NavigationMenuItem>
|
|
134
|
-
* <
|
|
231
|
+
* <NavigationMenuItem value="products">
|
|
232
|
+
* <NavigationMenuTrigger>Products</NavigationMenuTrigger>
|
|
233
|
+
* <NavigationMenuContent>
|
|
234
|
+
* <NavigationMenuLink href="/products">All Products</NavigationMenuLink>
|
|
235
|
+
* </NavigationMenuContent>
|
|
135
236
|
* </NavigationMenuItem>
|
|
136
237
|
* <NavigationMenuItem>
|
|
137
|
-
* <NavigationMenuLink href="/about">
|
|
238
|
+
* <NavigationMenuLink href="/about" className={navigationMenuTriggerStyle()}>
|
|
239
|
+
* About
|
|
240
|
+
* </NavigationMenuLink>
|
|
138
241
|
* </NavigationMenuItem>
|
|
139
242
|
* </NavigationMenuList>
|
|
140
243
|
* ```
|
|
141
244
|
*
|
|
142
|
-
* @
|
|
245
|
+
* @example
|
|
246
|
+
* ```tsx
|
|
247
|
+
* // Custom list element using asChild
|
|
248
|
+
* <NavigationMenuList asChild>
|
|
249
|
+
* <div className="custom-nav-container">
|
|
250
|
+
* <NavigationMenuItem>
|
|
251
|
+
* <NavigationMenuLink href="/home">Home</NavigationMenuLink>
|
|
252
|
+
* </NavigationMenuItem>
|
|
253
|
+
* </div>
|
|
254
|
+
* </NavigationMenuList>
|
|
255
|
+
* ```
|
|
256
|
+
*
|
|
257
|
+
* @accessibility
|
|
258
|
+
* - Renders as semantic ul element by default for proper list structure
|
|
259
|
+
* - Maintains proper ARIA relationships with contained NavigationMenuItem elements
|
|
260
|
+
* - Supports keyboard navigation between contained items
|
|
261
|
+
*
|
|
262
|
+
* @see {@link NavigationMenuItem} Individual menu item containers
|
|
263
|
+
* @see {@link NavigationMenu} Parent navigation menu component
|
|
143
264
|
* @since 1.0.0
|
|
144
265
|
*/
|
|
145
266
|
function NavigationMenuList({
|
|
@@ -158,34 +279,70 @@ function NavigationMenuList({
|
|
|
158
279
|
);
|
|
159
280
|
}
|
|
160
281
|
|
|
282
|
+
/**
|
|
283
|
+
* Props for NavigationMenuItem component (Documentation only - NOT used in component implementation)
|
|
284
|
+
* These types are for documentation generation and should not replace Radix inferred types
|
|
285
|
+
*/
|
|
286
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
287
|
+
type NavigationMenuItemDocsProps = {
|
|
288
|
+
/** A unique value that associates the item with an active value when controlled or defaultValue when uncontrolled */
|
|
289
|
+
value?: string;
|
|
290
|
+
/** Change the default rendered element for the one passed as a child, merging their props and behavior */
|
|
291
|
+
asChild?: boolean;
|
|
292
|
+
} & React.ComponentProps<"li">;
|
|
293
|
+
|
|
161
294
|
/**
|
|
162
295
|
* NavigationMenuItem - Individual navigation menu item container
|
|
163
296
|
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
297
|
+
* A list item container that wraps a single navigation element within a NavigationMenuList.
|
|
298
|
+
* Each item can contain either a NavigationMenuTrigger with NavigationMenuContent for dropdown
|
|
299
|
+
* functionality, or a NavigationMenuLink for direct navigation. The value prop is used for
|
|
300
|
+
* controlled state management and active item tracking.
|
|
167
301
|
*
|
|
168
|
-
* @component
|
|
169
302
|
* @example
|
|
170
303
|
* ```tsx
|
|
171
|
-
* //
|
|
172
|
-
* <NavigationMenuItem>
|
|
304
|
+
* // Dropdown navigation item with controlled value
|
|
305
|
+
* <NavigationMenuItem value="products">
|
|
173
306
|
* <NavigationMenuTrigger>Products</NavigationMenuTrigger>
|
|
174
307
|
* <NavigationMenuContent>
|
|
175
|
-
* <
|
|
308
|
+
* <div className="grid gap-3 p-6 w-[400px] grid-cols-2">
|
|
309
|
+
* <NavigationMenuLink href="/products/analytics">Analytics</NavigationMenuLink>
|
|
310
|
+
* <NavigationMenuLink href="/products/dashboard">Dashboard</NavigationMenuLink>
|
|
311
|
+
* </div>
|
|
176
312
|
* </NavigationMenuContent>
|
|
177
313
|
* </NavigationMenuItem>
|
|
178
314
|
* ```
|
|
179
315
|
*
|
|
180
316
|
* @example
|
|
181
317
|
* ```tsx
|
|
182
|
-
* // Simple link
|
|
318
|
+
* // Simple navigation link item
|
|
183
319
|
* <NavigationMenuItem>
|
|
184
|
-
* <NavigationMenuLink href="/contact">
|
|
320
|
+
* <NavigationMenuLink href="/contact" className={navigationMenuTriggerStyle()}>
|
|
321
|
+
* Contact Us
|
|
322
|
+
* </NavigationMenuLink>
|
|
185
323
|
* </NavigationMenuItem>
|
|
186
324
|
* ```
|
|
187
325
|
*
|
|
188
|
-
* @
|
|
326
|
+
* @example
|
|
327
|
+
* ```tsx
|
|
328
|
+
* // With custom container element using asChild
|
|
329
|
+
* <NavigationMenuItem asChild>
|
|
330
|
+
* <div className="custom-menu-item">
|
|
331
|
+
* <NavigationMenuLink href="/about">About</NavigationMenuLink>
|
|
332
|
+
* </div>
|
|
333
|
+
* </NavigationMenuItem>
|
|
334
|
+
* ```
|
|
335
|
+
*
|
|
336
|
+
* @accessibility
|
|
337
|
+
* - Renders as semantic li element by default for proper list item structure
|
|
338
|
+
* - Associates with parent NavigationMenu state through value prop
|
|
339
|
+
* - Maintains focus management within navigation sequences
|
|
340
|
+
* - Supports both direct links and trigger/content dropdown patterns
|
|
341
|
+
*
|
|
342
|
+
* @see {@link NavigationMenuTrigger} Dropdown trigger button
|
|
343
|
+
* @see {@link NavigationMenuContent} Dropdown content panel
|
|
344
|
+
* @see {@link NavigationMenuLink} Navigation link component
|
|
345
|
+
* @see {@link NavigationMenuList} Parent list container
|
|
189
346
|
* @since 1.0.0
|
|
190
347
|
*/
|
|
191
348
|
function NavigationMenuItem({
|
|
@@ -201,39 +358,94 @@ function NavigationMenuItem({
|
|
|
201
358
|
);
|
|
202
359
|
}
|
|
203
360
|
|
|
361
|
+
/**
|
|
362
|
+
* Navigation menu trigger styling configuration using CVA (Class Variance Authority)
|
|
363
|
+
*
|
|
364
|
+
* Provides consistent button styling for navigation triggers with interactive states.
|
|
365
|
+
* Can be applied to NavigationMenuLink components for uniform trigger-style appearance.
|
|
366
|
+
*
|
|
367
|
+
* @variant base - Default trigger button styling with hover, focus, and disabled states
|
|
368
|
+
* - Interactive states: hover (accent background), focus (accent + ring), disabled (opacity + pointer-events)
|
|
369
|
+
* - Open state: Special styling when dropdown is open (accent background with opacity)
|
|
370
|
+
* - Focus visible: Ring indicator for keyboard navigation accessibility
|
|
371
|
+
*
|
|
372
|
+
* @example
|
|
373
|
+
* ```tsx
|
|
374
|
+
* // Apply to NavigationMenuLink for consistent button styling
|
|
375
|
+
* <NavigationMenuLink href="/docs" className={navigationMenuTriggerStyle()}>
|
|
376
|
+
* Documentation
|
|
377
|
+
* </NavigationMenuLink>
|
|
378
|
+
* ```
|
|
379
|
+
*
|
|
380
|
+
* @see {@link NavigationMenuTrigger} Uses this styling automatically
|
|
381
|
+
* @see {@link NavigationMenuLink} Can use this for consistent trigger appearance
|
|
382
|
+
*/
|
|
204
383
|
const navigationMenuTriggerStyle = cva(
|
|
205
384
|
"group inline-flex h-9 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=open]:hover:bg-accent data-[state=open]:text-accent-foreground data-[state=open]:focus:bg-accent data-[state=open]:bg-accent/50 focus-visible:ring-ring/50 outline-none transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1",
|
|
206
385
|
);
|
|
207
386
|
|
|
208
387
|
/**
|
|
209
|
-
* NavigationMenuTrigger -
|
|
388
|
+
* Props for NavigationMenuTrigger component (Documentation only - NOT used in component implementation)
|
|
389
|
+
* These types are for documentation generation and should not replace Radix inferred types
|
|
390
|
+
*/
|
|
391
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
392
|
+
type NavigationMenuTriggerDocsProps = {
|
|
393
|
+
/** Change the default rendered element for the one passed as a child, merging their props and behavior */
|
|
394
|
+
asChild?: boolean;
|
|
395
|
+
} & React.ComponentProps<"button">;
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* NavigationMenuTrigger - Interactive button that opens dropdown navigation content
|
|
210
399
|
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
400
|
+
* A button component that toggles NavigationMenuContent visibility when activated.
|
|
401
|
+
* Automatically includes a chevron down icon that rotates when the dropdown is open.
|
|
402
|
+
* Features comprehensive keyboard and mouse interaction support with proper ARIA
|
|
403
|
+
* state management. The asChild prop allows composition with custom button components.
|
|
214
404
|
*
|
|
215
|
-
* @component
|
|
216
405
|
* @example
|
|
217
406
|
* ```tsx
|
|
218
|
-
*
|
|
407
|
+
* // Basic trigger with dropdown content
|
|
408
|
+
* <NavigationMenuItem value="products">
|
|
409
|
+
* <NavigationMenuTrigger>Products</NavigationMenuTrigger>
|
|
410
|
+
* <NavigationMenuContent>
|
|
411
|
+
* <div className="p-6 w-[400px]">
|
|
412
|
+
* <NavigationMenuLink href="/products/analytics">Analytics</NavigationMenuLink>
|
|
413
|
+
* <NavigationMenuLink href="/products/dashboard">Dashboard</NavigationMenuLink>
|
|
414
|
+
* </div>
|
|
415
|
+
* </NavigationMenuContent>
|
|
416
|
+
* </NavigationMenuItem>
|
|
219
417
|
* ```
|
|
220
418
|
*
|
|
221
419
|
* @example
|
|
222
420
|
* ```tsx
|
|
223
|
-
* //
|
|
421
|
+
* // Custom trigger styling with asChild
|
|
224
422
|
* <NavigationMenuTrigger asChild>
|
|
225
|
-
* <Button variant="outline"
|
|
423
|
+
* <Button variant="outline" size="lg">
|
|
424
|
+
* Custom Features Button
|
|
425
|
+
* </Button>
|
|
226
426
|
* </NavigationMenuTrigger>
|
|
227
427
|
* ```
|
|
228
428
|
*
|
|
229
|
-
* @
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
* -
|
|
233
|
-
* -
|
|
429
|
+
* @example
|
|
430
|
+
* ```tsx
|
|
431
|
+
* // Trigger with additional icons
|
|
432
|
+
* <NavigationMenuTrigger className="gap-2">
|
|
433
|
+
* <StarIcon className="size-4" />
|
|
434
|
+
* Featured Items
|
|
435
|
+
* </NavigationMenuTrigger>
|
|
436
|
+
* ```
|
|
234
437
|
*
|
|
235
|
-
* @
|
|
236
|
-
*
|
|
438
|
+
* @accessibility
|
|
439
|
+
* - Automatic ARIA expanded state management (expanded="true/false")
|
|
440
|
+
* - Button role with proper keyboard activation (Enter/Space keys)
|
|
441
|
+
* - Focus visible ring indicator for keyboard navigation
|
|
442
|
+
* - Screen reader accessible button semantics and state announcements
|
|
443
|
+
* - Disabled state handling with pointer-events and opacity
|
|
444
|
+
* - Chevron icon marked as aria-hidden for screen reader exclusion
|
|
445
|
+
*
|
|
446
|
+
* @see {@link NavigationMenuContent} Content panel this trigger controls
|
|
447
|
+
* @see {@link NavigationMenuItem} Required parent container
|
|
448
|
+
* @see {@link navigationMenuTriggerStyle} Styling function used internally
|
|
237
449
|
* @since 1.0.0
|
|
238
450
|
*/
|
|
239
451
|
function NavigationMenuTrigger({
|
|
@@ -257,43 +469,109 @@ function NavigationMenuTrigger({
|
|
|
257
469
|
}
|
|
258
470
|
|
|
259
471
|
/**
|
|
260
|
-
* NavigationMenuContent -
|
|
472
|
+
* Props for NavigationMenuContent component (Documentation only - NOT used in component implementation)
|
|
473
|
+
* These types are for documentation generation and should not replace Radix inferred types
|
|
474
|
+
*/
|
|
475
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
476
|
+
type NavigationMenuContentDocsProps = {
|
|
477
|
+
/** Change the default rendered element for the one passed as a child, merging their props and behavior */
|
|
478
|
+
asChild?: boolean;
|
|
479
|
+
/** Used to force mounting when more control is needed. Useful when controlling animation with external libraries */
|
|
480
|
+
forceMount?: boolean;
|
|
481
|
+
/** Event handler called when the escape key is down. Can be prevented by calling event.preventDefault */
|
|
482
|
+
onEscapeKeyDown?: (event: KeyboardEvent) => void;
|
|
483
|
+
/** Event handler called when a pointer event occurs outside the bounds of the component. Can be prevented by calling event.preventDefault */
|
|
484
|
+
onPointerDownOutside?: (event: PointerEvent) => void;
|
|
485
|
+
/** Event handler called when focus moves outside the bounds of the component. Can be prevented by calling event.preventDefault */
|
|
486
|
+
onFocusOutside?: (event: FocusEvent) => void;
|
|
487
|
+
/** Event handler called when an interaction (pointer or focus) happens outside the component. Can be prevented by calling event.preventDefault */
|
|
488
|
+
onInteractOutside?: (event: PointerEvent | FocusEvent) => void;
|
|
489
|
+
} & React.ComponentProps<"div">;
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* NavigationMenuContent - Dropdown content panel for navigation items
|
|
261
493
|
*
|
|
262
|
-
* The content container that appears when a NavigationMenuTrigger is activated.
|
|
263
|
-
* Supports enter/exit animations,
|
|
264
|
-
*
|
|
494
|
+
* The collapsible content container that appears when a NavigationMenuTrigger is activated.
|
|
495
|
+
* Supports smooth enter/exit animations, flexible positioning (with or without viewport),
|
|
496
|
+
* and comprehensive interaction handling. The content automatically manages focus and
|
|
497
|
+
* provides multiple ways to dismiss the dropdown (Escape key, outside clicks, etc.).
|
|
265
498
|
*
|
|
266
|
-
* @component
|
|
267
499
|
* @example
|
|
268
500
|
* ```tsx
|
|
501
|
+
* // Grid layout with navigation links
|
|
269
502
|
* <NavigationMenuContent>
|
|
270
|
-
* <div className="grid gap-3 p-6 w-[
|
|
271
|
-
* <NavigationMenuLink href="/
|
|
272
|
-
*
|
|
503
|
+
* <div className="grid gap-3 p-6 w-[500px] grid-cols-2">
|
|
504
|
+
* <NavigationMenuLink href="/products/analytics">
|
|
505
|
+
* <div className="text-sm font-medium">Analytics</div>
|
|
506
|
+
* <p className="text-sm text-muted-foreground">Track your performance</p>
|
|
507
|
+
* </NavigationMenuLink>
|
|
508
|
+
* <NavigationMenuLink href="/products/dashboard">
|
|
509
|
+
* <div className="text-sm font-medium">Dashboard</div>
|
|
510
|
+
* <p className="text-sm text-muted-foreground">Manage your data</p>
|
|
511
|
+
* </NavigationMenuLink>
|
|
273
512
|
* </div>
|
|
274
513
|
* </NavigationMenuContent>
|
|
275
514
|
* ```
|
|
276
515
|
*
|
|
277
516
|
* @example
|
|
278
517
|
* ```tsx
|
|
279
|
-
* // Complex layout
|
|
518
|
+
* // Complex multi-column layout
|
|
280
519
|
* <NavigationMenuContent>
|
|
281
|
-
* <div className="grid gap-6 p-
|
|
282
|
-
* <div>
|
|
283
|
-
* <h4>
|
|
284
|
-
* <NavigationMenuLink href="/
|
|
520
|
+
* <div className="grid gap-6 p-8 w-[800px] grid-cols-3">
|
|
521
|
+
* <div className="space-y-2">
|
|
522
|
+
* <h4 className="text-sm font-medium">Features</h4>
|
|
523
|
+
* <NavigationMenuLink href="/features/auth">Authentication</NavigationMenuLink>
|
|
524
|
+
* <NavigationMenuLink href="/features/api">API Management</NavigationMenuLink>
|
|
525
|
+
* </div>
|
|
526
|
+
* <div className="space-y-2">
|
|
527
|
+
* <h4 className="text-sm font-medium">Tools</h4>
|
|
528
|
+
* <NavigationMenuLink href="/tools/cli">Command Line</NavigationMenuLink>
|
|
529
|
+
* <NavigationMenuLink href="/tools/sdk">SDK</NavigationMenuLink>
|
|
285
530
|
* </div>
|
|
286
531
|
* </div>
|
|
287
532
|
* </NavigationMenuContent>
|
|
288
533
|
* ```
|
|
289
534
|
*
|
|
290
|
-
* @
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
535
|
+
* @example
|
|
536
|
+
* ```tsx
|
|
537
|
+
* // With custom interaction handlers
|
|
538
|
+
* <NavigationMenuContent
|
|
539
|
+
* onEscapeKeyDown={(e) => {
|
|
540
|
+
* console.log('Escape pressed');
|
|
541
|
+
* // Don't prevent default to allow normal closing behavior
|
|
542
|
+
* }}
|
|
543
|
+
* onPointerDownOutside={(e) => {
|
|
544
|
+
* console.log('Clicked outside');
|
|
545
|
+
* // e.preventDefault() would prevent closing
|
|
546
|
+
* }}
|
|
547
|
+
* >
|
|
548
|
+
* <div className="p-6 w-[300px]">
|
|
549
|
+
* <NavigationMenuLink href="/help">Help Center</NavigationMenuLink>
|
|
550
|
+
* </div>
|
|
551
|
+
* </NavigationMenuContent>
|
|
552
|
+
* ```
|
|
294
553
|
*
|
|
295
|
-
* @
|
|
296
|
-
*
|
|
554
|
+
* @example
|
|
555
|
+
* ```tsx
|
|
556
|
+
* // Force mounted for animation control
|
|
557
|
+
* <NavigationMenuContent forceMount>
|
|
558
|
+
* <div className="p-4 w-[250px] animate-in slide-in-from-top">
|
|
559
|
+
* <NavigationMenuLink href="/docs">Documentation</NavigationMenuLink>
|
|
560
|
+
* </div>
|
|
561
|
+
* </NavigationMenuContent>
|
|
562
|
+
* ```
|
|
563
|
+
*
|
|
564
|
+
* @accessibility
|
|
565
|
+
* - Automatic focus management when content opens and closes
|
|
566
|
+
* - Escape key support for dismissing dropdown (can be customized via onEscapeKeyDown)
|
|
567
|
+
* - Outside interaction handling for dismissing (clicks and focus outside)
|
|
568
|
+
* - Proper ARIA relationships with trigger button
|
|
569
|
+
* - Content is accessible via keyboard navigation within the dropdown
|
|
570
|
+
* - Screen reader announcements for state changes
|
|
571
|
+
*
|
|
572
|
+
* @see {@link NavigationMenuTrigger} Button that controls this content
|
|
573
|
+
* @see {@link NavigationMenuLink} Links typically used within content
|
|
574
|
+
* @see {@link NavigationMenuViewport} Viewport container for positioning
|
|
297
575
|
* @since 1.0.0
|
|
298
576
|
*/
|
|
299
577
|
function NavigationMenuContent({
|
|
@@ -305,7 +583,7 @@ function NavigationMenuContent({
|
|
|
305
583
|
data-slot="navigation-menu-content"
|
|
306
584
|
className={cn(
|
|
307
585
|
"data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 top-0 left-0 w-full p-2 pr-2.5 md:absolute md:w-auto",
|
|
308
|
-
"group-data-[viewport=false]/navigation-menu:bg-popover group-data-[viewport=false]/navigation-menu:text-popover-foreground group-data-[viewport=false]/navigation-menu:data-[state=open]:animate-in group-data-[viewport=false]/navigation-menu:data-[state=closed]:animate-out group-data-[viewport=false]/navigation-menu:data-[state=closed]:zoom-out-95 group-data-[viewport=false]/navigation-menu:data-[state=open]:zoom-in-95 group-data-[viewport=false]/navigation-menu:data-[state=open]:fade-in-0 group-data-[viewport=false]/navigation-menu:data-[state=closed]:fade-out-0 group-data-[viewport=false]/navigation-menu:top-full group-data-[viewport=false]/navigation-menu:mt-1.5 group-data-[viewport=false]/navigation-menu:overflow-hidden group-data-[viewport=false]/navigation-menu:rounded-md group-data-[viewport=false]/navigation-menu:border group-data-[viewport=false]/navigation-menu:shadow group-data-[viewport=false]/navigation-menu:duration-200
|
|
586
|
+
"group-data-[viewport=false]/navigation-menu:bg-popover group-data-[viewport=false]/navigation-menu:text-popover-foreground group-data-[viewport=false]/navigation-menu:data-[state=open]:animate-in group-data-[viewport=false]/navigation-menu:data-[state=closed]:animate-out group-data-[viewport=false]/navigation-menu:data-[state=closed]:zoom-out-95 group-data-[viewport=false]/navigation-menu:data-[state=open]:zoom-in-95 group-data-[viewport=false]/navigation-menu:data-[state=open]:fade-in-0 group-data-[viewport=false]/navigation-menu:data-[state=closed]:fade-out-0 group-data-[viewport=false]/navigation-menu:top-full group-data-[viewport=false]/navigation-menu:mt-1.5 group-data-[viewport=false]/navigation-menu:overflow-hidden group-data-[viewport=false]/navigation-menu:rounded-md group-data-[viewport=false]/navigation-menu:border group-data-[viewport=false]/navigation-menu:shadow group-data-[viewport=false]/navigation-menu:duration-200 [&_[data-slot=navigation-menu-link]]:focus:ring-0 [&_[data-slot=navigation-menu-link]]:focus:outline-none",
|
|
309
587
|
className,
|
|
310
588
|
)}
|
|
311
589
|
{...props}
|
|
@@ -314,20 +592,56 @@ function NavigationMenuContent({
|
|
|
314
592
|
}
|
|
315
593
|
|
|
316
594
|
/**
|
|
317
|
-
* NavigationMenuViewport -
|
|
595
|
+
* Props for NavigationMenuViewport component (Documentation only - NOT used in component implementation)
|
|
596
|
+
* These types are for documentation generation and should not replace Radix inferred types
|
|
597
|
+
*/
|
|
598
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
599
|
+
type NavigationMenuViewportDocsProps = {
|
|
600
|
+
/** Change the default rendered element for the one passed as a child, merging their props and behavior */
|
|
601
|
+
asChild?: boolean;
|
|
602
|
+
/** Used to force mounting when more control is needed. Useful when controlling animation with external libraries */
|
|
603
|
+
forceMount?: boolean;
|
|
604
|
+
} & React.ComponentProps<"div">;
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* NavigationMenuViewport - Positioned container for dropdown content
|
|
318
608
|
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
* enter/exit animations.
|
|
609
|
+
* The viewport container that manages positioning, sizing, and animation of NavigationMenuContent
|
|
610
|
+
* panels. It automatically calculates dimensions based on content size and provides smooth
|
|
611
|
+
* enter/exit animations. The viewport uses CSS custom properties for dynamic sizing and
|
|
612
|
+
* positioning. Only rendered when the viewport prop is true (default) on NavigationMenu.
|
|
613
|
+
*
|
|
614
|
+
* @example
|
|
615
|
+
* ```tsx
|
|
616
|
+
* // Typically used automatically by NavigationMenu
|
|
617
|
+
* <NavigationMenu>
|
|
618
|
+
* <NavigationMenuList>
|
|
619
|
+
* // menu items
|
|
620
|
+
* </NavigationMenuList>
|
|
621
|
+
* // NavigationMenuViewport is rendered automatically
|
|
622
|
+
* </NavigationMenu>
|
|
623
|
+
* ```
|
|
322
624
|
*
|
|
323
|
-
* @
|
|
324
|
-
*
|
|
625
|
+
* @example
|
|
626
|
+
* ```tsx
|
|
627
|
+
* // Custom viewport styling
|
|
628
|
+
* <NavigationMenuViewport className="border-2 border-primary shadow-xl" />
|
|
629
|
+
* ```
|
|
630
|
+
*
|
|
631
|
+
* @example
|
|
632
|
+
* ```tsx
|
|
633
|
+
* // Force mounted viewport for animation control
|
|
634
|
+
* <NavigationMenuViewport forceMount className="custom-animation" />
|
|
635
|
+
* ```
|
|
325
636
|
*
|
|
326
637
|
* @accessibility
|
|
327
|
-
* - Handles focus containment for dropdown content
|
|
328
|
-
* - Manages viewport announcements for screen readers
|
|
638
|
+
* - Handles focus containment for dropdown content within the viewport
|
|
639
|
+
* - Manages viewport size announcements for screen readers
|
|
640
|
+
* - Provides proper z-index layering for dropdown content
|
|
641
|
+
* - Maintains content visibility and accessibility during animations
|
|
329
642
|
*
|
|
330
|
-
* @
|
|
643
|
+
* @see {@link NavigationMenu} Parent component that controls viewport rendering
|
|
644
|
+
* @see {@link NavigationMenuContent} Content rendered within this viewport
|
|
331
645
|
* @since 1.0.0
|
|
332
646
|
*/
|
|
333
647
|
function NavigationMenuViewport({
|
|
@@ -352,54 +666,120 @@ function NavigationMenuViewport({
|
|
|
352
666
|
);
|
|
353
667
|
}
|
|
354
668
|
|
|
669
|
+
/**
|
|
670
|
+
* Props for NavigationMenuLink component (Documentation only - NOT used in component implementation)
|
|
671
|
+
* These types are for documentation generation and should not replace Radix inferred types
|
|
672
|
+
*/
|
|
673
|
+
type NavigationMenuLinkDocsProps = {
|
|
674
|
+
/** Change the default rendered element for the one passed as a child, merging their props and behavior */
|
|
675
|
+
asChild?: boolean;
|
|
676
|
+
/** Whether the link is currently active/selected. Used for highlighting current page @default false */
|
|
677
|
+
active?: boolean;
|
|
678
|
+
/** Event handler called when the link is selected (clicked or activated) */
|
|
679
|
+
onSelect?: (event: Event) => void;
|
|
680
|
+
} & React.ComponentProps<"a">;
|
|
681
|
+
|
|
355
682
|
/**
|
|
356
683
|
* NavigationMenuLink - Styled link component for navigation menus
|
|
357
684
|
*
|
|
358
|
-
* A link component designed specifically for navigation menus
|
|
359
|
-
* states, hover effects, and
|
|
360
|
-
* Can be used both within dropdown
|
|
685
|
+
* A versatile link component designed specifically for navigation menus with comprehensive
|
|
686
|
+
* styling and state management. Supports active states, hover/focus effects, and seamless
|
|
687
|
+
* framework integration through the asChild pattern. Can be used both within dropdown
|
|
688
|
+
* content and as direct navigation items. Features proper keyboard navigation and
|
|
689
|
+
* accessibility support.
|
|
361
690
|
*
|
|
362
|
-
* @component
|
|
363
691
|
* @example
|
|
364
692
|
* ```tsx
|
|
365
|
-
* //
|
|
693
|
+
* // Basic navigation link
|
|
366
694
|
* <NavigationMenuLink href="/about">About Us</NavigationMenuLink>
|
|
367
695
|
* ```
|
|
368
696
|
*
|
|
369
697
|
* @example
|
|
370
698
|
* ```tsx
|
|
371
|
-
* //
|
|
699
|
+
* // Active link with current page styling
|
|
700
|
+
* <NavigationMenuLink href="/dashboard" active>
|
|
701
|
+
* Dashboard
|
|
702
|
+
* </NavigationMenuLink>
|
|
703
|
+
* ```
|
|
704
|
+
*
|
|
705
|
+
* @example
|
|
706
|
+
* ```tsx
|
|
707
|
+
* // Rich content link in dropdown with description
|
|
708
|
+
* <NavigationMenuLink href="/features/analytics">
|
|
709
|
+
* <div className="text-sm font-medium leading-none">Analytics</div>
|
|
710
|
+
* <p className="text-sm text-muted-foreground mt-1">
|
|
711
|
+
* View detailed insights and performance metrics
|
|
712
|
+
* </p>
|
|
713
|
+
* </NavigationMenuLink>
|
|
714
|
+
* ```
|
|
715
|
+
*
|
|
716
|
+
* @example
|
|
717
|
+
* ```tsx
|
|
718
|
+
* // With Next.js Link using asChild pattern
|
|
372
719
|
* <NavigationMenuLink asChild>
|
|
373
|
-
* <Link href="/products">
|
|
720
|
+
* <Link href="/products" prefetch={false}>
|
|
721
|
+
* Products
|
|
722
|
+
* </Link>
|
|
374
723
|
* </NavigationMenuLink>
|
|
375
724
|
* ```
|
|
376
725
|
*
|
|
377
726
|
* @example
|
|
378
727
|
* ```tsx
|
|
379
|
-
* //
|
|
380
|
-
* <NavigationMenuLink
|
|
381
|
-
* <
|
|
382
|
-
*
|
|
728
|
+
* // With Remix Link using asChild pattern
|
|
729
|
+
* <NavigationMenuLink asChild>
|
|
730
|
+
* <RemixLink to="/docs" prefetch="intent">
|
|
731
|
+
* Documentation
|
|
732
|
+
* </RemixLink>
|
|
383
733
|
* </NavigationMenuLink>
|
|
384
734
|
* ```
|
|
385
735
|
*
|
|
386
736
|
* @example
|
|
387
737
|
* ```tsx
|
|
388
|
-
* //
|
|
389
|
-
* <NavigationMenuLink
|
|
390
|
-
*
|
|
738
|
+
* // Direct navigation with trigger button styling
|
|
739
|
+
* <NavigationMenuLink
|
|
740
|
+
* href="/contact"
|
|
741
|
+
* className={navigationMenuTriggerStyle()}
|
|
742
|
+
* >
|
|
743
|
+
* Contact Us
|
|
744
|
+
* </NavigationMenuLink>
|
|
745
|
+
* ```
|
|
746
|
+
*
|
|
747
|
+
* @example
|
|
748
|
+
* ```tsx
|
|
749
|
+
* // With custom selection handler
|
|
750
|
+
* <NavigationMenuLink
|
|
751
|
+
* href="/logout"
|
|
752
|
+
* onSelect={(event) => {
|
|
753
|
+
* event.preventDefault();
|
|
754
|
+
* handleLogout();
|
|
755
|
+
* }}
|
|
756
|
+
* >
|
|
757
|
+
* Sign Out
|
|
758
|
+
* </NavigationMenuLink>
|
|
759
|
+
* ```
|
|
760
|
+
*
|
|
761
|
+
* @example
|
|
762
|
+
* ```tsx
|
|
763
|
+
* // External link with icon
|
|
764
|
+
* <NavigationMenuLink href="https://github.com" target="_blank" rel="noopener">
|
|
765
|
+
* <GitHubIcon className="size-4" />
|
|
766
|
+
* GitHub
|
|
767
|
+
* <ExternalLinkIcon className="size-3 ml-auto" />
|
|
391
768
|
* </NavigationMenuLink>
|
|
392
769
|
* ```
|
|
393
770
|
*
|
|
394
771
|
* @accessibility
|
|
395
|
-
* - Focus visible ring for keyboard navigation
|
|
396
|
-
* - Active state styling for current page indication
|
|
397
|
-
* - Proper link semantics and ARIA attributes
|
|
398
|
-
* - Keyboard activation support (Enter key)
|
|
399
|
-
* - Screen reader compatible text content
|
|
400
|
-
*
|
|
401
|
-
*
|
|
402
|
-
*
|
|
772
|
+
* - Focus visible ring indicator for keyboard navigation (3px ring with outline)
|
|
773
|
+
* - Active state styling with proper contrast for current page indication
|
|
774
|
+
* - Proper link semantics and ARIA attributes (including aria-current when active)
|
|
775
|
+
* - Keyboard activation support (Enter key) and tab navigation
|
|
776
|
+
* - Screen reader compatible text content and descriptions
|
|
777
|
+
* - Icon sizing and color inheritance for consistent visual hierarchy
|
|
778
|
+
* - External link indicators and proper rel attributes for security
|
|
779
|
+
*
|
|
780
|
+
* @see {@link NavigationMenuContent} Content container where links are often used
|
|
781
|
+
* @see {@link NavigationMenuItem} Item container for direct navigation links
|
|
782
|
+
* @see {@link navigationMenuTriggerStyle} Styling function for button-like appearance
|
|
403
783
|
* @since 1.0.0
|
|
404
784
|
*/
|
|
405
785
|
function NavigationMenuLink({
|
|
@@ -419,25 +799,74 @@ function NavigationMenuLink({
|
|
|
419
799
|
}
|
|
420
800
|
|
|
421
801
|
/**
|
|
422
|
-
* NavigationMenuIndicator -
|
|
802
|
+
* Props for NavigationMenuIndicator component (Documentation only - NOT used in component implementation)
|
|
803
|
+
* These types are for documentation generation and should not replace Radix inferred types
|
|
804
|
+
*/
|
|
805
|
+
type NavigationMenuIndicatorDocsProps = {
|
|
806
|
+
/** Change the default rendered element for the one passed as a child, merging their props and behavior */
|
|
807
|
+
asChild?: boolean;
|
|
808
|
+
/** Used to force mounting when more control is needed. Useful when controlling animation with external libraries */
|
|
809
|
+
forceMount?: boolean;
|
|
810
|
+
} & React.ComponentProps<"div">;
|
|
811
|
+
|
|
812
|
+
/**
|
|
813
|
+
* NavigationMenuIndicator - Animated visual indicator for active menu items
|
|
814
|
+
*
|
|
815
|
+
* An optional visual indicator that displays an animated arrow pointing to the currently
|
|
816
|
+
* active or focused navigation menu item. Automatically transitions between positions as
|
|
817
|
+
* users navigate through menu items, providing clear visual feedback about the current
|
|
818
|
+
* selection. The indicator appears below the active item and includes smooth fade and
|
|
819
|
+
* position animations.
|
|
820
|
+
*
|
|
821
|
+
* @example
|
|
822
|
+
* ```tsx
|
|
823
|
+
* // Basic usage within NavigationMenuList
|
|
824
|
+
* <NavigationMenuList>
|
|
825
|
+
* <NavigationMenuItem value="home">
|
|
826
|
+
* <NavigationMenuTrigger>Home</NavigationMenuTrigger>
|
|
827
|
+
* <NavigationMenuContent>
|
|
828
|
+
* <NavigationMenuLink href="/">Homepage</NavigationMenuLink>
|
|
829
|
+
* </NavigationMenuContent>
|
|
830
|
+
* </NavigationMenuItem>
|
|
831
|
+
* <NavigationMenuItem value="about">
|
|
832
|
+
* <NavigationMenuTrigger>About</NavigationMenuTrigger>
|
|
833
|
+
* <NavigationMenuContent>
|
|
834
|
+
* <NavigationMenuLink href="/about">About Us</NavigationMenuLink>
|
|
835
|
+
* </NavigationMenuContent>
|
|
836
|
+
* </NavigationMenuItem>
|
|
837
|
+
* <NavigationMenuIndicator className="data-[state=visible]:bg-primary" />
|
|
838
|
+
* </NavigationMenuList>
|
|
839
|
+
* ```
|
|
423
840
|
*
|
|
424
|
-
*
|
|
425
|
-
*
|
|
426
|
-
*
|
|
841
|
+
* @example
|
|
842
|
+
* ```tsx
|
|
843
|
+
* // Custom styled indicator
|
|
844
|
+
* <NavigationMenuIndicator className="
|
|
845
|
+
* data-[state=visible]:animate-pulse
|
|
846
|
+
* data-[state=visible]:bg-gradient-to-r
|
|
847
|
+
* data-[state=visible]:from-blue-500
|
|
848
|
+
* data-[state=visible]:to-purple-500
|
|
849
|
+
* " />
|
|
850
|
+
* ```
|
|
427
851
|
*
|
|
428
|
-
* @component
|
|
429
852
|
* @example
|
|
430
853
|
* ```tsx
|
|
431
|
-
* //
|
|
432
|
-
* <NavigationMenuIndicator
|
|
854
|
+
* // Force mounted indicator for custom animations
|
|
855
|
+
* <NavigationMenuIndicator
|
|
856
|
+
* forceMount
|
|
857
|
+
* className="custom-indicator-animation"
|
|
858
|
+
* />
|
|
433
859
|
* ```
|
|
434
860
|
*
|
|
435
861
|
* @accessibility
|
|
436
|
-
* - Purely decorative visual element
|
|
437
|
-
* - Does not interfere with screen reader navigation
|
|
438
|
-
* -
|
|
439
|
-
*
|
|
440
|
-
*
|
|
862
|
+
* - Purely decorative visual element that enhances UX
|
|
863
|
+
* - Does not interfere with keyboard or screen reader navigation
|
|
864
|
+
* - Arrow element is properly hidden from assistive technologies
|
|
865
|
+
* - Does not affect focus management or navigation behavior
|
|
866
|
+
* - Provides visual feedback that complements accessible navigation patterns
|
|
867
|
+
*
|
|
868
|
+
* @see {@link NavigationMenuList} Container where indicator is typically placed
|
|
869
|
+
* @see {@link NavigationMenuItem} Items that the indicator highlights
|
|
441
870
|
* @since 1.0.0
|
|
442
871
|
*/
|
|
443
872
|
function NavigationMenuIndicator({
|