Reference

Sidebar

Side navigation. A Sidebar.Item whose to matches the current route is marked .active and aria-current="page".

Sidebar { … }

Before 5.0

No props to try.

Reference

Every built-in, with its props and an example.

Example

wf

Row { style { height: 360px; border: 1px solid $color-border } Sidebar { style { height: 100% } Sidebar.Header { Text("Docs").bold } Sidebar.Item(to: "/", icon: "home") { Text("Home") } Sidebar.Item(to: "/learn", icon: "book", active: .prefix) { Text("Learn") } Sidebar.Item(to: "/reference", icon: "list", active: .prefix) { Text("Reference") } Sidebar.Item(to: "/recipes", icon: "layers") { Text("Recipes") } Sidebar.Divider Sidebar.Item(to: "/playground", icon: "play") { Text("Playground") } } Stack(gap: .sm) { style { flex: 1; padding: 24px } Heading("Reference").h3 Text("Every built-in, with its props and an example.").muted } }

On its own: as tall as the window, sticking as the page scrolls

wf

Sidebar { Sidebar.Item(to: "/learn", icon: "book").prefix { Text("Learn") } Sidebar.Item(to: "/errors", icon: "alert-circle") { Text("Errors") } }

Props

This element takes no props of its own.

Attribute families: global, aria, data. Plus the 22 universal props every element takes: animate:, exit:, speed:, duration:, delay:, easing:, stagger:, on:, count:, shared:, class:, ref:, drag:, dragGroup:, dropValue:, dropAxis:, dropInside:, roving:, trapFocus:, mount:, update:, cleanup:.

Flags and cases

A flag is written after the parentheses with a dot: a Bool prop, or a case of one of the element's enum props. A case the enum lacks is an error with a hint.

No flags of its own.

Events

Every element also takes the props, the events and the attribute families listed on every element.

Slots

children

Parts

The parts of Sidebar are written under its name, inside it. Each is described here, with what it takes.

The sidebar's heading area.

Sidebar.Header { … }

One navigation entry.

Sidebar.Item(to: Path, icon: String, active: Enum) { … }
Props of Sidebar.Item
PropTypeUnsetMeaning

to:

Path

none

The route it links to, navigated in place; while it matches the current route the item carries .active and aria-current="page". Unset, the item is not a link

icon:

String

none

The name of a built-in icon, drawn before its words

active:

one of its cases

exact match

How it decides it is the current page: unset, the route must equal to; .prefix also matches routes beneath it. Written as a flag, .prefix, or by name, active: .prefix.

  • .prefix: Also current on every route beneath to: /docs for /docs/forms

.prefix

A rule between groups of items.

Sidebar.Divider

Renders with the class wf-sidebar, stable across releases, so a stylesheet may target it.

These controls list the props' cases; the example below shows them written.