Command palette

@yasinsensoy/web

Web · Components

Sidebar

The app's main navigation menu: a sidebar on the left with the page content next to it.

8 exports

Live example

Preview

Inbox

Card 1

The mobile bar can hide on scroll.

Sample content. On desktop the sidebar collapses into an icon strip; on narrow screens it becomes a top bar or a bottom navigation bar.

Card 2

The mobile bar can hide on scroll.

Sample content. On desktop the sidebar collapses into an icon strip; on narrow screens it becomes a top bar or a bottom navigation bar.

Card 3

The mobile bar can hide on scroll.

Sample content. On desktop the sidebar collapses into an icon strip; on narrow screens it becomes a top bar or a bottom navigation bar.

Card 4

The mobile bar can hide on scroll.

Sample content. On desktop the sidebar collapses into an icon strip; on narrow screens it becomes a top bar or a bottom navigation bar.

Card 5

The mobile bar can hide on scroll.

Sample content. On desktop the sidebar collapses into an icon strip; on narrow screens it becomes a top bar or a bottom navigation bar.

Card 6

The mobile bar can hide on scroll.

Sample content. On desktop the sidebar collapses into an icon strip; on narrow screens it becomes a top bar or a bottom navigation bar.

Code

import { Sidebar, UserMenusu } from "@yasinsensoy/web";

// app/(panel)/layout.tsx
<Sidebar mobile="bottom" storageKey="sidebar"
  header={<Logo />}
  footer={<UserMenusu />}
  items={[
    { label: "Ana sayfa", href: "/", icon: "home" },
    { label: "Gelen kutusu", href: "/inbox", icon: "mail", badge: 12 },
    { label: "Projects", icon: "folder", items: [
      { label: "Store", href: "/projects/store" },
      { label: "Blog", href: "/projects/blog", badge: "New" },
      { label: "Admin panel", href: "/projects/panel" },
    ] },
    { label: "Favorites", href: "/favorites", icon: "heart", badge: true, badgeTone: "danger" },
    { group: "Hesap", items: [
      { label: "Ekip", href: "/ekip", icon: "user" },
      { label: "Ayarlar", href: "/ayarlar", icon: "settings" },
    ] },
  ]}
>
  {children}
</Sidebar>

Events

  1. Events appear here when you interact with the preview.

Bottom navigation bar on phones: badges, bottom sheet menu, “More”

Inbox

Card 1

The mobile bar can hide on scroll.

Sample content. On desktop the sidebar collapses into an icon strip; on narrow screens it becomes a top bar or a bottom navigation bar.

Card 2

The mobile bar can hide on scroll.

Sample content. On desktop the sidebar collapses into an icon strip; on narrow screens it becomes a top bar or a bottom navigation bar.

Card 3

The mobile bar can hide on scroll.

Sample content. On desktop the sidebar collapses into an icon strip; on narrow screens it becomes a top bar or a bottom navigation bar.

Card 4

The mobile bar can hide on scroll.

Sample content. On desktop the sidebar collapses into an icon strip; on narrow screens it becomes a top bar or a bottom navigation bar.

Card 5

The mobile bar can hide on scroll.

Sample content. On desktop the sidebar collapses into an icon strip; on narrow screens it becomes a top bar or a bottom navigation bar.

Card 6

The mobile bar can hide on scroll.

Sample content. On desktop the sidebar collapses into an icon strip; on narrow screens it becomes a top bar or a bottom navigation bar.

Top bar and a menu from the left on phones (mobile="sheet")

AAcme

Inbox

Card 1

The mobile bar can hide on scroll.

Sample content. On desktop the sidebar collapses into an icon strip; on narrow screens it becomes a top bar or a bottom navigation bar.

Card 2

The mobile bar can hide on scroll.

Sample content. On desktop the sidebar collapses into an icon strip; on narrow screens it becomes a top bar or a bottom navigation bar.

Card 3

The mobile bar can hide on scroll.

Sample content. On desktop the sidebar collapses into an icon strip; on narrow screens it becomes a top bar or a bottom navigation bar.

Card 4

The mobile bar can hide on scroll.

Sample content. On desktop the sidebar collapses into an icon strip; on narrow screens it becomes a top bar or a bottom navigation bar.

Card 5

The mobile bar can hide on scroll.

Sample content. On desktop the sidebar collapses into an icon strip; on narrow screens it becomes a top bar or a bottom navigation bar.

Card 6

The mobile bar can hide on scroll.

Sample content. On desktop the sidebar collapses into an icon strip; on narrow screens it becomes a top bar or a bottom navigation bar.

Collapsed icon strip (remembered with storageKey): name tooltip, corner badge, subpages in a menu

Inbox

Card 1

The mobile bar can hide on scroll.

Sample content. On desktop the sidebar collapses into an icon strip; on narrow screens it becomes a top bar or a bottom navigation bar.

Card 2

The mobile bar can hide on scroll.

Sample content. On desktop the sidebar collapses into an icon strip; on narrow screens it becomes a top bar or a bottom navigation bar.

Card 3

The mobile bar can hide on scroll.

Sample content. On desktop the sidebar collapses into an icon strip; on narrow screens it becomes a top bar or a bottom navigation bar.

Card 4

The mobile bar can hide on scroll.

Sample content. On desktop the sidebar collapses into an icon strip; on narrow screens it becomes a top bar or a bottom navigation bar.

Card 5

The mobile bar can hide on scroll.

Sample content. On desktop the sidebar collapses into an icon strip; on narrow screens it becomes a top bar or a bottom navigation bar.

Card 6

The mobile bar can hide on scroll.

Sample content. On desktop the sidebar collapses into an icon strip; on narrow screens it becomes a top bar or a bottom navigation bar.

Import

import { Sidebar } from "@yasinsensoy/web";

