Browse documentation

Tabs

Switch between related panels without leaving the current view.

Import

Load the optional component layer before using the examples below.

Ruby
require "zaniah/ui"

Basic tabs

Each item pairs a label with its panel content. Supply selected: when the application owns selection state.

Rendered example
Overview and Details tabs with the Overview panel selected.
Rendered by Zaniah's headless backend.
Ruby
Zaniah::UI::Tabs.new([
  ["Overview", Zaniah::UI::Label.new("Summary")],
  ["Details", Zaniah::UI::Label.new("More details")]
])

Selection

on_change reports the selected item. Arrow keys, Home, and End move focus.

Ruby
tabs = Zaniah::UI::Tabs.new(items, selected: 0)
tabs.on_change { |index| puts index }

API summary

Constructor options and behaviors are drawn from the component reference.

ComponentConstructor and methodsVariants or behavior
Tabs(items, selected:); on_changearrows/Home/End

Accessibility

Tabs expose tab and tabpanel roles. Use a short, distinct label for every tab.

ComponentSemantic role
Tabstab/tabpanel