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 Mode
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: 0
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. Use window.location.href
to compare page pathname and tile URLs.
import React, { useEffect } from 'react';import { Navigation } from '@skeletonlabs/skeleton-react';
export const Page: React.FC = () => { let urlPathname = '';
const links = [ { label: 'Files', href: '#/files' }, { label: 'Images', href: '#/images' }, { label: 'Music', href: '#/music' }, { label: 'Videos', href: '#/videos' }, ];
useEffect(() => { urlPathname = window.location.href; });
return ( <Navigation.Bar> {links.map((link) => ( <Navigation.Tile label={link.label} href={link.href} selected={urlPathname === link.href} > {link.label} </Navigation.Tile> ))} </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 | ReactNode | |
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 | ReactNode | |
children | ReactNode | |
footer | ReactNode | |
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 | ReactNode | |