Skip to Content
MavKitOne is in beta. @mav-labs-inc/mavkit-react is not public packages yet.
ComponentsSidebar

Sidebar

SidebarLayout renders a .sidebar-layout wrapper and enhances a hand-authored .sidebar panel, optional .sidebar-backdrop, and .sidebar-close inside it — four built-in layout behaviors (beside/over/fixed/under-navbar), outside-click/Escape, focus trapping on mobile overlays, and URL-based active-item detection. Compound subcomponents (Sidebar, SidebarHeader, SidebarBody, SidebarSection, SidebarItem, SidebarFooter, SidebarMain) remove the markup boilerplate, but hand-authoring the raw .sidebar-* tree works exactly the same.

Usage

import { SidebarLayout, Sidebar, SidebarHeader, SidebarBody, SidebarSection, SidebarItem, SidebarMain, SidebarToggle, } from '@mav-labs-inc/mavkit-react' // Uncontrolled, closed by default <SidebarLayout variant="over" position="end"> <Sidebar> <SidebarHeader title="Menu" /> <SidebarBody> <SidebarSection label="Main"> <SidebarItem href="/" active>Home</SidebarItem> </SidebarSection> </SidebarBody> </Sidebar> <SidebarMain> <SidebarToggle>Menu</SidebarToggle> … </SidebarMain> </SidebarLayout> // Controlled, like Modal <SidebarLayout variant="over" open={isOpen} onOpenChange={setIsOpen}>…</SidebarLayout>

Example

variant="over" — click “Menu” to open the panel over the content.

Props

SidebarLayout

PropTypeDefaultDescription
variant'beside' | 'over' | 'fixed' | 'under-navbar'—One of the four built-in layout behaviors.
position'start' | 'end''start'Which edge the panel is anchored to.
openboolean—Controlled open state — call onOpenChange to flip it, mirroring Modal's open/onClose.
onOpenChange(open: boolean) => void—
defaultOpenbooleanfalseUncontrolled mode only — initial open state.
closeOnOutsidebooleantrue
closeOnEscapebooleantrue
mobileBackdropbooleantrueWhether fixed shows the dark backdrop once it collapses to a mobile drawer (≤768px). No effect on beside (never a backdrop) or over/under-navbar (always one).
onOpened() => void—
onClosed() => void—
classNamestring—
refRef<SidebarController>—{ isOpen, panelId, open(), close(), toggle() }

Renders the sliding panel + its backdrop as siblings (a Fragment).

PropTypeDefaultDescription
idstring—Auto-generated if omitted.
ariaLabelstring'Navigation'Ignored if aria-labelledby is set.
aria-labelledbystring—
classNamestring—

SidebarHeader

PropTypeDefaultDescription
titleReactNode—
showClosebooleantrueShow the built-in .sidebar-close button.
childrenReactNode—Overrides title entirely — the close button (if showClose) still renders after it.

SidebarSection

PropTypeDefaultDescription
labelReactNode—Uppercase group heading. Omit for an unlabeled group.

SidebarItem

Renders an <a> when href is given (auto-closes an overlay panel on click), otherwise a <button type="button"> for non-navigation actions.

PropTypeDefaultDescription
activeboolean—Marks this item as the current page.
disabledboolean—
iconReactNode—
badgeReactNode—
hrefstring—Renders an <a> instead of a <button>.

Also accepts every native <a>/<button> attribute (whichever it renders).

SidebarBody / SidebarFooter / SidebarMain

Thin wrappers rendering .sidebar-body / .sidebar-footer / .sidebar-main — accept only className/children.

SidebarToggle

Companion toggle button consuming the enclosing SidebarLayout context (or an explicit controller prop for a toggle rendered outside it).

PropTypeDefaultDescription
controllerSidebarController | null—Pass a layout ref's controller when the toggle lives outside SidebarLayout.

Also accepts every native <button> attribute.

useSidebar()

Access the enclosing SidebarLayout controller — for building a custom toggle.

Last updated on