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.
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
Code
Events
- Events appear here when you interact with the preview.
Bottom navigation bar on phones: badges, bottom sheet menu, “More”
Top bar and a menu from the left on phones (mobile="sheet")
Collapsed icon strip (remembered with storageKey): name tooltip, corner badge, subpages in a menu
Import
Sidebar
componentThe 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. Same items data as the web Sidebar: icon, badge, groups with headings and nested sub-pages. The current screen is marked automatically from the Navigator path.
- Collapsing: On wide screens it collapses to an icon rail (button, animated). In the rail names become tooltips, badges sit at the icon corner, sub-pages become a menu opening to the right. The state is remembered with
storageKey(+storage). - Mobile:
mobile="sheet"is a ☰ bar at the top and a menu from the left;mobile="bottom"is an icon tab bar at the bottom and a "Daha fazla" window. Windows close with the back button, by swiping and on item press. Bars respect the notch and home indicator insets;hideOnScrollhides them while scrolling. - Accessibility: The active item is announced as selected, sub-lists report their expanded/collapsed state, group headings are read as headings.
Examples
SidebarItem
interfaceA page link or action inside Sidebar (same fields as web).
| Name | Type | Default | Description |
|---|---|---|---|
label | ReactNode | Item text. Also shown as a tooltip/label in the collapsed rail and the bottom bar. | |
href? | string | Page 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? | IconProp | Icon: 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 | boolean | Badge 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? | TooltipProp | Tooltip shown on long press. In the collapsed rail label is shown if omitted. | |
disabled? | boolean | Cannot be selected. | |
onSelect? | (event: MenuSelectEvent) => void | Called 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? | boolean | Are the sub-pages initially open? If omitted it starts open when one of them is active. | |
exact? | boolean | Active only when the address matches exactly. If omitted, sub-addresses also make the item active (/projects/12 → /projects). / is always compared exactly. | |
active? | boolean | Sets the active state manually; no address comparison is made. | |
bottom? | boolean | Show 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
interfaceItem group with a heading ("Projects", "Settings").
| Name | Type | Description |
|---|---|---|
group | ReactNode | Group heading. Becomes a thin line in the collapsed rail. |
items | readonly SidebarItem[] | Items in the group. |
SidebarEntry
typeAn element of the Sidebar items array: an item, a group or a "separator" line.
SidebarMobile
typeWhat replaces the sidebar on small screens?
"sheet": A thin bar at the top (☰ button andheader); 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 thefooterare in the "Daha fazla" (more) window on the last tab.
Threshold between the desktop (tablet) and mobile views: 640, 768 or 1024 dp.
SidebarStyles
interfaceStyles of the Sidebar inner parts.
| Name | Type | Description |
|---|---|---|
root? | ViewStyle | Root wrapping the sidebar and the content. |
aside? | ViewStyle | Sidebar on wide screens. |
content? | ViewStyle | Column holding the content (children). |
topBar? | ViewStyle | Mobile top bar (mobile="sheet"). |
bottomBar? | ViewStyle | Mobile bottom navigation bar (mobile="bottom"). |
item? | ViewStyle | Item row. |
SidebarProps
interfaceProps of the Sidebar component (same names as web).
| Name | Type | Default | Description |
|---|---|---|---|
items | readonly SidebarEntry[] | Items, groups with headings and "separator" lines. See SidebarEntry. | |
children? | ReactNode | Screen content; drawn in the column next to the sidebar. | |
header? | ReactNode | Top 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? | ReactNode | Bottom 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? | boolean | true | Can it collapse to an icon rail on wide screens? Adds a collapse button. |
collapsed? | boolean | Collapsed, in controlled use? | |
defaultCollapsed? | boolean | false | Initially collapsed, in uncontrolled use? |
onCollapsedChange? | (collapsed: boolean) => void | Called with the new state when collapsed or expanded. | |
storageKey? | string | The collapsed state is stored under this name and remembered on the next launch (e.g. "sidebar"). Pass storage to make it persistent. | |
storage? | PreferenceStorage | Where the collapsed state is stored (a @yasinsensoy/native/storage store can be passed directly). | |
bottomCount? | number | 5 | Maximum number of tabs in the bottom bar when mobile="bottom" (including "Daha fazla"). SidebarItem.bottom decides which items are included. |
hideOnScroll? | boolean | false | Should the mobile bar hide while scrolling down and come back when scrolling up? Pass the content's scroll tracker via scroll. |
scroll? | ScrollTracker | The content's scroll tracker (useScrollTracker); for hideOnScroll. | |
currentPath? | string | Path of the current screen. If omitted it is read from Navigator via useCurrentPath. The active item is the longest matching href. | |
mobileOpen? | boolean | Is the mobile menu window (☰ or "Daha fazla") open, in controlled use? | |
onMobileOpenChange? | (open: boolean) => void | Called when the mobile menu window opens or closes. | |
label? | string | "Ana menü" | Screen reader name of the navigation region. |
width? | number | 256 | Sidebar width (dp). |
railWidth? | number | 56 | Width of the collapsed rail (dp). |
styles? | SidebarStyles | Styles of the inner parts. See SidebarStyles. | |
effect? | EffectProp | Effect of the item rows (e.g. "ripple"). Defaults to appearance.defaults.sidebar.effect. | |
testID? | string | Test id (given to the root). |