# Inset sidebar

A shadcn/ui app sidebar as a floating card on a tinted window, with concentric corners, a search that filters links, and every line kept at any 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:** Dashboards and analytics apps; SaaS admin panels with a floating sidebar; Apps with a sidebar search for pages; Products with a soft, card-style layout
- **Category:** Navigation · **Type:** Sidebars · **Style:** Motion, Minimal, Dark mode
- **See it:** [Live preview](https://www.craftui.space/docs/blocks/inset-sidebar) · [Screenshot](https://www.craftui.space/llms.md/preview/inset-sidebar.dc67159e.jpg)

![Inset sidebar](https://www.craftui.space/llms.md/preview/inset-sidebar.dc67159e.jpg)

## Install

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

This is a paid item (BLK-GP038E): 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 InsetSidebar from "@/components/blocks/inset-sidebar/inset-sidebar";

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

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. |
| `groups` | `NavGroup[]` | `DEFAULT_GROUPS` | The groups of links; the search filters them. |
| `levels` | `Level[]` | `DEFAULT_LEVELS` | Deeper levels, opened by rows with `to` (Analytics, Billing). |
| `user` | `SidebarUser` | `DEFAULT_USER` | The signed-in person, shown in the footer. |
| `defaultActive` | `string` | — | Id of the link that starts active. Defaults to the first. |
| `onNavigate` | `(id: string) => void` | — | Called with the id of each link picked (not when a row opens a level). |
| `onLevelChange` | `(levelId: string \| null) => void` | — | Called with a level's id when it opens, and `null` back on the main list. |
| `onSwitchWorkspace` | `(id: string) => void` | — | Called when a workspace is picked in the switcher. |
| `onCreateWorkspace` | `() => void` | — | Called from the switcher's "Create workspace". |
| `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 numbers in sidebar-vars.ts, e.g. `{ "--sb-icon": "1.25rem", "--sb-card": "16rem" }`. The margin, the card's corners and the top bar follow from them. |

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

### `NavGroup`

| Field | Type | Description |
| --- | --- | --- |
| `id` (required) | `string` | Unique id. |
| `label` | `string` | Small heading above the links, e.g. "Data". Leave out for none. |
| `items` (required) | `NavItem[]` | The links, in order. |

### `Level`

| Field | Type | Description |
| --- | --- | --- |
| `id` (required) | `string` | Unique id; rows point at it with `to`. |
| `title` (required) | `string` | Name in the back row, e.g. "Analytics". |
| `groups` (required) | `NavGroup[]` | The level's groups, in order. |

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

### `NavItem`

| Field | Type | Description |
| --- | --- | --- |
| `id` (required) | `string` | Unique id; matched against the active id. |
| `label` (required) | `string` | Text in the row; also what the search matches. |
| `icon` (required) | `IconSvgElement` | A Hugeicons icon from `@hugeicons/core-free-icons`. |
| `href` | `string` | Link target. Without it the row only changes the active item. |
| `to` | `string` | Id of the level this row opens. A row with `to` opens that level in place of the list (with a back row) instead of navigating, and shows a chevron on the right spine. |

## Files

The install adds:

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

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

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