Pricing

SidebarItem handbook

v1.7.0 · @snowui-design-system/components

License: Before reading component documentation, source, or npm usage instructions for the first time, read the full LICENSE. Reuse that review for the same task and version. Public API configuration and internal implementation changes have different license implications. All components use the unified runtime package; source rights remain governed by the license.

Overview

Present a navigation entry in Sidebar with active state, icon, hierarchy, and status hints so users can identify their location.

When to use it

Use it as a Sidebar navigation entry with a stable identity, icon, label, and destination. Active state does not perform application routing for you.

  • Provide stable id and label; href is the navigation destination, and onSelect reports selection.

  • disabled prevents navigation. actions adds item actions; parts configures built-in badges and action buttons.

  • The built-in updated dot name follows LocaleProvider. The caller owns label, tags and actions. Existing decorative and accessibility-tree behavior in collapsed mode is unchanged.

Quick start

This example shows the recommended basic composition. See the sections below for more cases and composition limits.

<script lang="ts">	import { SidebarItem } from '@snowui-design-system/components';	let opened = $state('');</script> <div style="width: min(100%, 12rem);"><SidebarItem id="components" label="Components" icon="squares-four" iconCollection="phosphor" onSelect={() => opened = 'Components'} /></div>

API

Keyword Type Default Description
id string required Stable navigation identifier
label string required Visible label and accessible name when collapsed
icon string | Snippet — ResourceIcon name or custom leading content
iconCollection string — ResourceIcon collection for icon; pass "snowui" for a matching SnowUI icon
depth 0 | 1 0 Navigation depth. 1 denotes a second-level Item and replaces the regular Icon with an L-shaped hierarchy connector in the leading slot.
href string — Renders the main action as a Link when supplied, otherwise as a Button
updated boolean false Built-in Badge dot. Expanded: after external tags; collapsed: beside the leading icon.
tags Snippet — Custom status or category tags between label and the updated hint; Badge variant="border" is recommended
disabled boolean false Disables the main action
actions SidebarActionData[] | Snippet [] Zero or more trailing actions; an array creates Button bare controls
onSelect (id: string) => void — Callback when this item is selected
parts ComponentPartsOf<{ Badge: typeof Badge; Button: typeof Button }> — Configures the built-in Badge and data-generated Buttons

See the base component documentation for inherited capabilities not redeclared here. This table lists only named public Props declared by this component.

Usage boundaries and details

API reference

Spacing between the main graphic, label, tags and updated hint stays at least 4 CSS px under root-font or gap scaling, preserving larger preferred gaps. Long labels truncate first, and both Link and Button respect available width. Trailing actions reserve independent space instead of covering status tags. The leading slot respects the built-in icon minimum of 12px; its default 20px geometry and hierarchy alignment are preserved.

With href, the main navigation content is a link; otherwise it is a button. Secondary actions are independent of the main navigation action. tags appear between label and the updated hint. The icon remains visible when collapsed, and a built-in Tooltip provides the full label. The component owns collapse transitions, label layout, and action placement; the page supplies data and application callbacks.

depth={1} denotes a second-level Item. Within the existing 20px leading slot, pseudo-elements draw an L-shaped dotted line with equal arms: dense 1px Black/40% dots, a 4px rounded bend, and a default visual length of 9px × 9px. Its vertical center aligns with the first-level Item icon above; its horizontal center aligns with the second-level Item label. The graphic expresses hierarchy only. It has no independent interaction or accessibility semantics, does not use icon resource resolution, and does not change with IconProvider. A second-level Item does not also show a regular icon. Callers should still hide second-level Items when Sidebar collapses.


SidebarItem style overrides

Read the full LICENSE first; reuse that review for the same task, version, and scope.

First use public component Props to match the desired appearance, preserving the existing look where possible. If changes are necessary, follow the style selection and override order: use your own class (including Tailwind already in the project) or an instance style. The names below are public overrides actually consumed by source; check their scope and do not modify private DOM. Choose the correct SnowUI token family. External apps need not install SnowUI website utilities.

Variable Purpose and default reference
--snowui-button-opacity-override Opacity (see component source for the default)
--snowui-link-gap-override Spacing between content and leading/trailing attachments (preferred var(--gap-1), with at least 4 CSS px effective spacing).
--snowui-sidebar-item-background-override Hover and active background (default var(--black-4))
--snowui-sidebar-item-font-size-override Navigation label font size (default var(--text-14))
--snowui-sidebar-item-gap-override Spacing inside navigation items (preferred var(--gap-2), with at least 4 CSS px effective spacing).
--snowui-sidebar-item-line-height-override Navigation label line height (default var(--leading-14))
--snowui-sidebar-item-padding-x-override Navigation item horizontal padding (default var(--padding-2))
--snowui-sidebar-item-padding-y-override Navigation item vertical padding (default var(--padding-2))
--snowui-sidebar-item-radius-override Navigation item corner radius (default var(--radius-3))

Design guide · Tokens · Composition boundaries

SidebarItem types and states

Required Props: id and label.

Bindable Props: this component declares no named two-way binding; handle state updates through public callbacks or its host.

Inherited declaration: Omit<FrameProps, "children" | "id">. Consult the base component’s public documentation for inherited capabilities; fields excluded by Omit cannot be used as if inherited unchanged.

Shared Frame API · Back to API

The following type declarations are actually referenced by public Props and come from source. A Svelte Snippet denotes a content fragment; ComponentProps denotes the Props of the corresponding component.

SidebarActionData

Source: components/src/blocks/sidebar-context.svelte.ts

export interface SidebarActionData {    id: string;    icon: string;    iconCollection?: string;    label: string;    disabled?: boolean;    onSelect?: (ownerId: string) => void;}

ComponentPartsOf

Source: components/src/logic/component-parts.svelte.ts

export type ComponentPartsOf<    T extends Record<string, Component<any>>,> = {    [K in keyof T]?: ConfigurableComponentPartProps<T[K]>;};

ConfigurableComponentPartProps

Source: components/src/logic/component-parts.svelte.ts

export type ConfigurableComponentPartProps<C extends Component<any>> = Partial<    Omit<ComponentProps<C>, ComponentPartControlledKey>>;

ComponentPartControlledKey

Source: components/src/logic/component-parts.svelte.ts

export type ComponentPartControlledKey =    | "children"    | "as"    | "value"    | "defaultValue"    | "open"    | "selected"    | "checked"    | "disabled"    | "readonly"    | "id"    | `on${string}`    | `aria-${string}`;