# Flat sidebar

A shadcn/ui app sidebar with a workspace switcher, folding sections and counts, where icons, labels and buttons stay aligned at any icon or row size.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown variants are available for the docs, pricing and about pages: append `.md` to the URL or send an `Accept: text/markdown` header (the home page answers the header too). An agent skill is available at [/.well-known/agent-skills/site-skill.md](/.well-known/agent-skills/site-skill.md).

## At a glance

- **Good for:** App sidebars for SaaS products and internal tools; Issue trackers and project tools with a workspace switcher; Dashboards with a sidebar that becomes a phone drawer; shadcn/ui Sidebar setups with exact alignment
- **Category:** Navigation · **Type:** Sidebars · **Style:** Motion, Minimal, Dark mode
- **See it:** [Live preview](https://www.craftui.space/docs/blocks/flat-sidebar) · [Screenshot](https://www.craftui.space/llms.md/preview/flat-sidebar.0bd0e099.jpg)

![Flat sidebar](https://www.craftui.space/llms.md/preview/flat-sidebar.0bd0e099.jpg)

## Install

```bash
pnpm dlx shadcn@latest add https://www.craftui.space/r/flat-sidebar.json
```

This is a paid item (BLK-F1N622): the install needs a craftUI plan or a purchase of it. Signed in, the docs page gives your personal install command. Plans: https://www.craftui.space/pricing

## Usage

```tsx
import FlatSidebar from "@/components/blocks/flat-sidebar/flat-sidebar";

export default function Page() {
  return <FlatSidebar />;
}
```

With no props it renders with demo content; pass your own through the props below.

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `workspaces` | `Workspace[]` | `DEFAULT_WORKSPACES` | Workspaces in the header's switcher; the first is current. |
| `top` | `NavItem[]` | `DEFAULT_TOP` | Rows above the first section, with no label (Inbox, My issues). |
| `sections` | `NavSection[]` | `DEFAULT_SECTIONS` | Labelled sections that fold, in order. |
| `user` | `SidebarUser` | `DEFAULT_USER` | The signed-in person, shown in the footer. |
| `defaultActive` | `string` | — | Id of the row that starts active. Defaults to the first top row. |
| `onNavigate` | `(id: string) => void` | — | Called with the id of each row picked. |
| `onSwitchWorkspace` | `(id: string) => void` | — | Called when a workspace is picked in the switcher. |
| `onCreateWorkspace` | `() => void` | — | Called from the switcher's "Create workspace". |
| `onSearch` | `() => void` | — | Called from the header's search button. |
| `onCreate` | `() => void` | — | Called from the header's new-item button. |
| `onSettings` | `() => void` | — | Called from the footer's settings button. |
| `children` | `React.ReactNode` | — | The page beside the sidebar. Defaults to placeholder content. |
| `className` | `string` | — | Height and placement, e.g. "h-svh" (the default) or "h-[40rem]". |
| `style` | `React.CSSProperties` | — | Sizes for this one sidebar, overriding the five numbers in sidebar-vars.ts, e.g. `{ "--sb-icon": "1.25rem", "--sb-row": "2.5rem" }`. Everything else follows from them, so items stay on their lines. |

### `Workspace`

| Field | Type | Description |
| --- | --- | --- |
| `id` (required) | `string` | Unique id. |
| `name` (required) | `string` | Name shown in the header, e.g. "Northwind". |
| `color` (required) | `string` | Background of the workspace's monogram, any CSS colour. |

### `NavItem`

| Field | Type | Description |
| --- | --- | --- |
| `id` (required) | `string` | Unique id; matched against the active id to mark the current page. |
| `label` (required) | `string` | Text in the row, e.g. "Inbox". |
| `icon` | `IconSvgElement` | A Hugeicons icon from `@hugeicons/core-free-icons`. Leave out when `color` is set. |
| `color` | `string` | A coloured square in place of an icon (a team or project), any CSS colour. |
| `href` | `string` | Link target. Without it the row is a button that only changes the active item. |
| `count` | `number` | A small count shown on the right spine, e.g. unread items. |

### `NavSection`

| Field | Type | Description |
| --- | --- | --- |
| `id` (required) | `string` | Unique id. |
| `label` (required) | `string` | Small heading above the links, e.g. "Workspace". |
| `items` (required) | `NavItem[]` | The links in the section, in order. |
| `defaultOpen` | `boolean` | Whether the section starts open. Defaults to open. |

### `SidebarUser`

| Field | Type | Description |
| --- | --- | --- |
| `name` (required) | `string` | Full name, e.g. "Maya Chen". |
| `avatar` | `string` | Photo URL; the initials show while it loads or when it's missing. |

## Files

The install adds:

- `components/blocks/flat-sidebar/flat-sidebar.tsx`
- `components/blocks/flat-sidebar/nav-rows.tsx`
- `components/blocks/flat-sidebar/workspace-switcher.tsx`
- `components/blocks/flat-sidebar/nav-data.ts`
- `components/blocks/flat-sidebar/sidebar-vars.ts`
- `components/blocks/flat-sidebar/DESIGN.md`

npm dependencies (installed for you): `@hugeicons/core-free-icons`, `@hugeicons/react`.

shadcn/ui components it uses (the shadcn CLI adds any that are missing): `avatar`, `collapsible`, `dropdown-menu`, `sidebar`.