Sidebar

Side navigation drawer component

Sidebar component for side navigation and menu systems. Supports left/right/top/bottom positioning with custom menu items, badges, and styling.

Basic Usage

import { Sidebar } from 'prizmux'
import { Home, Settings, LogOut } from 'lucide-react-native'
import { useState } from 'react'

export default function App() {
  const [visible, setVisible] = useState(false)

  const items = [
    {
      id: '1',
      title: 'Home',
      icon: <Home size={20} />,
      onPress: () => navigation.navigate('Home'),
    },
    {
      id: '2',
      title: 'Settings',
      icon: <Settings size={20} />,
      onPress: () => navigation.navigate('Settings'),
    },
  ]

  return (
    <Sidebar
      visible={visible}
      onClose={() => setVisible(false)}
      items={items}
      side="left"
    />
  )
}

Props

PropTypeDefaultRequiredDescription
visiblebooleanSidebar visibility
onClose() => voidClose callback
itemsSidebarMenuItem[]Menu items
side'left' | 'right' | 'top' | 'bottom''right'Slide direction
widthnumberWidth for left/right (% of screen)
heightnumberHeight for top/bottom (% of screen)
offsetTopnumber0Distance from top (left/right only)
offsetSidenumber0Gap from edge
showOverlaybooleantrueShow backdrop overlay
overlayColorstring'rgba(0,0,0,0.3)'Overlay color
dismissOnOverlayPressbooleantrueClose on overlay tap
backgroundColorstring'#FFFFFF'Sidebar background
borderRadiusnumber0Border radius
headerReactNodeHeader element
showHeaderbooleantrueShow header if provided
showIconBackgroundbooleanfalseIcon background circles
iconBackgroundColorstringIcon background color
activeItemColorstring'#F3F4F6'Active item bg color
itemTextColorstring'#111827'Menu text color
shadowbooleantrueDrop shadow
styleViewStyleContainer styles
itemStyleViewStyleMenu item styles
headerStyleViewStyleHeader styles

SidebarMenuItem

PropTypeDefaultRequiredDescription
idstringUnique identifier
titlestringMenu item label
iconReactNodeMenu icon
onPress() => voidPress callback
badgenumber | stringBadge text/number
badgeColorstringBadge background color

Examples

With Badge

const items = [
  {
    id: '1',
    title: 'Messages',
    icon: <Mail size={20} />,
    onPress: () => {},
    badge: '5',
    badgeColor: '#FF6B6B',
  },
  {
    id: '2',
    title: 'Notifications',
    icon: <Bell size={20} />,
    onPress: () => {},
    badge: '12',
  },
]

<Sidebar visible={visible} onClose={() => {}} items={items} />

Left Sidebar

<Sidebar
  visible={visible}
  onClose={() => setVisible(false)}
  items={items}
  side="left"
/>

With Header

<Sidebar
  visible={visible}
  onClose={() => {}}
  items={items}
  header={
    <View style={{ padding: 16 }}>
      <Text style={{ fontSize: 18, fontWeight: 'bold' }}>Menu</Text>
    </View>
  }
  showHeader={true}
/>

Custom Styling

<Sidebar
  visible={visible}
  onClose={() => {}}
  items={items}
  backgroundColor="#1F2937"
  itemTextColor="#F3F4F6"
  activeItemColor="#374151"
  borderRadius={12}
  showIconBackground={true}
  iconBackgroundColor="#374151"
/>

Top/Bottom Navigation

<Sidebar
  visible={visible}
  onClose={() => {}}
  items={items}
  side="top"
  height={200}
/>