SidebarItem

interface

A page link or action inside Sidebar.

NameTypeDefaultDescription
labelReactNodeText of the item. Also shown as a tooltip/label in the collapsed strip and the bottom bar.
href?stringAddress of the page. Internal addresses are rendered with the link component given to UIProvider (Next.js Link); external addresses (https://…) open in a new tab. If omitted, the item is a button (onSelect) or toggles its sub-items.
icon?IconPropIcon: name ("home") or element. Only the icon shows in the collapsed strip; only items with an icon go into the bottom navigation bar.
badge?number | string | booleanBadge on the right: a number (12; "99+" if above 99, hidden at 0), short text ("New") or true for just a dot. Shown at the icon corner in the collapsed strip and the bottom bar.
badgeTone?Tone"primary"Badge color.
tooltip?TooltipPropTooltip shown on hover. In the collapsed strip, label is shown if omitted. See TooltipProp.
disabled?booleanCan't be selected.
onSelect?(event: MouseEvent<HTMLElement>) => voidCalled when clicked (e.g. to open a "New project" window). If given with href, event.preventDefault() stops navigation. Can't be passed from a server component.
items?readonly SidebarItem[]Sub-pages. In the wide view they become a collapsible list; in the collapsed strip and the bottom bar, pressing the icon opens them as a menu.
defaultOpen?booleanWhether sub-pages start open. If omitted, it starts open if one of them is active.
exact?booleanActive only when the address matches exactly. If omitted, sub-addresses also make the item active (/projects/12 → /projects). / is always compared exactly.
active?booleanSets the active state manually; no address comparison is made.
bottom?booleanWhether it shows in the mobile bottom navigation bar. If even one item has true, only the true ones show in the bar; false removes the item from the bar. If omitted, the first top-level items with an icon go in.

SidebarGroup

interface

Item group with a heading ("Projects", "Settings").

NameTypeDescription
groupReactNodeHeading of the group. Turns into a thin line in the collapsed strip.
itemsreadonly SidebarItem[]Items in the group.

Element of the Sidebar items array: an item, a group or a "separator" line.

type SidebarEntry = SidebarItem | SidebarGroup | "separator"

What replaces the sidebar on small screens?

  • "sheet": A thin bar at the top (☰ button and header); the menu opens in a window sliding from the left.
  • "bottom": A navigation bar with icons at the bottom, like in apps. Items that don't fit, groups and footer are in the "More" window in the last tab.
type SidebarMobile = "sheet" | "bottom"

Threshold between the desktop and mobile view: 640, 768 or 1024 px.

type SidebarBreakpoint = "sm" | "md" | "lg"

Classes that can be passed to the inner parts of Sidebar.

NameTypeDescription
root?stringRoot wrapping the sidebar and the page.
aside?stringThe sidebar on desktop.
content?stringColumn holding the page content (children).
topBar?stringMobile top bar (mobile="sheet").
bottomBar?stringMobile bottom navigation bar (mobile="bottom").

SidebarProps

interface

Props of the Sidebar component.

NameTypeDefaultDescription
itemsreadonly SidebarEntry[]Items, groups with headings and "separator" lines. See SidebarEntry.
children?ReactNodeContent of the page; rendered in the column next to the sidebar.
header?ReactNodeTop area: logo, app name, team switcher. In the collapsed strip only the sidebar's width of it is visible; so put the icon/logo first. Also shown in the mobile top bar while mobile="sheet".
footer?ReactNodeBottom area: user menu, settings. Shown at the bottom of the "More" window while mobile="bottom".
mobile?SidebarMobile"sheet"View on small screens. See SidebarMobile.
breakpoint?SidebarBreakpoint"md"Threshold for switching to the mobile view. See SidebarBreakpoint.
responsive?"viewport" | "container""viewport"What is the threshold measured against? "viewport" is the screen width; "container" the width of the box wrapping the sidebar (split views, preview frames). While "container", position: fixed elements inside the root are positioned relative to the root.
collapsible?booleantrueWhether it can collapse to an icon strip on desktop. A collapse button and shortcut are added.
collapsed?booleanWhether it is collapsed in controlled use.
defaultCollapsed?booleanfalseWhether it starts collapsed in uncontrolled use.
onCollapsedChange?(collapsed: boolean) => voidCalled with the new state when collapsed or expanded.
storageKey?stringThe collapsed state is stored in the browser under this name and remembered on the next visit (e.g. "sidebar"). The page is drawn at the right width on first paint; no flicker.
shortcut?string | false"Mod+B"Collapse/expand shortcut (see MenuItem.shortcut); false turns it off. Works inside text fields too, without breaking text editing.
bottomCount?number5Maximum number of tabs in the bottom bar while mobile="bottom" (including "More"). SidebarItem.bottom decides which items go in.
hideOnScroll?booleanfalseWhether the mobile bar hides while scrolling down and comes back when scrolling up. Frees more screen space on reading-heavy pages.
currentPath?stringPath of the current page. If omitted, it is read from the UIProvider usePathname hook (automatic in Next.js). The active item is the longest matching href.
mobileOpen?booleanWhether the mobile menu window (☰ or "More") is open in controlled use.
onMobileOpenChange?(open: boolean) => voidCalled when the mobile menu window opens or closes.
label?string{@link UIProvider} text ("Ana menü")Screen reader name of the navigation region.
width?string"16rem"Width of the sidebar (CSS length).
className?stringClasses added to the root.
classNames?SidebarClassNamesClasses added to the inner parts.
style?CSSPropertiesStyles added to the root.
effect?EffectPropEffect or effects of the item rows (also plays on the active row) (e.g. "ripple", ["border", "glow"]). If omitted, UIProvider appearance.defaults.sidebar.effect. See BuiltinEffect.