Command palette

@yasinsensoy/native

React Native · Components

Sidebar

The app's main navigation menu: on wide screens (tablet) a sidebar on the left with the screen content next to it; on phones a top bar with a menu opening from the left, or a bottom navigation bar.

8 exports

Live example

The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.

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/native";

// 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/native";

SidebarItem

interface

A page link or action inside Sidebar (same fields as web).

NameTypeDefaultDescription
labelReactNodeItem text. Also shown as a tooltip/label in the collapsed rail and the bottom bar.
href?stringPage address: opened with openLink (a path registered in the Navigator in the app, an external URL in the system). If omitted the item is a button (onSelect) or toggles its children.
icon?IconPropIcon: a name or an element. Only the icon shows in the collapsed rail; only items with an icon go into the bottom navigation bar.
badge?number | string | booleanBadge on the right: a number (12; above 99 shows "99+", 0 is hidden), short text ("New") or true for just a dot. Shown at the icon's corner in the collapsed rail and the bottom bar.
badgeTone?Tone"primary"Badge color.
tooltip?TooltipPropTooltip shown on long press. In the collapsed rail label is shown if omitted.
disabled?booleanCannot be selected.
onSelect?(event: MenuSelectEvent) => voidCalled on press (e.g. to open a "New project" dialog). When given with href, event.preventDefault() stops navigation; the mobile drawer and submenu still close.
items?readonly SidebarItem[]Sub-pages. In the wide view it becomes a collapsible list; in the collapsed rail and the bottom bar pressing the icon opens it as a menu.
defaultOpen?booleanAre the sub-pages initially open? If omitted it starts open when 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?booleanShow it in the mobile bottom navigation bar? If even one item is true, only the true ones appear in the bar; false removes the item from the bar. If omitted the first top-level items with an icon are included.

SidebarGroup

interface

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

NameTypeDescription
groupReactNodeGroup heading. Becomes a thin line in the collapsed rail.
itemsreadonly SidebarItem[]Items in the group.

An 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": An icon navigation bar at the bottom, like in apps. Items that do not fit, groups and the footer are in the "Daha fazla" (more) window on the last tab.
type SidebarMobile = "sheet" | "bottom"

Threshold between the desktop (tablet) and mobile views: 640, 768 or 1024 dp.

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

SidebarStyles

interface

Styles of the Sidebar inner parts.

NameTypeDescription
root?ViewStyleRoot wrapping the sidebar and the content.
aside?ViewStyleSidebar on wide screens.
content?ViewStyleColumn holding the content (children).
topBar?ViewStyleMobile top bar (mobile="sheet").
bottomBar?ViewStyleMobile bottom navigation bar (mobile="bottom").
item?ViewStyleItem row.

SidebarProps

interface

Props of the Sidebar component (same names as web).

NameTypeDefaultDescription
itemsreadonly SidebarEntry[]Items, groups with headings and "separator" lines. See SidebarEntry.
children?ReactNodeScreen content; drawn in the column next to the sidebar.
header?ReactNodeTop area: logo, app name, team picker. In the collapsed rail only the rail width is visible, so put the icon/logo first. Also shown in the mobile top bar when mobile="sheet".
footer?ReactNodeBottom area: user menu, settings. On mobile it appears at the bottom of the menu window.
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 the threshold measures: "viewport" the window width; "container" the width of the box wrapping the sidebar (split views).
collapsible?booleantrueCan it collapse to an icon rail on wide screens? Adds a collapse button.
collapsed?booleanCollapsed, in controlled use?
defaultCollapsed?booleanfalseInitially collapsed, in uncontrolled use?
onCollapsedChange?(collapsed: boolean) => voidCalled with the new state when collapsed or expanded.
storageKey?stringThe collapsed state is stored under this name and remembered on the next launch (e.g. "sidebar"). Pass storage to make it persistent.
storage?PreferenceStorageWhere the collapsed state is stored (a @yasinsensoy/native/storage store can be passed directly).
bottomCount?number5Maximum number of tabs in the bottom bar when mobile="bottom" (including "Daha fazla"). SidebarItem.bottom decides which items are included.
hideOnScroll?booleanfalseShould the mobile bar hide while scrolling down and come back when scrolling up? Pass the content's scroll tracker via scroll.
scroll?ScrollTrackerThe content's scroll tracker (useScrollTracker); for hideOnScroll.
currentPath?stringPath of the current screen. If omitted it is read from Navigator via useCurrentPath. The active item is the longest matching href.
mobileOpen?booleanIs the mobile menu window (☰ or "Daha fazla") open, in controlled use?
onMobileOpenChange?(open: boolean) => voidCalled when the mobile menu window opens or closes.
label?string"Ana menü"Screen reader name of the navigation region.
width?number256Sidebar width (dp).
railWidth?number56Width of the collapsed rail (dp).
styles?SidebarStylesStyles of the inner parts. See SidebarStyles.
effect?EffectPropEffect of the item rows (e.g. "ripple"). Defaults to appearance.defaults.sidebar.effect.
testID?stringTest id (given to the root).