# Navigation
A flexible navigation interface for large, medium, and small screens.
## Bar
```tsx
import { Navigation } from '@skeletonlabs/skeleton-react';
import { BookIcon } from 'lucide-react';
import { HouseIcon } from 'lucide-react';
import { PopcornIcon } from 'lucide-react';
import { TvIcon } from 'lucide-react';
export default function Default() {
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
import { Navigation } from '@skeletonlabs/skeleton-react';
import { BookIcon } from 'lucide-react';
import { HouseIcon } from 'lucide-react';
import { PopcornIcon } from 'lucide-react';
import { SkullIcon } from 'lucide-react';
import { SettingsIcon } from 'lucide-react';
import { TvIcon } from 'lucide-react';
export default function Default() {
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
import { Navigation } from '@skeletonlabs/skeleton-react';
import { BikeIcon } from 'lucide-react';
import { BookIcon } from 'lucide-react';
import { HouseIcon } from 'lucide-react';
import { MountainIcon } from 'lucide-react';
import { PopcornIcon } from 'lucide-react';
import { SailboatIcon } from 'lucide-react';
import { SettingsIcon } from 'lucide-react';
import { SkullIcon } from 'lucide-react';
import { TvIcon } from 'lucide-react';
import { WavesIcon } from 'lucide-react';
export default function Default() {
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
import { Navigation } from '@skeletonlabs/skeleton-react';
import { BookIcon } from 'lucide-react';
import { HouseIcon } from 'lucide-react';
import { PopcornIcon } from 'lucide-react';
import { TvIcon } from 'lucide-react';
import { ArrowLeftRightIcon } from 'lucide-react';
import { useState } from 'react';
export default function Default() {
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
| Property | Default | Type |
| -------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| layout | bar | "bar" \| "rail" \| "sidebar" \| undefined — Sets the data-layout attribute, which modifies the visual presentation of the component set. |
| element | - | ((attributes: HTMLAttributes\<"div">) => Element) \| undefined — Render the element yourself |
| element | - | ((attributes: HTMLAttributes\<"header">) => Element) \| undefined — Render the element yourself |
| element | - | ((attributes: HTMLAttributes\<"div">) => Element) \| undefined — Render the element yourself |
| element | - | ((attributes: HTMLAttributes\<"div">) => Element) \| undefined — Render the element yourself |
| element | - | ((attributes: HTMLAttributes\<"div">) => Element) \| undefined — Render the element yourself |
| element | - | ((attributes: HTMLAttributes\<"div">) => Element) \| undefined — Render the element yourself |
| element | - | ((attributes: HTMLAttributes\<"footer">) => Element) \| undefined — Render the element yourself |