Navigation Core Stable

Sidebar

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

Preview

Installation

pnpm add fancy-ui-svelte
import { Sidebar } from 'fancy-ui-svelte'

Usage

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

<Sidebar />

Examples

Basic Usage

With Badges

A count folded into an item's accessible name, and a second grouped section.

Collapsed

Icon-only rail — labels and badge meaning move to sr-only text, never removed.

An avatar and name row, above a separator, pinned to the bottom.

Props

PropTypeDefaultDescription
label string"Sidebar"Accessible name for the nav landmark.
collapsed booleanfalseWhether 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 | nullnullBindable reference to the root nav element.
SidebarGroup.label *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 booleanfalseMarks 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 booleanfalseDisables both the click and keyboard-activation paths.
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 | nullnullBindable reference to the item's interactive element.
SidebarSeparator.class string-Additional CSS classes, merged onto the hairline.
SidebarSeparator.ref HTMLHRElement | nullnullBindable reference to the <hr> element.
SidebarFooter.class string-Additional CSS classes, merged onto the footer row.
SidebarFooter.ref HTMLDivElement | nullnullBindable reference to the footer's root element.

Slots

SlotDescription
childrenSidebarGroup, SidebarSeparator and SidebarFooter.
SidebarGroup.childrenThe SidebarItems in this section.
SidebarItem.iconA decorative glyph or icon, shown even while the sidebar is collapsed.
SidebarItem.childrenThe item's label. Moves to sr-only text while collapsed — never removed.
SidebarFooter.avatarA decorative avatar, shown even while the sidebar is collapsed.
SidebarFooter.childrenThe name / text next to the avatar. sr-only while collapsed.