# Sidebar

> A collapsible, grouped navigation rail with labelled sections, a current-item accent, and badges folded into each item's accessible name.

- Package: `fancy-ui-vue` (Vue 3.5+ + Tailwind CSS v4)
- Category: Navigation
- Tags: sidebar, nav, rail, collapsible, compound, badge
- Types: `SidebarProps`, `SidebarGroupProps`, `SidebarItemProps`, `SidebarSeparatorProps`, `SidebarFooterProps`, `SidebarContext`
- Docs: https://fancy-ui.rama.app/docs/components/sidebar
- Source: https://github.com/RamaHerbin/fancy-ui/tree/main/vue/src/components/sidebar

## Import

```vue
<script setup lang="ts">
import { Sidebar } from 'fancy-ui-vue';
</script>
```

Setup (once per project): `npm install fancy-ui-vue`, then put these lines in your main CSS file (the stylesheet imports go right after `@import "tailwindcss";`):

```css
@import "tailwindcss";
@import "fancy-ui-vue/tailwind.css";
@import "fancy-ui-vue/styles.css";
```

Full guide: https://fancy-ui.rama.app/llms.txt

The names below are the ones to write in a Vue template; when one differs from the Svelte name, the Svelte name follows in parentheses. Snippets become named slots (`#default` is the default snippet), a prop the Vue port declares as a model is a `v-model:<name>` (except `ref`, exposed via `defineExpose({ ref })`: put a template ref on the component and read `.ref`) and callbacks are listeners (`onclick` is `@click`). Every component sets `inheritAttrs: false`: `class` is a declared prop, merged where the Svelte component applies it (not always the root element), and only when the props table below lists it; other attributes do not fall through unless the package README lists the component as forwarding native attributes. Divergences: https://github.com/RamaHerbin/fancy-ui/tree/main/vue#divergences-from-the-svelte-api

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `label` | `string` | `"Sidebar"` | Accessible name for the nav landmark. |
| `collapsed` | `boolean` | `false` | Whether the sidebar is collapsed to an icon-only rail. Plain, not bindable — nothing inside the compound ever changes it itself. |
| `class` | `string` | — | Additional CSS classes, merged onto the root. |
| `ref` | `HTMLElement \| null` | `null` | Bindable reference to the root nav element. |
| `SidebarGroup.label` (required) | `string` | — | The section heading, e.g. "General". |
| `SidebarGroup.class` | `string` | — | Additional CSS classes, merged onto the group. |
| `SidebarItem.href` | `string` | — | Renders an <a> when set; a <button type="button"> otherwise. |
| `SidebarItem.current` | `boolean` | `false` | Marks this as the current item — aria-current="page" plus the accent left bar. |
| `SidebarItem.badge` | `string \| number` | — | A count or short flag, e.g. 4, rendered as a pill. |
| `SidebarItem.badgeLabel` | `string` | — | What the badge means, folded into the accessible name. Defaults to just the badge value. |
| `SidebarItem.disabled` | `boolean` | `false` | Disables both the click and keyboard-activation paths. |
| `SidebarItem.@click` (Svelte `SidebarItem.onclick`) | `(event: MouseEvent) => void` | — | Native click handler, for the button branch. Never called while disabled. |
| `SidebarItem.class` | `string` | — | Additional CSS classes, merged onto the item. |
| `SidebarItem.ref` | `HTMLAnchorElement \| HTMLButtonElement \| null` | `null` | Bindable reference to the item's interactive element. |
| `SidebarItem.sound` | `boolean` | `false` | Plays select when a sidebar item that is not already current is activated, once the user has enabled sound |
| `SidebarSeparator.class` | `string` | — | Additional CSS classes, merged onto the hairline. |
| `SidebarSeparator.ref` | `HTMLHRElement \| null` | `null` | Bindable reference to the <hr> element. |
| `SidebarFooter.class` | `string` | — | Additional CSS classes, merged onto the footer row. |
| `SidebarFooter.ref` | `HTMLDivElement \| null` | `null` | Bindable reference to the footer's root element. |

## Slots

| Slot | Description |
| --- | --- |
| `#default` (Svelte `children`) | SidebarGroup, SidebarSeparator and SidebarFooter. |
| `SidebarGroup.#default` (Svelte `SidebarGroup.children`) | The SidebarItems in this section. |
| `SidebarItem.#icon` (Svelte `SidebarItem.icon`) | A decorative glyph or icon, shown even while the sidebar is collapsed. |
| `SidebarItem.#default` (Svelte `SidebarItem.children`) | The item's label. Moves to sr-only text while collapsed — never removed. |
| `SidebarFooter.#avatar` (Svelte `SidebarFooter.avatar`) | A decorative avatar, shown even while the sidebar is collapsed. |
| `SidebarFooter.#default` (Svelte `SidebarFooter.children`) | The name / text next to the avatar. sr-only while collapsed. |

## Example

No Vue example is published for this component yet: start from the import above and the props table. The full examples are Svelte-only, on https://fancy-ui.rama.app/docs/components/sidebar.md.
