'use client';
/**
* NavRail — the destinations of a product down one side, folded to icons when
* the screen is narrow or the work needs the room.
*
* ```tsx
*
*
* }>Meridian
*
*
*
* }>Overview
* }>
* Inbox 12
*
*
* …
*
* ```
*
* ## One pill, and it travels
*
* The chosen destination sits on a tonal pill in the primary colour, with a
* short accent on its leading edge. There is one pill for the whole rail, not
* one per group, so it crosses the gap between groups when the choice does:
* going from Inbox to Settings reads as one move down the rail rather than as
* one row dimming while another lights.
*
* The pill is placed by measuring the active row in a layout effect, and kept
* on it with a `ResizeObserver` and a `MutationObserver` as the rail changes
* width, a label wraps or the active item changes. It is measured before paint
* and does not animate on the first placement, so a page never opens with the
* pill sliding in from the corner. With reduced motion the travel is skipped
* and it is simply there.
*
* ## Folded, it is still a rail
*
* Collapsed, the rows become 40px icon squares. The active pill becomes the
* square, the group labels become dividers, and a badge becomes a dot on the
* corner of its icon rather than disappearing with the label. The rail's width
* follows the state, so an app can put it in a flex row and let the content
* take the room it gives up.
*
* A folded item keeps its accessible name through `label` (or its text
* children when they are plain text), and shows the same name in a small
* flyout on hover and focus. The visible label is `aria-hidden` while folded,
* so a screen reader hears the row once rather than twice.
*
* ## Nested destinations
*
* A destination can own a child list with `NavRail.Sub`. The parent stays an
* ordinary row — a link when it has an `href` — and the list is indented under
* it, with a disclosure button that says whether it is open. Zoomed in, the
* child rows are part of the rail's single pill and its arrow-key order; when
* the child that is active is folded away inside a closed list, the parent
* holds the pill so the rail still shows a place.
*
* Folded, the same list becomes a flyout to the side of the rail, opened by
* hover or focus and kept out of the rail's clipping so a narrow column can
* still show names. The parent is not the flyout's trigger in the sense a menu
* is: the child rows are links in a real `
`, and the button beside the
* parent is a disclosure with `aria-expanded` and `aria-controls`. One level is
* supported; a child list is not meant to contain another `NavRail.Sub`, and
* deeper trees are the caller's own component.
*
* The open state is the parent's, not the rail's: `NavRail.Sub` takes
* `defaultOpen`, or `open` and `onOpenChange` when the app holds it, and it
* does not change when the rail folds. An open list becomes a pinned flyout
* folded, and hover opens one without changing that state.
*
* ## Two weights
*
* `variant="tonal"`, the default, keeps the current place as a quiet primary
* tint with a short accent bar — the right volume for a rail that is part of
* the app's chrome and is on screen the whole time. `variant="solid"` fills the
* row with the primary colour and sets its text in `primary-foreground`, the
* same weight Tabs, Toolbar and Inspector give their chosen item, for an app
* that wants the rail to speak as loudly as the rest of the collection. The
* choice applies folded as well: the icon square, the count dot and the active
* child in a flyout follow it.
*
* ## The keyboard
*
* Every row is an ordinary tab stop, so Tab walks the rail the way it walks
* the rest of the page. Once focus is on a row, Up and Down move it, wrapping
* at the ends and stepping over disabled rows; Home and End go to the first and
* last visible row, skipping children hidden in a closed list. On a parent,
* Right opens a closed list or steps into an open one, Left closes it, and
* Escape closes it wherever focus is inside it. `NavRail.Trigger` is a button
* and says whether the rail is open with `aria-expanded`.
*
* ## It does not collapse itself
*
* There is no viewport-width breakpoint here. Choosing a width on the client
* after hydration makes a server-rendered page jump, and choosing one on the
* server guesses the reader's window. The rail is controlled or uncontrolled
* by `collapsed`, so the app decides, and can pass a media query or a stored
* preference without the component having an opinion about either.
*/
import {
Children,
createContext,
isValidElement,
useCallback,
useContext,
useEffect,
useId,
useLayoutEffect,
useMemo,
useRef,
useState,
useSyncExternalStore,
type ComponentProps,
type CSSProperties,
type FocusEvent as ReactFocusEvent,
type KeyboardEvent,
type MouseEvent as ReactMouseEvent,
type PointerEvent as ReactPointerEvent,
type ReactElement,
type ReactNode,
} from 'react';
import { tv } from 'tailwind-variants';
import { mergeProps } from '@base-ui/react/merge-props';
import { useRender } from '@base-ui/react/use-render';
import type { ElementType as RenderElementType } from 'react';
import { Sheet } from '../sheet';
import { indicatorBox, isRovingKey, railWidth, rovingRow, activeRowIndex, subKeyAction, textOf, type RailRowState } from './rail';
/** Draws a part as another element, or composes it with a component: `render={}`. */
type RenderProp = { render?: useRender.ComponentProps['render'] };
/** How loudly the active row is drawn: a quiet tint, or the primary fill. */
export type NavRailVariant = 'tonal' | 'solid';
/** What folding does: to icons, right out of the layout, or nothing at all. */
export type NavRailCollapsible = 'icon' | 'offcanvas' | 'none';
/** Which edge of the shell the rail sits on. */
export type NavRailSide = 'start' | 'end';
/** One curve for the width, the pill and the labels, so they move as one thing. */
const EASE = 'ease-[cubic-bezier(0.32,0.72,0,1)]';
/**
* The rail's surface. `--muted` is a translucent tint in the theme, so it is
* laid over an opaque page colour instead of being mixed with it: that keeps
* the header and the footer able to cover the rows that scroll beneath them.
*/
const SURFACE = 'bg-background bg-[linear-gradient(var(--muted),var(--muted))]';
const navRailVariants = tv({
slots: {
root: [
// Above the page beside it, so a folded label or flyout is never covered
// by the inset.
'group/nav-rail relative isolate z-10 flex h-full w-(--nav-rail-width) shrink-0 flex-col gap-1 overflow-y-auto overscroll-contain rounded-2xl p-2',
`${SURFACE} text-foreground ring-1 ring-foreground/[0.045] dark:ring-foreground/[0.08]`,
`transition-[width,opacity,visibility] duration-300 ${EASE} motion-reduce:transition-none`,
'[scrollbar-width:thin]',
// Folded right out of the layout, the rail keeps no width, padding or
// surface, and leaves the tab order once the fade ends. An outside
// trigger is what brings it back.
'data-[collapsible=offcanvas]:data-[collapsed]:invisible data-[collapsible=offcanvas]:data-[collapsed]:w-0 data-[collapsible=offcanvas]:data-[collapsed]:gap-0 data-[collapsible=offcanvas]:data-[collapsed]:p-0 data-[collapsible=offcanvas]:data-[collapsed]:opacity-0 data-[collapsible=offcanvas]:data-[collapsed]:ring-0 data-[collapsible=offcanvas]:data-[collapsed]:pointer-events-none',
// In a drawer, the surface is the sheet: no width, no rounding, no ring.
'data-[mobile]:h-full data-[mobile]:w-full data-[mobile]:rounded-none data-[mobile]:p-3 data-[mobile]:ring-0',
],
header: [
`sticky top-0 z-20 flex shrink-0 items-center gap-2 rounded-t-[inherit] px-0.5 pb-1 ${SURFACE}`,
'group-data-[collapsed]/nav-rail:flex-col group-data-[collapsed]/nav-rail:gap-1 group-data-[collapsed]/nav-rail:pb-0',
],
content: 'flex min-h-0 flex-col gap-0.5',
rail: [
'absolute inset-y-6 z-30 hidden w-2 touch-none cursor-ew-resize rounded-full bg-transparent outline-none',
'transition-colors duration-150 hover:bg-primary/30 focus-visible:bg-primary/30 motion-reduce:transition-none',
'group-data-[side=start]/nav-rail:end-0 group-data-[side=end]/nav-rail:start-0',
'group-data-[collapsible=offcanvas]/nav-rail:hidden group-data-[mobile]/nav-rail:hidden',
'sm:block',
],
brand: [
'group/brand flex min-w-0 flex-1 items-center gap-2.5 rounded-[10px] px-1.5 py-1 text-start outline-none',
'transition-colors duration-150',
'focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset',
'group-data-[collapsed]/nav-rail:flex-none group-data-[collapsed]/nav-rail:justify-center group-data-[collapsed]/nav-rail:gap-0 group-data-[collapsed]/nav-rail:px-0',
],
brandIcon:
'flex size-8 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary [&_img]:size-full [&_img]:rounded-[inherit] [&_img]:object-cover [&_svg]:size-[18px]',
brandLabel: [
'min-w-0 max-w-40 truncate text-sm font-semibold tracking-[-0.01em]',
`transition-[opacity,translate,max-width] duration-300 ${EASE} motion-reduce:transition-none`,
'group-data-[collapsed]/nav-rail:max-w-0 group-data-[collapsed]/nav-rail:-translate-x-1 group-data-[collapsed]/nav-rail:pointer-events-none group-data-[collapsed]/nav-rail:opacity-0',
],
trigger: [
'inline-flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-lg text-muted-foreground outline-none',
'transition-[background-color,color,scale] duration-150 hover:bg-foreground/[0.06] hover:text-foreground',
'focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset active:scale-95 motion-reduce:transition-none',
],
triggerGlyph: `size-4 transition-transform duration-300 ${EASE} motion-reduce:transition-none`,
group: 'flex flex-col gap-0.5',
// The heading and the divider share the row: one fades out as the other
// fades in, so a group keeps its height folded and open.
groupLabel: 'relative flex h-7 shrink-0 items-center overflow-hidden px-2.5',
groupLabelText: [
'min-w-0 flex-1 truncate text-[10px] font-semibold tracking-[0.09em] text-muted-foreground/70 uppercase',
'transition-opacity duration-200 motion-reduce:transition-none',
'group-data-[collapsed]/nav-rail:pointer-events-none group-data-[collapsed]/nav-rail:opacity-0',
],
groupLabelDivider: [
'pointer-events-none absolute inset-x-2 h-px rounded-full bg-border opacity-0',
'transition-opacity duration-200 motion-reduce:transition-none',
'group-data-[collapsed]/nav-rail:opacity-100',
],
item: [
'group/item relative z-10 flex h-10 w-full shrink-0 cursor-pointer items-center gap-2.5 rounded-[10px] px-2.5 text-sm font-medium outline-none select-none',
'text-muted-foreground transition-colors duration-150 hover:bg-foreground/[0.05] hover:text-foreground',
'data-active:text-foreground data-active:hover:bg-foreground/[0.03]',
'data-[holding]:text-foreground data-[holding]:hover:bg-foreground/[0.03]',
'data-[expanded]:bg-foreground/[0.05] data-[expanded]:text-foreground',
'data-solid-active:text-primary-foreground! data-solid-active:hover:bg-transparent',
'data-[holding]:data-solid-active:text-primary-foreground!',
'data-disabled:pointer-events-none data-disabled:opacity-40',
'focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset',
'data-[icons-only]:justify-center data-[icons-only]:gap-0 data-[icons-only]:px-0',
'data-[nested]:h-9 data-[nested]:text-[13px]',
// A child in a flyout has no pill behind it, so it carries its own
// active weight: the same tint, ring and solid fill the rail gives the
// row it draws the pill over.
'data-[flyout]:data-active:bg-primary/[0.12] data-[flyout]:data-active:ring-1 data-[flyout]:data-active:ring-primary/20 data-[flyout]:data-active:ring-inset',
'data-[flyout]:data-solid-active:bg-primary data-[flyout]:data-solid-active:ring-0',
],
icon: [
'flex size-5 shrink-0 items-center justify-center text-muted-foreground',
'transition-colors duration-150 group-hover/item:text-foreground group-data-[active]/item:text-primary',
'group-data-[solid-active]/item:text-primary-foreground!',
'group-data-[nested]/item:[&_svg]:size-4',
// The parent of the active child is tinted rather than pilled: it is a
// sign that the current page is under it, not a second current place.
'group-data-[child-active]/item:text-primary',
'[&_svg]:pointer-events-none [&_svg]:size-[18px]',
],
label: [
'min-w-0 max-w-full flex-1 truncate whitespace-nowrap',
`transition-[opacity,translate,max-width] duration-300 ${EASE} motion-reduce:transition-none`,
'group-data-[icons-only]/item:max-w-0 group-data-[icons-only]/item:-translate-x-1 group-data-[icons-only]/item:pointer-events-none group-data-[icons-only]/item:opacity-0',
],
badges: [
'pointer-events-none ms-auto flex shrink-0 items-center gap-1',
'group-data-[icons-only]/item:absolute group-data-[icons-only]/item:end-0.5 group-data-[icons-only]/item:top-0.5 group-data-[icons-only]/item:ms-0',
'group-data-[icons-only]/item:[&>*+*]:hidden',
],
badge: [
'inline-flex h-5 min-w-5 shrink-0 items-center justify-center overflow-hidden rounded-full px-1.5',
'bg-foreground/[0.07] text-[11px] font-medium text-muted-foreground tabular-nums',
'transition-colors duration-150 group-data-[active]/item:bg-primary/15 group-data-[active]/item:text-foreground',
'group-data-[solid-active]/item:bg-primary-foreground/20! group-data-[solid-active]/item:text-primary-foreground!',
'group-data-[icons-only]/item:group-data-[solid-active]/item:bg-primary-foreground!',
// Folded, the count is a dot: the label is gone and a number would have
// nowhere to sit, but the fact that something is waiting still reads.
'group-data-[icons-only]/item:size-2 group-data-[icons-only]/item:min-w-0 group-data-[icons-only]/item:bg-primary group-data-[icons-only]/item:p-0 group-data-[icons-only]/item:text-[0px] group-data-[icons-only]/item:text-transparent',
],
tooltip: [
'pointer-events-none fixed z-50 origin-left -translate-y-1/2',
'rounded-md bg-foreground px-2 py-1 text-xs font-medium whitespace-nowrap text-background shadow-md',
],
// A parent and its child list. The wrapper is what the flyout is positioned
// against, and what hover and focus are read from.
branch: 'group/branch relative flex w-full flex-col',
toggle: [
'absolute end-1 top-5 z-20 flex size-6 -translate-y-1/2 cursor-pointer items-center justify-center rounded-md text-muted-foreground/70 outline-none',
'transition-[opacity,background-color,color,scale] duration-150 hover:bg-foreground/[0.06] hover:text-foreground',
'focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset active:scale-95 motion-reduce:transition-none',
'group-data-[solid-active]/branch:text-primary-foreground/80',
],
chevron: `size-3.5 shrink-0 opacity-70 transition-transform duration-200 ${EASE} motion-reduce:transition-none`,
descendantDot: 'size-1.5 shrink-0 rounded-full bg-primary group-data-[icons-only]/item:hidden',
// Inline, the list unfolds by grid rows so its height travels rather than
// popping. Folded, the same element becomes the flyout beside the rail,
// with the tooltip's fade and scale.
sub: [
'grid grid-rows-[0fr] opacity-0 transition-[grid-template-rows,opacity] duration-200',
`${EASE} motion-reduce:transition-none`,
'data-[open]:grid-rows-[1fr] data-[open]:opacity-100',
'group-data-[collapsed]/nav-rail:pointer-events-none group-data-[collapsed]/nav-rail:fixed group-data-[collapsed]/nav-rail:top-0 group-data-[collapsed]/nav-rail:z-50 group-data-[collapsed]/nav-rail:grid-rows-[1fr] group-data-[collapsed]/nav-rail:origin-left group-data-[collapsed]/nav-rail:scale-95 group-data-[collapsed]/nav-rail:ps-2 group-data-[collapsed]/nav-rail:pe-0 group-data-[collapsed]/nav-rail:opacity-0 group-data-[collapsed]/nav-rail:transition-[opacity,scale] group-data-[collapsed]/nav-rail:duration-150',
'group-data-[side=end]/nav-rail:group-data-[collapsed]/nav-rail:ps-0 group-data-[side=end]/nav-rail:group-data-[collapsed]/nav-rail:pe-2',
'group-data-[collapsed]/nav-rail:data-[visible]:pointer-events-auto group-data-[collapsed]/nav-rail:data-[visible]:scale-100 group-data-[collapsed]/nav-rail:data-[visible]:opacity-100',
],
subPanel: [
'min-h-0 overflow-hidden',
// The flyout's own surface, kept on the inner element so the outer one
// can stay the transition and arrow-key container.
'group-data-[collapsed]/nav-rail:min-w-52 group-data-[collapsed]/nav-rail:max-h-[calc(100dvh-1rem)] group-data-[collapsed]/nav-rail:overflow-y-auto group-data-[collapsed]/nav-rail:rounded-xl group-data-[collapsed]/nav-rail:border group-data-[collapsed]/nav-rail:border-border group-data-[collapsed]/nav-rail:bg-popover group-data-[collapsed]/nav-rail:p-1 group-data-[collapsed]/nav-rail:text-popover-foreground group-data-[collapsed]/nav-rail:shadow-lg',
],
// A folded child list is shown away from the rail, where the parent's row
// is no longer beside it: its name and mark head the flyout, so the
// children are never shown without the branch they belong to.
subHeader: [
'hidden items-center gap-2 border-b border-border/60 px-2 pb-1.5 pt-1',
'group-data-[collapsed]/nav-rail:flex',
],
subHeaderIcon: 'flex size-4 shrink-0 items-center justify-center text-muted-foreground [&_svg]:size-3.5',
subHeaderLabel:
'min-w-0 truncate text-[10px] font-semibold tracking-[0.09em] text-muted-foreground uppercase',
subList: [
'flex flex-col gap-0.5',
// The indent and the rule are what make a child read as subordinate
// rather than as a row that happens to be smaller.
'ms-2.5 border-s border-border/60 ps-2',
'group-data-[collapsed]/nav-rail:ms-0 group-data-[collapsed]/nav-rail:border-s-0 group-data-[collapsed]/nav-rail:ps-0',
],
subEntry: 'flex w-full min-w-0',
separator: 'mx-1.5 h-px shrink-0 rounded-full bg-border group-data-[collapsed]/nav-rail:mx-0.5',
footer: [
`sticky bottom-0 z-20 mt-auto flex shrink-0 flex-col gap-0.5 rounded-b-[inherit] pt-1 ${SURFACE}`,
],
inset: [
'relative flex min-w-0 flex-1 flex-col overflow-hidden rounded-xl bg-background ring-1 ring-border/70',
],
provider: 'group/nav-rail-shell flex min-h-svh w-full',
// One pill for the whole rail. The accent is its own small bar so the fill
// can stay a tint rather than a solid block of colour.
indicator: [
'pointer-events-none absolute top-(--indicator-y) left-(--indicator-x) z-0 h-(--indicator-h) w-(--indicator-w) rounded-[10px]',
'bg-primary/[0.12] opacity-0 ring-1 ring-primary/20 ring-inset',
'group-data-[variant=solid]/nav-rail:bg-primary group-data-[variant=solid]/nav-rail:ring-0',
"group-data-[collapsed]/nav-rail:before:hidden group-data-[variant=solid]/nav-rail:before:hidden",
"before:absolute before:inset-y-2.5 before:start-1 before:w-[3px] before:rounded-full before:bg-primary before:content-['']",
'data-ready:opacity-100',
'data-ready:transition-[left,top,width,height] data-ready:duration-300 data-ready:ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:transition-none',
],
},
});
export interface NavRailContextValue {
/** Whether the rail is folded. In a drawer this is always `false`. */
collapsed: boolean;
variant: NavRailVariant;
collapsible: NavRailCollapsible;
side: NavRailSide;
/** Whether the rail is drawn as a drawer rather than in the layout. */
mobile: boolean;
/** Whether the viewport is below the shell's mobile breakpoint. */
isMobile: boolean;
/** Whether the drawer is open. */
mobileOpen: boolean;
setCollapsed(next: boolean): void;
setMobileOpen(open: boolean): void;
toggle(): void;
}
const NavRailContext = createContext(null);
/**
* Reads the rail's state from inside a `NavRail.Provider` or a `NavRail`.
*
* Use it for a trigger in the page's own chrome, beside the rail: a menu
* button in the top bar, a keyboard hint, a stored preference.
*/
export function useNavRail(): NavRailContextValue {
const context = useContext(NavRailContext);
if (!context) throw new Error('useNavRail must be used inside a or a .');
return context;
}
function useNavRailPart(part: string): NavRailContextValue {
const context = useContext(NavRailContext);
if (!context) throw new Error(`${part} must be used inside a .`);
return context;
}
/**
* Whether the viewport is below a breakpoint, read in a way that is safe for a
* server render: the server draws the wide layout, and the first client frame
* corrects it without a hydration mismatch.
*/
function useIsBelow(breakpoint: string): boolean {
const subscribe = useCallback(
(onChange: () => void) => {
if (typeof window === 'undefined') return () => {};
const query = window.matchMedia(`(max-width: ${breakpoint})`);
query.addEventListener('change', onChange);
return () => query.removeEventListener('change', onChange);
},
[breakpoint]
);
const read = useCallback(
() => typeof window !== 'undefined' && window.matchMedia(`(max-width: ${breakpoint})`).matches,
[breakpoint]
);
return useSyncExternalStore(subscribe, read, () => false);
}
interface NavRailSubContextValue {
/** Whether the child list is logically open. */
open: boolean;
/** Whether it is drawn: open inline, or showing as a flyout. */
visible: boolean;
/** The id of the `
`, for the disclosure's `aria-controls`. */
listId: string;
/** The parent's accessible name, used to name the list. */
name?: string;
/** The parent's mark, shown at the head of a folded flyout. */
icon?: ReactNode;
/** Whether the rail is folded, so the children live in a flyout. */
folded: boolean;
/** Opens or closes the list from the parent row. */
toggle(): void;
}
const NavRailSubContext = createContext(null);
/** True for an item drawn inside a child list, so it is indented and quieter. */
const NavRailNestedContext = createContext(false);
/** True for an item drawn inside a folded flyout, where it keeps its label. */
const NavRailFlyoutContext = createContext(false);
const useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;
/**
* Sets `inert` on an element while it is out of sight.
*
* Passed as a prop, a boolean would be written differently by different React
* versions; set on the node, it is the attribute the browser reads.
*/
function useInert(inert: boolean) {
const ref = useRef(null);
useIsomorphicLayoutEffect(() => {
ref.current?.toggleAttribute('inert', inert);
}, [inert]);
return ref;
}
/**
* Whether a `NavRail.Sub`'s direct children include the active destination.
*
* Only the elements the caller passes are read: a child drawn by a wrapper
* component cannot be seen here, and the parent simply goes without its
* secondary marker. One level is the supported shape.
*/
function subHasActive(sub: ReactElement): boolean {
const children = (sub.props as { children?: ReactNode }).children;
return Children.toArray(children).some(
(child) => isValidElement(child) && (child.props as { active?: boolean }).active === true
);
}
/**
* Reads a row's state for focus movement and the pill.
*
* A child in a folded flyout is not part of the rail's own order: the flyout
* has its own reading order when focus is inside it, and the pill stays on the
* parent in the rail.
*/
function railRowState(row: HTMLElement, collapsed: boolean): RailRowState {
const branch = row.closest('[data-slot="nav-rail-branch"]');
const owns = branch !== null && row.parentElement === branch;
const sub = owns ? branch.querySelector(':scope > [data-slot="nav-rail-sub"]') : null;
const container = row.closest('[data-slot="nav-rail-sub"]');
const hidden = container ? collapsed || !container.hasAttribute('data-open') : false;
return {
active: row.hasAttribute('data-active'),
disabled: row.getAttribute('aria-disabled') === 'true' || row.hasAttribute('disabled'),
hidden,
branch: owns,
expanded: sub?.hasAttribute('data-open') ?? false,
childActive: row.hasAttribute('data-child-active'),
nested: container !== null,
};
}
export interface NavRailProps extends Omit, 'className'> {
/** Whether the rail is folded. Pass it with `onCollapsedChange` to hold the state yourself. */
collapsed?: boolean;
/** Whether it starts folded, when the caller does not hold it. Default `false`. */
defaultCollapsed?: boolean;
/** Called when the rail asks to fold or unfold. */
onCollapsedChange?: (collapsed: boolean) => void;
/** Its width open, as pixels or any CSS length. Default `15rem`. */
expandedWidth?: number | string;
/** Its width folded, as pixels or any CSS length. Default `3.5rem`. */
collapsedWidth?: number | string;
/**
* What folding does. `icon` keeps a column of icon squares, `offcanvas`
* takes the rail out of the layout entirely, and `none` keeps it open and
* ignores the fold entirely. Default `icon`.
*/
collapsible?: NavRailCollapsible;
/** Which edge of the shell it sits on, for the rail handle and the drawer. Default `start`. */
side?: NavRailSide;
/**
* How loudly the active row is drawn. `tonal` is a quiet primary tint with an
* accent bar; `solid` is the primary fill and `primary-foreground` text that
* Tabs, Toolbar and Inspector use. Default `tonal`.
*/
variant?: NavRailVariant;
className?: string;
}
/**
* The rail. It is a `