Sidebar navigation
Four components build a sidebar navigation tree. SidebarNavigationTitle and SidebarNavigationItem are single entries. SidebarCollapsibleTitle and SidebarCollapsibleItem are entries that expand to show the entries nested inside them.
Example
Overview
Tables
Settings
Props
All four components take type, which picks the colour scheme: main for the application sidebar and sqlSidebar for the SQL console sidebar.
SidebarNavigationItem props
Prop | Type | Default value | Description |
|---|---|---|---|
Prop label * | Type ReactNode | Default value required | Description The text of the entry |
Prop selected | Type boolean | Default value undefined | Description Whether the entry is the current one |
Prop disabled | Type boolean | Default value undefined | Description Whether the entry is disabled |
Prop level | Type number | Default value 0 | Description Nesting depth, which sets the indent |
Prop icon | Type IconName | LogoName | Default value undefined | Description Icon shown with the label |
Prop iconDir | Type "start" | "end" | Default value undefined | Description Which side of the label the icon sits on |
Prop type | Type "main" | "sqlSidebar" | Default value "main" | Description The colour scheme of the sidebar |
* denotes required field
SidebarNavigationTitle props
Prop | Type | Default value | Description |
|---|---|---|---|
Prop label * | Type ReactNode | Default value required | Description The text of the title |
Prop selected | Type boolean | Default value undefined | Description Whether the title is the current entry |
Prop icon | Type IconName | Default value undefined | Description Icon shown with the label |
Prop iconDir | Type "start" | "end" | Default value undefined | Description Which side of the label the icon sits on |
Prop type | Type "main" | "sqlSidebar" | Default value "main" | Description The colour scheme of the sidebar |
* denotes required field
SidebarCollapsibleItem props
Prop | Type | Default value | Description |
|---|---|---|---|
Prop label * | Type ReactNode | Default value required | Description The text of the entry |
Prop children * | Type ReactNode | Default value required | Description The entries shown when the item is open |
Prop open | Type boolean | Default value undefined | Description Whether the item is open, for a controlled item |
Prop onOpenChange | Type (value: boolean) => void | Default value undefined | Description Called when the item opens or closes |
Prop selected | Type boolean | Default value undefined | Description Whether the entry is the current one |
Prop level | Type number | Default value undefined | Description Nesting depth, which sets the indent |
Prop icon | Type IconName | LogoName | Default value undefined | Description Icon shown with the label |
Prop iconDir | Type "start" | "end" | Default value "start" | Description Which side of the label the icon sits on |
Prop indicatorDir | Type "start" | "end" | Default value "start" | Description Which side the open and close chevron sits on |
Prop type | Type "main" | "sqlSidebar" | Default value "main" | Description The colour scheme of the sidebar |
* denotes required field
SidebarCollapsibleTitle props
Prop | Type | Default value | Description |
|---|---|---|---|
Prop label * | Type ReactNode | Default value required | Description The text of the title |
Prop children * | Type ReactNode | Default value required | Description The entries shown when the title is open |
Prop open | Type boolean | Default value undefined | Description Whether the title is open, for a controlled title |
Prop onOpenChange | Type (value: boolean) => void | Default value undefined | Description Called when the title opens or closes |
Prop selected | Type boolean | Default value undefined | Description Whether the title is the current entry |
Prop icon | Type IconName | Default value undefined | Description Icon shown with the label |
Prop iconDir | Type "start" | "end" | Default value "start" | Description Which side of the label the icon sits on |
Prop type | Type "main" | "sqlSidebar" | Default value "main" | Description The colour scheme of the sidebar |
* denotes required field
Quick start
import { SidebarNavigationItem, SidebarNavigationTitle } from '@clickhouse/click-ui'
import { useState } from 'react'
function Sidebar() {
const [selected, setSelected] = useState('overview')
return (
<nav aria-label='Service'>
<SidebarNavigationTitle label='Service' />
<SidebarNavigationItem
label='Overview'
icon='home'
selected={selected === 'overview'}
onClick={() => setSelected('overview')}
/>
<SidebarNavigationItem
label='Settings'
icon='settings'
selected={selected === 'settings'}
onClick={() => setSelected('settings')}
/>
</nav>
)
}Related components
- Tabs: For switching between views inside a page.
- Accordion: For collapsible content outside navigation.
- Icon: The icons used in sidebar entries.