Navigation rails let people switch between UI views on mid-sized devices. Use a navigation rail in a medium, expanded, large or extra-large window. A rail can contain:
- Three to seven destinations
- A menu button, which expands and collapses the rail
- An optional FAB, for the key action of the app
Always put the rail in the same place, even on different screens of an app.
On smaller devices, use a navigation bar instead.
A rail is composed of these parts:
| Part | Use |
|---|---|
NavigationRail | The rail |
NavigationRailHeader | The controls at the top of the rail. See Header. |
NavigationRailItem | A destination |
NavigationRailSection | A group of secondary destinations. See Sections. |
Icon | In an item, its icon, sized and colored by the item |
Text with slot="label" | In an item, its label, which names the item |
import {
NavigationRail,
NavigationRailHeader,
NavigationRailItem,
NavigationRailSection,
} from '@material-web/react'
import { Text } from 'react-aria-components'Basic navigation rail
Put one NavigationRailItem per destination in a NavigationRail, each with its icon and its label.
import {
Fab,
Icon,
IconButton,
NavigationRail,
NavigationRailHeader,
NavigationRailItem,
NavigationRailSection,
} from '@material-web/react'
import { useState } from 'react'
import { Text } from 'react-aria-components'
export default function Basic() {
const [isExpanded, setExpanded] = useState(false)
const [page, setPage] = useState('Inbox')
return (
<div className="flex h-120 w-full">
<nav aria-label="Mail" className="flex">
<NavigationRail isExpanded={isExpanded}>
<NavigationRailHeader>
<IconButton
aria-label={isExpanded ? 'Collapse' : 'Expand'}
onPress={() => setExpanded(!isExpanded)}
>
<Icon name={isExpanded ? 'menu_open' : 'menu'} />
</IconButton>
<Fab isExtended={isExpanded} aria-label="Compose">
<Icon name="edit" className="icon-filled" />
<Text slot="label">Compose</Text>
</Fab>
</NavigationRailHeader>
<NavigationRailItem isSelected={page === 'Inbox'} onChange={() => setPage('Inbox')}>
<Icon name="inbox" />
<Text slot="label">Inbox</Text>
</NavigationRailItem>
<NavigationRailItem isSelected={page === 'Sent'} onChange={() => setPage('Sent')}>
<Icon name="send" />
<Text slot="label">Sent</Text>
</NavigationRailItem>
<NavigationRailSection aria-labelledby="rail-labels">
<Text slot="header" id="rail-labels">
Labels
</Text>
<NavigationRailItem isSelected={page === 'Family'} onChange={() => setPage('Family')}>
<Icon name="label" />
<Text slot="label">Family</Text>
</NavigationRailItem>
</NavigationRailSection>
</NavigationRail>
</nav>
<div className="m-space-200 min-w-0 flex-1 rounded-shape-xl bg-primary-container p-space-300 text-title-lg text-on-primary-container">
{page}
</div>
</div>
)
}A rail comes in two variants, collapsed and expanded, which transform into each other when the menu button is selected. Set isExpanded to expand the rail, and change it in the onPress of the menu button, as the first example does. The page beside the rail adjusts to fit.
Collapsed rail
A collapsed rail (the default) is 96dp wide, with each item's label under its icon. It runs along the leading edge of the window.
import { Icon, NavigationRail, NavigationRailItem } from '@material-web/react'
import { useState } from 'react'
import { Text } from 'react-aria-components'
const destinations = [
['Alarm', 'alarm'],
['Clock', 'schedule'],
['Timer', 'hourglass_empty'],
] as const
export default function Collapsed() {
const [page, setPage] = useState<string>('Clock')
return (
<div className="flex h-96">
<NavigationRail aria-label="Main">
{destinations.map(([name, icon]) => (
<NavigationRailItem key={name} isSelected={page === name} onChange={() => setPage(name)}>
<Icon name={icon} />
<Text slot="label">{name}</Text>
</NavigationRailItem>
))}
</NavigationRail>
<div className="m-space-200 min-w-0 flex-1 rounded-shape-xl bg-primary-container p-space-300 text-title-lg text-on-primary-container">
{page}
</div>
</div>
)
}Expanded rail
An expanded rail is as wide as its content, from 220 to 360dp, with each item's icon and label side by side. A label too long for that wraps. Use an expanded rail when there are secondary destinations that have lower priority than the main navigation items.
import { Icon, NavigationRail, NavigationRailItem } from '@material-web/react'
import { useState } from 'react'
import { Text } from 'react-aria-components'
const destinations = [
['Alarm', 'alarm'],
['Clock', 'schedule'],
['Timer', 'hourglass_empty'],
] as const
export default function Expanded() {
const [page, setPage] = useState<string>('Clock')
return (
<div className="flex h-96">
<NavigationRail aria-label="Main" isExpanded>
{destinations.map(([name, icon]) => (
<NavigationRailItem key={name} isSelected={page === name} onChange={() => setPage(name)}>
<Icon name={icon} />
<Text slot="label">{name}</Text>
</NavigationRailItem>
))}
</NavigationRail>
<div className="m-space-200 min-w-0 flex-1 rounded-shape-xl bg-primary-container p-space-300 text-title-lg text-on-primary-container">
{page}
</div>
</div>
)
}Slots
Item
- label
| Slot | Child | Use |
|---|---|---|
label | A Text | The label, which names the item |
Write an item's icon and label as its children. The Icon is sized and colored by the item.
Section
- header
| Slot | Child | Use |
|---|---|---|
header | A Text, first in the section | The header of a section |
Give the header an id, and set the section's aria-labelledby to that id. Without a header, name the section with an aria-label.
Header
Write a NavigationRailHeader first in the rail, then the items, then any sections. The rail shows its children in the order written.
The header shows its children in a column, such as a menu IconButton and a FAB. The first example has both.
| Part | Use |
|---|---|
| Menu button | Change the menu icon when the rail is expanded, to show that it can be collapsed. |
| FAB | Pass the rail's isExpanded to the FAB as its isExtended. An extended FAB widens the expanded rail. A FAB in the header has no shadow until it is hovered. |
| Logo | Optional. Avoid a logo that could be mistaken for a button, and do not use one as the menu button. |
Sections
Put secondary destinations in a NavigationRailSection, after the rail's own items. A section is shown only in an expanded rail. For a section header, see Slots.
import {
Icon,
NavigationRail,
NavigationRailItem,
NavigationRailSection,
} from '@material-web/react'
import { useState } from 'react'
import { Text } from 'react-aria-components'
const destinations = [
['Alarm', 'alarm'],
['Clock', 'schedule'],
['Timer', 'hourglass_empty'],
] as const
const secondary = [
['Sounds', 'music_note'],
['Wind down', 'self_improvement'],
] as const
export default function Sections() {
const [page, setPage] = useState<string>('Clock')
const item = ([name, icon]: readonly [string, string]) => (
<NavigationRailItem key={name} isSelected={page === name} onChange={() => setPage(name)}>
<Icon name={icon} />
<Text slot="label">{name}</Text>
</NavigationRailItem>
)
return (
<div className="flex h-120">
<NavigationRail aria-label="Main" isExpanded>
{destinations.map(item)}
<NavigationRailSection aria-label="More">{item(['Bedtime', 'bed'])}</NavigationRailSection>
<NavigationRailSection aria-labelledby="sleep-well">
<Text slot="header" id="sleep-well">
Sleep well
</Text>
{secondary.map(item)}
</NavigationRailSection>
</NavigationRail>
<div className="m-space-200 min-w-0 flex-1 rounded-shape-xl bg-primary-container p-space-300 text-title-lg text-on-primary-container">
{page}
</div>
</div>
)
}Selection
Set isSelected on the NavigationRailItem of the page being shown, and handle a press with onChange or onPress. A selected item shows the active indicator and fills its Icon.
<NavigationRailItem isSelected={page === 'inbox'} onChange={() => setPage('inbox')}>
<Icon name="inbox" />
<Text slot="label">Inbox</Text>
</NavigationRailItem>- Your own state: Selecting an item does not deselect the others, and a press on the selected item calls
onChange(false), so keep the selection in your own state. - Uncontrolled: With
defaultSelectedinstead, an item keeps its own selection, and a second press turns it off.
Disabled
Set isDisabled to disable an item. It cannot be pressed or focused.
import { Icon, NavigationRail, NavigationRailItem } from '@material-web/react'
import { useState } from 'react'
import { Text } from 'react-aria-components'
const destinations = [
['Alarm', 'alarm'],
['Clock', 'schedule'],
['Timer', 'hourglass_empty'],
] as const
export default function Disabled() {
const [page, setPage] = useState<string>('Clock')
return (
<div className="flex h-96">
<NavigationRail aria-label="Main">
{destinations.map(([name, icon]) => (
<NavigationRailItem
key={name}
isSelected={page === name}
isDisabled={name === 'Timer'}
onChange={() => setPage(name)}
>
<Icon name={icon} />
<Text slot="label">{name}</Text>
</NavigationRailItem>
))}
</NavigationRail>
<div className="m-space-200 min-w-0 flex-1 rounded-shape-xl bg-primary-container p-space-300 text-title-lg text-on-primary-container">
{page}
</div>
</div>
)
}Arrangement
Set arrangement to top (the default) or center. With center, the items are in the middle of the rail, and the header stays at its top. On tablets, use center to make the items easier to reach.
import {
Icon,
IconButton,
NavigationRail,
NavigationRailHeader,
NavigationRailItem,
} from '@material-web/react'
import { useState } from 'react'
import { Text } from 'react-aria-components'
const destinations = [
['Alarm', 'alarm'],
['Clock', 'schedule'],
['Timer', 'hourglass_empty'],
] as const
export default function Center() {
const [isExpanded, setExpanded] = useState(false)
const [page, setPage] = useState<string>('Clock')
return (
<div className="flex h-120">
<NavigationRail aria-label="Main" arrangement="center" isExpanded={isExpanded}>
<NavigationRailHeader>
<IconButton
aria-label={isExpanded ? 'Collapse' : 'Expand'}
onPress={() => setExpanded(!isExpanded)}
>
<Icon name={isExpanded ? 'menu_open' : 'menu'} />
</IconButton>
</NavigationRailHeader>
{destinations.map(([name, icon]) => (
<NavigationRailItem key={name} isSelected={page === name} onChange={() => setPage(name)}>
<Icon name={icon} />
<Text slot="label">{name}</Text>
</NavigationRailItem>
))}
</NavigationRail>
<div className="m-space-200 min-w-0 flex-1 rounded-shape-xl bg-primary-container p-space-300 text-title-lg text-on-primary-container">
{page}
</div>
</div>
)
}The sections are centered together with the items. This also applies to a collapsed rail, where the sections are hidden but keep their space.
Placement
The rail is not positioned for you, and is as tall as its container stretches it. Put it first in a row with the page, such as <div className="flex h-dvh">, so that it is on the leading edge of the window: the left side in a left-to-right language, and the right side in a right-to-left one.
The rail is not a landmark. Put it in a <nav> of your own, with flex so that the rail is stretched, as in the first example, or name it with an aria-label.
Hidden when collapsed
Set isHiddenOnCollapse to hide the rail while it is collapsed, for an immersive page. A hidden rail takes no space and cannot be reached, so expand it from a menu button of your own, outside the rail. Once expanded, it is shown beside the page, which makes room for it.
import {
Icon,
IconButton,
NavigationRail,
NavigationRailHeader,
NavigationRailItem,
} from '@material-web/react'
import { useRef, useState } from 'react'
import { Text } from 'react-aria-components'
import { flushSync } from 'react-dom'
const destinations = [
['Alarm', 'alarm'],
['Clock', 'schedule'],
['Timer', 'hourglass_empty'],
] as const
export default function HiddenOnCollapse() {
const [isExpanded, setExpanded] = useState(false)
const [page, setPage] = useState<string>('Clock')
const show = useRef<HTMLButtonElement>(null)
const hide = useRef<HTMLButtonElement>(null)
// Each menu button takes the keyboard focus from the other.
const turn = (next: boolean) => {
flushSync(() => setExpanded(next))
;(next ? hide : show).current?.focus()
}
return (
<div className="flex h-96">
<NavigationRail aria-label="Main" isExpanded={isExpanded} isHiddenOnCollapse>
<NavigationRailHeader>
<IconButton ref={hide} aria-label="Hide navigation" onPress={() => turn(false)}>
<Icon name="menu_open" />
</IconButton>
</NavigationRailHeader>
{destinations.map(([name, icon]) => (
<NavigationRailItem key={name} isSelected={page === name} onChange={() => setPage(name)}>
<Icon name={icon} />
<Text slot="label">{name}</Text>
</NavigationRailItem>
))}
</NavigationRail>
<div className="relative flex min-w-0 flex-1 items-center justify-center bg-primary-container text-display-lg text-on-primary-container">
{!isExpanded && (
<IconButton
ref={show}
aria-label="Show navigation"
className="absolute start-7 top-13"
onPress={() => turn(true)}
>
<Icon name="menu" />
</IconButton>
)}
8:30
</div>
</div>
)
}- Layout: Such a rail is never shown collapsed, and its sections are always shown.
- Focus: Move the keyboard focus to the rail's menu button when it expands, and back to the page's menu button when it collapses.
Third-party routing library
An item takes no href. To move between the pages of an app, call the router in the item's onChange or onPress, and set isSelected from the current location. See Routing.
With React Router:
import { Icon, NavigationRailItem } from '@material-web/react'
import { Text } from 'react-aria-components'
import { useLocation, useNavigate } from 'react-router'
function InboxItem() {
const { pathname } = useLocation()
const navigate = useNavigate()
return (
<NavigationRailItem isSelected={pathname === '/inbox'} onPress={() => navigate('/inbox')}>
<Icon name="inbox" />
<Text slot="label">Inbox</Text>
</NavigationRailItem>
)
}The navigation bar page has a whole example.
Customization
Pass classes in className to restyle the rail, its header, an item or a section. A class of yours replaces the component's own class for the same property. See Styling for the classes, the states and the theme.
Set className="bg-transparent" to turn the rail's fill off, and className="border-e border-outline-variant" to show a divider at the edge next to the content.
import { Icon, NavigationRail, NavigationRailItem } from '@material-web/react'
import { useState } from 'react'
import { Text } from 'react-aria-components'
const destinations = [
['Alarm', 'alarm'],
['Clock', 'schedule'],
['Timer', 'hourglass_empty'],
] as const
export default function Divider() {
const [page, setPage] = useState<string>('Clock')
return (
<div className="flex h-96 bg-surface-container-low">
<NavigationRail aria-label="Main" className="border-e border-outline-variant bg-transparent">
{destinations.map(([name, icon]) => (
<NavigationRailItem key={name} isSelected={page === name} onChange={() => setPage(name)}>
<Icon name={icon} />
<Text slot="label">{name}</Text>
</NavigationRailItem>
))}
</NavigationRail>
<div className="min-w-0 flex-1 p-space-300 text-title-lg">{page}</div>
</div>
)
}Pass a function as an item's children to render them from its state, as on a navigation bar item: isHovered, isPressed, isFocused, isFocusVisible, isSelected and isDisabled. In this example, an item shows another icon when it is selected.
import { Icon, NavigationRail, NavigationRailItem } from '@material-web/react'
import { useState } from 'react'
import { Text } from 'react-aria-components'
const destinations = ['Explore', 'Saved', 'Updates']
export default function FunctionChildren() {
const [page, setPage] = useState('Saved')
return (
<div className="flex h-96">
<NavigationRail aria-label="Main">
{destinations.map((name) => (
<NavigationRailItem key={name} isSelected={page === name} onChange={() => setPage(name)}>
{({ isSelected }) => (
<>
<Icon name={isSelected ? 'check_circle' : 'circle'} />
<Text slot="label">{name}</Text>
</>
)}
</NavigationRailItem>
))}
</NavigationRail>
<div className="m-space-200 min-w-0 flex-1 rounded-shape-xl bg-primary-container p-space-300 text-title-lg text-on-primary-container">
{page}
</div>
</div>
)
}- States: Style an item's state with its variant, such as
hover:,pressed:orselected:. See States. - Functions: The
classNameandstyleof a rail, an item and a section can be functions of their state too. See Children as a function. - Every navigation rail: To restyle all the navigation rails at once, change the theme.
Use cases
Material lists what people should be able to do with assistive technology:
- Navigate between navigation destinations
- Select a particular navigation destination from a set
- Get appropriate feedback based on input type
Interaction and style
- States: Hovering an item shows a state layer in its indicator's box, and a press anywhere on the item shows a ripple there. Keyboard focus shows a focus ring at the item's edges, across the rail, and a click does not. A disabled item shows no state layer.
- Touch target: An item takes a press anywhere across the rail, past its indicator in an expanded rail. Its items are 64dp tall in a collapsed rail and 56dp in an expanded one, more than the 48dp minimum touch target.
- Color contrast: With the default colors, the icons keep 3:1 contrast and the labels 4.5:1 with what is behind them, in the light and dark schemes at every contrast level. Material advises enough contrast between the container and the icons, active or not: check it again when you turn the rail's fill off with
bg-transparent. - Text size: A collapsed rail's label wraps under its icon as the text grows, and the item grows taller with it. Material advises keeping the full label visible at up to twice the text size.
- Motion: With reduced motion, the rail expands and collapses at once, and the active indicator appears at once.
- Forced colors: In forced colors, the active indicator is drawn in the system's highlight color, with the icon and the label on it in the highlight text color, and a disabled item in the gray text color.
- Right to left: In a right-to-left direction, the rail's parts are mirrored, and it expands toward the page.
- Selected icon: A selected item fills its
Icon, as Material advises. For an icon with no filled style, Material advises the semibold weight: give itfont-semiboldwhile the item is selected. See Customization.
Focus
- Tab moves the focus into the rail once: to its first control, such as the menu button in its header, as Material advises, or to the control focused last. The next Tab leaves the rail, and Shift+Tab comes back to the control focused last.
- A disabled item cannot be focused, and neither can an item in a section of a collapsed rail, where the section is hidden.
- A rail hidden when collapsed cannot be reached until it expands. Move the focus to it and back yourself, as Hidden when collapsed describes.
Keyboard navigation
| Keys | Actions |
|---|---|
| Tab | Move the focus into the rail, or out of it |
| Up or Down arrow | Move the focus to the previous or next control |
| Space or Enter | Select the focused item, or press the focused button |
- The up and down arrow keys move between all of its controls, the header's buttons and the items. They skip a disabled or hidden one, and stop at the first and the last.
- An item's
onKeyDownis not called for the arrow keys, with or without a modifier, and the rail takes noonKeyDown.
Labeling elements
- The rail is a vertical toolbar, and each item a toggle button. Name the rail with an
aria-label, or put it in a<nav>. - The label names each item, as Material advises. Where the label is ambiguous, Material advises a more descriptive name: set an
aria-labelthat includes the label, such as Recent images for an item labeled Recent. For an item with no label, set anaria-label. - A section is a group. Name each section with its header and
aria-labelledby, or with anaria-label. - Give the menu button an
aria-labelthat says what it does, such as Expand or Collapse, as the first example does. - A selected item reports it with
aria-pressed.
NavigationRail
isExpandedbooleanDefaultfalseThere are two variants of navigation rails, collapsed and expanded, which can easily transform into each other when the menu button is selected.
The collapsed nav rail runs along the leading edge of the window, and should contain 3–7 navigation items. It should not be hidden.
When the navigation rail transitions from collapsed to expanded, the contents of the page should automatically adjust to fit.
The contents of the navigation rail also expand to fill the space. For example, the FAB should transition into an extended FAB.
isHiddenOnCollapsebooleanDefaultfalseIn immersive experiences, the expanded navigation rail can be hidden entirely, appearing only when the menu icon is selected.
The collapsed navigation rail should not be hidden.
When the navigation rail is hidden, the body content can fill in the remaining space as long as the menu icon is still accessible.
arrangement'center' | 'top'Default'top'Navigation rail items can be aligned as a group to the top or center of a layout. On tablets, use center alignment to make it easier to reach items.
The menu icon and FAB should always be top-aligned.
Props of NavigationRail (10)
classNameClassNameOrFunction<ToolbarRenderProps>Default'react-aria-Toolbar'The CSS className for the element. A function may be provided to compute the class based on component state.
aria-labelstringDefines a string value that labels the current element.
aria-labelledbystringIdentifies the element (or elements) that labels the current element.
aria-describedbystringIdentifies the element (or elements) that describes the object.
aria-detailsstringIdentifies the element (or elements) that provide a detailed, extended description for the object.
slotstring | nullA slot name for the component. Slots allow the component to receive props from a parent component. An explicit
nullvalue indicates that the local props completely override all props received from a parent.childrenChildrenOrFunction<T>The children of the component. A function may be provided to alter the children based on component state.
styleCSSProperties | (values: ToolbarRenderProps & { defaultStyle: CSSProperties; }) => CSSProperties | undefinedThe inline style for the element. A function may be provided to compute the style based on component state.
renderDOMRenderFunction<'div', ToolbarRenderProps>Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components.
Requirements:
- You must render the expected element type (e.g. if
<button>is expected, you cannot render an<a>). - Only a single root DOM element can be rendered (no fragments).
- You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate.
- You must render the expected element type (e.g. if
refRef<HTMLDivElement>
NavigationRail also takes the 70 attributes and events of the element it renders.
NavigationRailHeader
Props of NavigationRailHeader (1)
refRef<HTMLDivElement>Allows getting a ref to the component instance. Once the component unmounts, React will set
ref.currenttonull(or call the ref withnullif you passed a callback ref).
NavigationRailHeader also takes the 278 attributes and events of the element it renders.
NavigationRailItem
Props of NavigationRailItem (37)
classNameClassNameOrFunction<ToggleButtonRenderProps>Default'react-aria-ToggleButton'The CSS className for the element. A function may be provided to compute the class based on component state.
idKeyWhen used in a ToggleButtonGroup, an identifier for the item in
selectedKeys. When used standalone, a DOM id.aria-labelstringDefines a string value that labels the current element.
aria-labelledbystringIdentifies the element (or elements) that labels the current element.
aria-describedbystringIdentifies the element (or elements) that describes the object.
aria-detailsstringIdentifies the element (or elements) that provide a detailed, extended description for the object.
onClick(e: MouseEvent<FocusableElement>) => voidNot recommended – use
onPressinstead.onClickis an alias foronPressprovided for compatibility with other libraries.onPressprovides additional event details for non-mouse interactions.isDisabledbooleanWhether the button is disabled.
onPress(e: PressEvent) => voidHandler that is called when the press is released over the target.
onPressStart(e: PressEvent) => voidHandler that is called when a press interaction starts.
onPressEnd(e: PressEvent) => voidHandler that is called when a press interaction ends, either over the target or when the pointer leaves the target.
onPressChange(isPressed: boolean) => voidHandler that is called when the press state changes.
onPressUp(e: PressEvent) => voidHandler that is called when a press is released over the target, regardless of whether it started on the target or not.
autoFocusbooleanWhether the element should receive focus on render.
onFocus(e: FocusEvent<Target>) => voidHandler that is called when the element receives focus.
onBlur(e: FocusEvent<Target>) => voidHandler that is called when the element loses focus.
onFocusChange(isFocused: boolean) => voidHandler that is called when the element's focus status changes.
onKeyDown(e: KeyboardEvent) => voidHandler that is called when a key is pressed.
onKeyUp(e: KeyboardEvent) => voidHandler that is called when a key is released.
aria-disabled'true' | 'false' | booleanIndicates whether the element is disabled to users of assistive technology.
aria-expanded'true' | 'false' | booleanIndicates whether the element, or another grouping element it controls, is currently expanded or collapsed.
aria-haspopup'dialog' | 'menu' | 'true' | 'false' | 'grid' | 'listbox' | 'tree' | booleanIndicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element.
aria-controlsstringIdentifies the element (or elements) whose contents or presence are controlled by the current element.
aria-pressed'true' | 'false' | 'mixed' | booleanIndicates the current "pressed" state of toggle buttons.
preventFocusOnPressbooleanWhether to prevent focus from moving to the button when pressing it.
Caution, this can make the button inaccessible and should only be used when alternative keyboard interaction is provided, such as ComboBox's MenuTrigger or a NumberField's increment/decrement control.
excludeFromTabOrderbooleanWhether to exclude the element from the sequential tab order. If true, the element will not be focusable via the keyboard by tabbing. This should be avoided except in rare scenarios where an alternative means of accessing the element or its functionality via the keyboard is available.
isSelectedbooleanWhether the element should be selected (controlled).
defaultSelectedbooleanWhether the element should be selected (uncontrolled).
onChange(isSelected: boolean) => voidHandler that is called when the element's selection state changes.
onHoverStart(e: HoverEvent) => voidHandler that is called when a hover interaction starts.
onHoverEnd(e: HoverEvent) => voidHandler that is called when a hover interaction ends.
onHoverChange(isHovering: boolean) => voidHandler that is called when the hover state changes.
slotstring | nullA slot name for the component. Slots allow the component to receive props from a parent component. An explicit
nullvalue indicates that the local props completely override all props received from a parent.childrenChildrenOrFunction<T>The children of the component. A function may be provided to alter the children based on component state.
styleCSSProperties | (values: ToggleButtonRenderProps & { defaultStyle: CSSProperties; }) => CSSProperties | undefinedThe inline style for the element. A function may be provided to compute the style based on component state.
renderDOMRenderFunction<'button', ToggleButtonRenderProps>Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components.
Requirements:
- You must render the expected element type (e.g. if
<button>is expected, you cannot render an<a>). - Only a single root DOM element can be rendered (no fragments).
- You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate.
- You must render the expected element type (e.g. if
refRef<HTMLButtonElement>
NavigationRailItem also takes the 69 attributes and events of the element it renders.
NavigationRailSection
Props of NavigationRailSection (17)
classNameClassNameOrFunction<GroupRenderProps>Default'react-aria-Group'The CSS className for the element. A function may be provided to compute the class based on component state.
isDisabledbooleanWhether the group is disabled.
isInvalidbooleanWhether the group is invalid.
isReadOnlybooleanWhether the group is read only.
role'group' | 'presentation' | 'region'Default'group'An accessibility role for the group. By default, this is set to
'group'. Use'region'when the contents of the group is important enough to be included in the page table of contents. Use'presentation'if the group is visual only and does not represent a semantic grouping of controls.aria-labelstringDefines a string value that labels the current element.
aria-labelledbystringIdentifies the element (or elements) that labels the current element.
aria-describedbystringIdentifies the element (or elements) that describes the object.
aria-detailsstringIdentifies the element (or elements) that provide a detailed, extended description for the object.
onHoverStart(e: HoverEvent) => voidHandler that is called when a hover interaction starts.
onHoverEnd(e: HoverEvent) => voidHandler that is called when a hover interaction ends.
onHoverChange(isHovering: boolean) => voidHandler that is called when the hover state changes.
childrenChildrenOrFunction<T>The children of the component. A function may be provided to alter the children based on component state.
styleCSSProperties | (values: GroupRenderProps & { defaultStyle: CSSProperties; }) => CSSProperties | undefinedThe inline style for the element. A function may be provided to compute the style based on component state.
renderDOMRenderFunction<'div', GroupRenderProps>Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components.
Requirements:
- You must render the expected element type (e.g. if
<button>is expected, you cannot render an<a>). - Only a single root DOM element can be rendered (no fragments).
- You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate.
- You must render the expected element type (e.g. if
slotstring | nullA slot name for the component. Slots allow the component to receive props from a parent component. An explicit
nullvalue indicates that the local props completely override all props received from a parent.refRef<HTMLDivElement>
NavigationRailSection also takes the 269 attributes and events of the element it renders.