Navigation
The primary sidebar navigation of an app. One item is selected at a time, and clicking a parent opens its first child.
Health
Source
Design
Storybook
Playground
No Example
Accessibility
compliant
Platform
Web
- Overview
- Props
- Figma
Usage
Home
Employees
Employees
(10)
Work stoppages
Settings
- When using nested navigation, clicking on the parent will trigger the first child
- There can be only one selected item at a time
Integration with React Router
To integrate with react-router, iy's possible to rely on:
renderAsto have the navigation items rendered asLinkcomponentskeyto compare current loacation with each item to know which one is selectednavigationItemStylesis required to re-apply styles. It is related to a Tamagui bug with theasChildprop.
const { pathname } = useLocation();
return (
<Navigation
selected={pathname}
items={[
{
label: "Home",
key: "/",
icon: <Icon visual="home" />,
renderAs: ({ children }) => (
<A asChild sx={navigationItemStyles}>
<Link to="/">{children}</Link>
</A>
),
},
{
label: "Employees",
key: "employees",
icon: <Icon visual="PeopleTwo" />,
subItems: [
{
label: "Salariés",
key: "/employees",
renderAs: ({ children }) => (
<A asChild sx={navigationItemStyles}>
<Link to="/employees">{children}</Link>
</A>
),
},
],
},
]}
/>
);
Playground
Loading...
Navigation props
| Name | Type | Default Value | Description | Usage count |
|---|---|---|---|---|
| items* | NavigationRootItem[] | |||
| onSelect | ((key: string) => void)undefined | |||
| selected* | string | |||
| sx | PositionPropsundefined |
Style API
Use sx for one-off adjustments. It accepts these style keys:
alignSelfanimationaspectRatiobottomcursordisplayendflexflexBasisflexGrowflexShrinkheightinsetinsetInlineinsetInlineEndinsetInlineStartleftmarginmarginBottommarginHorizontalmarginInlinemarginInlineEndmarginInlineStartmarginLeftmarginRightmarginTopmarginVerticalmatrixmaxHeightmaxWidthminHeightminWidthopacityperspectivepositionrightrotaterotateXrotateYrotateZscalescaleXscaleYskewXskewYstarttoptransformtransformOriginwidthxyzIndex
Each can be overridden per breakpoint with:
$lg$ltLg$ltMd$ltSm$ltVs$ltXl$ltXxl$md$sm$vs$xl$xs$xxl