# Navigation
A flexible navigation interface for large, medium, and small screens.
## Bar
```tsx
const links = [
{ label: 'Home', href: '#', icon: HouseIcon },
{ label: 'Books', href: '#', icon: BookIcon },
{ label: 'Movies', href: '#', icon: PopcornIcon },
{ label: 'Television', href: '#', icon: TvIcon },
];
let anchorBar = 'btn hover:preset-tonal flex-col items-center gap-1';
return (
{links.map((link) => {
const Icon = link.icon;
return (
{link.label}
);
})}
);
}
```
- Recommended for small sized screens (ex: mobile).
- Ideal for vertical screen layouts.
- Should be fixed to the bottom of the viewport.
- Supports 3-5 tiles based on contents and viewport width.
- Consider progressive enhancement with the [Virtual Keyboard API](https://developer.mozilla.org/en-US/docs/Web/API/VirtualKeyboard_API).
## Rail
```tsx
const links = [
{ label: 'Home', href: '#', icon: HouseIcon },
{ label: 'Books', href: '#', icon: BookIcon },
{ label: 'Movies', href: '#', icon: PopcornIcon },
{ label: 'Television', href: '#', icon: TvIcon },
];
let anchorRail = 'btn hover:preset-tonal aspect-square w-full max-w-[84px] flex flex-col items-center gap-0.5';
return (
{links.map((link) => {
const Icon = link.icon;
return (
{link.label}
);
})}
);
}
```
- Recommended for medium sized screens (ex: tablet).
- Ideal for horizontal screen layouts.
- Should be fixed to the left or right of the viewport.
- Supports 3-7 tiles based on contents and viewport height.
## Sidebar
```tsx
const linksSidebar = {
entertainment: [
{ label: 'Books', href: '#', icon: BookIcon },
{ label: 'Movies', href: '#', icon: PopcornIcon },
{ label: 'Television', href: '#', icon: TvIcon },
],
recreation: [
{ label: 'Biking', href: '#', icon: BikeIcon },
{ label: 'Sailing', href: '#', icon: SailboatIcon },
{ label: 'Hiking', href: '#', icon: MountainIcon },
{ label: 'Swimming', href: '#', icon: WavesIcon },
],
};
let anchorSidebar = 'btn hover:preset-tonal justify-start px-2 w-full';
return (
Home
{Object.entries(linksSidebar).map(([category, links]) => (
{category}
{links.map((link) => {
const Icon = link.icon;
return (
{link.label}
);
})}
))}
Settings
);
}
```
- Recommended for large sized screens (ex: desktop).
- Ideal for horizontal screen layouts.
- Should be fixed to the left or right of the viewport.
- Supports multiple groups of links for deep navigation.
- Supports a label field per each group.
- Can scroll vertically if contents extend beyond the viewport height.
## Toggle Layout
Using reactive state we can dynamically switch between multiple layouts. Tap the double arrow icon to toggle.
```tsx
const links = [
{ label: 'Home', href: '#', icon: HouseIcon },
{ label: 'Books', href: '#', icon: BookIcon },
{ label: 'Movies', href: '#', icon: PopcornIcon },
{ label: 'Television', href: '#', icon: TvIcon },
];
const buttonClasses = 'btn hover:preset-tonal';
let anchorRail = `${buttonClasses} aspect-square w-full max-w-[84px] flex flex-col items-center gap-0.5`;
let anchorSidebar = `${buttonClasses} justify-start px-2 w-full`;
let [layoutRail, setLayoutRail] = useState(true);
function toggleLayout() {
setLayoutRail(!layoutRail);
}
return (
{links.map((link) => {
const Icon = link.icon;
return (
{link.label}
);
})}
{!layoutRail ? Resize : ''}
);
}
```
## API Reference
### NavigationRoot
| Property | Type | Description |
| --- | --- | --- |
| `layout` | "bar" | "rail" | "sidebar" | undefined | Sets the data-layout attribute, which modifies the visual presentation of the component set. Default: bar |
| `element` | ((attributes: HTMLAttributes<"div">) => Element) | undefined | Render the element yourself |
### NavigationHeader
| Property | Type | Description |
| --- | --- | --- |
| `element` | ((attributes: HTMLAttributes<"header">) => Element) | undefined | Render the element yourself |
### NavigationContent
| Property | Type | Description |
| --- | --- | --- |
| `element` | ((attributes: HTMLAttributes<"div">) => Element) | undefined | Render the element yourself |
### NavigationGroup
| Property | Type | Description |
| --- | --- | --- |
| `element` | ((attributes: HTMLAttributes<"div">) => Element) | undefined | Render the element yourself |
### NavigationLabel
| Property | Type | Description |
| --- | --- | --- |
| `element` | ((attributes: HTMLAttributes<"div">) => Element) | undefined | Render the element yourself |
### NavigationMenu
| Property | Type | Description |
| --- | --- | --- |
| `element` | ((attributes: HTMLAttributes<"div">) => Element) | undefined | Render the element yourself |
### NavigationFooter
| Property | Type | Description |
| --- | --- | --- |
| `element` | ((attributes: HTMLAttributes<"footer">) => Element) | undefined | Render the element yourself |