---
title: Sidebar navigation
description: Sidebar components build the navigation tree of an application with titles, items and collapsible groups.
category: Navigation
related: [Tabs, Accordion, Icon]
---

Source: https://clickhouse.design/click-ui/sidebar

# 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

## 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                              |
| -------- | ------------------------ | ------------- | ---------------------------------------- |
| label \* | `ReactNode`              | `required`    | The text of the entry                    |
| selected | `boolean`                | `undefined`   | Whether the entry is the current one     |
| disabled | `boolean`                | `undefined`   | Whether the entry is disabled            |
| level    | `number`                 | `0`           | Nesting depth, which sets the indent     |
| icon     | `IconName \| LogoName`   | `undefined`   | Icon shown with the label                |
| iconDir  | `"start" \| "end"`       | `undefined`   | Which side of the label the icon sits on |
| type     | `"main" \| "sqlSidebar"` | `"main"`      | The colour scheme of the sidebar         |

```tsx
import {
  SidebarNavigationTitle,
  SidebarNavigationItem,
  SidebarCollapsibleItem,
} from '@clickhouse/click-ui'

<SidebarNavigationTitle label="Service" />
<SidebarNavigationItem label="Overview" icon="home" selected />
<SidebarCollapsibleItem label="Tables" icon="table">
  <SidebarNavigationItem label="events" level={1} />
</SidebarCollapsibleItem>
```

### SidebarNavigationTitle props

| Prop     | Type                     | Default value | Description                              |
| -------- | ------------------------ | ------------- | ---------------------------------------- |
| label \* | `ReactNode`              | `required`    | The text of the title                    |
| selected | `boolean`                | `undefined`   | Whether the title is the current entry   |
| icon     | `IconName`               | `undefined`   | Icon shown with the label                |
| iconDir  | `"start" \| "end"`       | `undefined`   | Which side of the label the icon sits on |
| type     | `"main" \| "sqlSidebar"` | `"main"`      | The colour scheme of the sidebar         |

### SidebarCollapsibleItem props

| Prop         | Type                       | Default value | Description                                     |
| ------------ | -------------------------- | ------------- | ----------------------------------------------- |
| label \*     | `ReactNode`                | `required`    | The text of the entry                           |
| children \*  | `ReactNode`                | `required`    | The entries shown when the item is open         |
| open         | `boolean`                  | `undefined`   | Whether the item is open, for a controlled item |
| onOpenChange | `(value: boolean) => void` | `undefined`   | Called when the item opens or closes            |
| selected     | `boolean`                  | `undefined`   | Whether the entry is the current one            |
| level        | `number`                   | `undefined`   | Nesting depth, which sets the indent            |
| icon         | `IconName \| LogoName`     | `undefined`   | Icon shown with the label                       |
| iconDir      | `"start" \| "end"`         | `"start"`     | Which side of the label the icon sits on        |
| indicatorDir | `"start" \| "end"`         | `"start"`     | Which side the open and close chevron sits on   |
| type         | `"main" \| "sqlSidebar"`   | `"main"`      | The colour scheme of the sidebar                |

### SidebarCollapsibleTitle props

| Prop         | Type                       | Default value | Description                                       |
| ------------ | -------------------------- | ------------- | ------------------------------------------------- |
| label \*     | `ReactNode`                | `required`    | The text of the title                             |
| children \*  | `ReactNode`                | `required`    | The entries shown when the title is open          |
| open         | `boolean`                  | `undefined`   | Whether the title is open, for a controlled title |
| onOpenChange | `(value: boolean) => void` | `undefined`   | Called when the title opens or closes             |
| selected     | `boolean`                  | `undefined`   | Whether the title is the current entry            |
| icon         | `IconName`                 | `undefined`   | Icon shown with the label                         |
| iconDir      | `"start" \| "end"`         | `"start"`     | Which side of the label the icon sits on          |
| type         | `"main" \| "sqlSidebar"`   | `"main"`      | The colour scheme of the sidebar                  |

## Quick start

```tsx
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.

## Common use cases

### Collapsible section
