Navigation Menu Primitive
A collection of navigation links.
Installation
Install the component via your command line.
Install @radix-ui/react-navigation-menu
Copy/paste the following code for web to ~/components/primitives/navigation-menu/navigation-menu.web.tsx
Copy/paste the following code for native to ~/components/primitives/navigation-menu/navigation-menu.tsx
Copy/paste the following code for types to ~/components/primitives/navigation-menu/types.ts
Copy/paste the following code for exporting to ~/components/primitives/navigation-menu/index.ts
Copy/paste the following code for native to ~/components/primitives/navigation-menu/index.tsx
Copy/paste the following code for types to ~/components/primitives/navigation-menu/types.ts
Usage
Props
Root
Extends View
props
Prop | Type | Note |
---|---|---|
value* | boolean | |
onValueChange* | (value: boolean) => void | |
asChild | boolean | (optional) |
delayDuration | number | Web only (optional) |
skipDelayDuration | number | Web only (optional) |
dir | ’ltr’ | ‘rtl’ | Web only (optional) |
orientation | ’horizontal’ | ‘vertical’ | Web only (optional) |
List
Extends View
props
Prop | Type | Note |
---|---|---|
asChild | boolean | (optional) |
Item
Extends Pressable
props
Prop | Type | Note |
---|---|---|
value* | string | |
asChild | boolean | (optional) |
Trigger
Extends Pressable
props
Prop | Type | Note |
---|---|---|
asChild | boolean | (optional) |
Portal
Prop | Type | Note |
---|---|---|
children* | React.ReactNode | |
forceMount | true | undefined | (optional) |
hostName | string | Web Only (optional) |
container | HTMLElement | null | undefined | Web Only (optional) |
Content
Extends View
props
Prop | Type | Note |
---|---|---|
asChild | boolean | (optional) |
forceMount | true | undefined | (optional) |
alignOffset | number | Native Only (optional) |
insets | Insets | Native Only (optional) |
avoidCollisions | boolean | Native Only (optional) |
align | ’start’ | ‘center’ | ‘end’ | Native Only (optional) |
side | ’top’ | ‘bottom’ | Native Only (optional) |
sideOffset | number | Native Only (optional) |
disablePositioningStyle | boolean | Native Only (optional) |
loop | boolean | Web Only (optional) |
onEscapeKeyDown | (event: KeyboardEvent) => void | Web Only (optional) |
onPointerDownOutside | (event: PointerDownOutsideEvent) => void | Web Only (optional) |
onFocusOutside | (event: FocusOutsideEvent) => void | Web Only (optional) |
onInteractOutside | PointerDownOutsideEvent | FocusOutsideEvent | Web Only (optional) |
Link
Extends Pressable
props
Prop | Type | Note |
---|---|---|
active | boolean | (optional) |
asChild | boolean | (optional) |
Viewport
Should only be used for web
Extends View
props except children
Indicator
Extends View
props
useRootContext
Must be used within a Root
component. It provides the following values from the navigation menu: value
, and onValueChange
.
useItemContext
Must be used within a Item
component. It provides the following values from the navigation menu: value
.