Reference

Tabs

Tab strip switching between its pages: the arrow keys move between the tabs (the other way round in a right-to-left page), Home and End go to the ends.

Tabs(bind: State, value: String or Number, orientation: Enum, …) { … }

Before 5.0

orientation

horizontal

vertical

activation

automatic

manual

label

Your name, photo and the email we write to.

Open: profile

Example

wf

state tab = "profile" Tabs(bind: tab, label: "Account") { Tabs.Page("Profile", value: "profile") { Text("Your name, photo and the email we write to.") } Tabs.Page("Billing", value: "billing") { Text("Pro plan, renews on 1 March.") } Tabs.Page("Danger zone", value: "danger", disabled: true) { Text("Only an owner can delete the account.") } } Text("Open: {tab}").muted.sm

Down the side, opened with Enter

wf

state section = "general" Tabs(bind: section, label: "Settings").vertical.manual { Tabs.Page("General", value: "general") { Text("Name and language") } Tabs.Page("Members", value: "members") { Text("Who can see the project") } }

Hearing the change

wf

state seen = "" Tabs(label: "Report") { on change(v) { seen = "{v}" } Tabs.Page("Week") { Text("This week") } Tabs.Page("Month") { Text("This month") } }

Props

Props of Tabs
PropTypeUnsetMeaning

bind:

State

the first tab

The open tab, read and written: a page's value:, or its place from 0 when the pages give none; a value no page has opens the first

value:

String or Number

the first tab

The open tab, read only: a press does not change it, only on change(v) hears the one picked — for a page that sets it itself

orientation:

one of its cases

horizontal

Which way the tabs run, and which arrow keys move between them; a flag, .vertical. Written as a flag, .horizontal, or by name, orientation: .horizontal.

  • .horizontal (the default): Tabs in a row; ArrowLeft and ArrowRight move (the default)
  • .vertical: Tabs in a column (aria-orientation="vertical"); ArrowUp and ArrowDown move

activation:

one of its cases

automatic

Whether moving the focus opens a tab; a flag, .manual. Written as a flag, .automatic, or by name, activation: .automatic.

  • .automatic (the default): A tab opens as the focus reaches it (the default)
  • .manual: The focus moves alone; Enter or Space opens the tab, for panels slow to draw

label:

String

none

The tab strip's accessible name (aria-label on its tablist)

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.

.horizontal

.vertical

.automatic

.manual

Events

Events of Tabs
EventSendsMeaning
on change—

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

Slots

children

Parts

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

Tabs.Page

One tab and its panel.

Tabs.Page(_ label: String, value: String or Number, disabled: Bool) { … }
Props of Tabs.Page
PropTypeUnsetMeaning

label

String (positional)

Tab 0, Tab 1, … by its place

The words on its tab button

value:

String or Number

its place from 0

What the Tabs' bind: holds while this tab is open

disabled:

Bool

false

Shown, but cannot be opened: the button is disabled and the arrow keys pass over it; .disabled, or disabled: value to follow state. Written as a flag, .disabled, or disabled: true.

.disabled

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