Rail
- Recommended for medium to large screens.
- Ideal for horizontal screen layouts.
- Should be fixed to the left or right of the viewport.
- Supports 3-7 tiles based on viewport height.
Selection
Define a value
state on the Rail. This is updated to match each Tile id
when presssed.
value: files
Routing
Replace Tile id
with href
to convert each to a anchor link.
Expanded
Apply the expanded
property to enable an expanded mode. Each tile will resize and used the expanded label.
(Content)
Bar
- Recommended for small screens.
- Ideal for vertical screen layouts.
- Should be fixed to the bottom of the viewport.
- Supports 3-5 tiles based on viewport width.
- Consider progressive enhancement with the Virtual Keyboard API.
Selection
Define a value
state on the Bar. This is updated to match each Tile id
when presssed.
value: files
Routing
Replace Tile id
with href
to convert each to a anchor link.
(Content)
Tiles
Tiles are universal between Rails and Bars. They default to buttons, but will convert to anchors when an href
is provided. When implementing value
for selection, each item will update the value when clicked.
Anchor Tile Selection
When using anchor Tiles, use the selected
prop to highlight the active tile. For SvelteKit, this can be achieved using the page
state and comparing the page pathname and tile URLs.
<script lang="ts"> import { page } from '$app/state';
const links = [ { label: 'Files', href: '#/files' }, { label: 'Images', href: '#/images' }, { label: 'Music', href: '#/music' }, { label: 'Videos', href: '#/videos' }, ];</script>
<Navigation.Bar> {#each links as {label, href}} <Navigation.Tile {label} {href} selected={page.url.pathname === link.href} > {icon} </Navigation.Tile> {/each}</Navigation.Bar>
Anatomy
Rail
<Navigation.Rail>
header
tiles
<Navigation.Tile>
expanded
label|labelExpanded
footer
Bar
<Navigation.Bar>
tiles
<Navigation.Tile>
expanded
label|labelExpanded
API Reference
NavCommon
Property | Type | Description |
---|---|---|
value | string | |
base | string | |
background | string | |
padding | string | |
width | string | |
widthExpanded | string | |
height | string | |
classes | string | |
tilesBase | string | |
tilesFlexDirection | string | |
tilesJustify | string | |
tilesItems | string | |
tilesGap | string | |
tilesClasses | string | |
onValueChange | (id: string) => void | |
NavBar
Property | Type | Description |
---|---|---|
children | Snippet<[]> | |
value | string | |
base | string | |
background | string | |
padding | string | |
width | string | |
widthExpanded | string | |
height | string | |
classes | string | |
tilesBase | string | |
tilesFlexDirection | string | |
tilesJustify | string | |
tilesItems | string | |
tilesGap | string | |
tilesClasses | string | |
onValueChange | (id: string) => void | |
NavRail
Property | Type | Description |
---|---|---|
expanded | boolean | |
headerBase | string | |
headerFlexDirection | string | |
headerJustify | string | |
headerItems | string | |
headerGap | string | |
headerClasses | string | |
footerBase | string | |
footerFlexDirection | string | |
footerJustify | string | |
footerItems | string | |
footerGap | string | |
footerClasses | string | |
header | Snippet<[]> | |
tiles | Snippet<[]> | |
footer | Snippet<[]> | |
value | string | |
base | string | |
background | string | |
padding | string | |
width | string | |
widthExpanded | string | |
height | string | |
classes | string | |
tilesBase | string | |
tilesFlexDirection | string | |
tilesJustify | string | |
tilesItems | string | |
tilesGap | string | |
tilesClasses | string | |
onValueChange | (id: string) => void | |
NavTile
Property | Type | Description |
---|---|---|
id | string | |
href | string | |
target | string | |
label | string | |
labelExpanded | string | |
title | string | |
selected | boolean | |
type | "button" | "submit" | "reset" | |
base | string | |
width | string | |
aspect | string | |
background | string | |
hover | string | |
active | string | |
padding | string | |
gap | string | |
rounded | string | |
classes | string | |
expandedPadding | string | |
expandedGap | string | |
expandedClasses | string | |
labelBase | string | |
labelClasses | string | |
labelExpandedBase | string | |
labelExpandedClasses | string | |
onclick | (id: string) => void | |
children | Snippet<[]> | |