Widgets

Tabs

Tabs

Switch between related sections inside one screen. A tabs control coordinates a tab_bar and tab_bar_view.

Example

tabs(
  length: 2,
  selected_index: 0,
  content: column(
    children: [
      tab_bar([
        tab(label: "Home", icon: "home"),
        tab(label: "Settings", icon: "settings")
      ]),
      container(
        height: 240,
        content: tab_bar_view([
          text("Home content"),
          text("Settings content")
        ])
      )
    ]
  ),
  on_change: ->(event) {
    page.update(status, value: "Selected tab: #{event.value}")
  }
)

Properties

  • length — number of coordinated tabs and views.
  • selected_index — initially selected tab index.
  • content — layout containing the tab bar and tab views.
  • animation_duration — tab transition duration.
  • expand, width, and height — layout sizing.

Events

  • on_change — fired after selection changes; read the selected index from event.value.

The number of tab controls in tab_bar should match the number of children in tab_bar_view and the length value.

Complete API

Helpers

  • tabs(content = ..., **props, &block)

Accepted properties

  • adaptive — Adapts to the platform (Material/Cupertino) when true.
  • align — Alignment of the control within its parent.
  • animate_align — Animates alignment changes.
  • animate_margin — Animates margin changes.
  • animate_offset — Animates offset changes.
  • animate_opacity — Animates opacity changes.
  • animate_position — Animates position changes.
  • animate_rotation — Animates rotation changes.
  • animate_scale — Animates scale changes.
  • animate_size — Animates size changes.
  • animation_duration — Sets the animation duration property.
  • aspect_ratio — Width-to-height ratio to maintain.
  • badge — Badge drawn on the corner of the control.
  • bottom — Bottom offset when positioned inside a stack.
  • col — Responsive column span (1-12) per breakpoint.
  • content — The single child control rendered inside this control.
  • data — Arbitrary value you can attach to the control and read back in handlers.
  • disabled — Disables interaction when true.
  • expand — Fills the available space along the parent's main axis when true.
  • expand_loose — Like expand, but only grows up to the child's natural size.
  • height — Fixed height in logical pixels.
  • key — Stable identity used to preserve state across rebuilds.
  • left — Left offset when positioned inside a stack.
  • length — Sets the length property.
  • margin — Outer spacing around the control.
  • offset — Translation offset applied to the control.
  • opacity — Opacity from 0.0 (transparent) to 1.0 (opaque).
  • right — Right offset when positioned inside a stack.
  • rotate — Rotation applied to the control.
  • rtl — Renders right-to-left when true.
  • scale — Scale transform applied to the control.
  • selected_index — Sets the selected index property.
  • size_change_interval — Throttle interval for on_size_change, in ms.
  • tooltip — Text shown on hover/long-press.
  • top — Top offset when positioned inside a stack.
  • visible — Hides the control when false.
  • width — Fixed width in logical pixels.

Events

  • on_animation_end — Fired when an animation completes.
  • on_change — Fired when the value changes.
  • on_size_change — Fired when the control's size changes.

Wire reference

  • Family: materials
  • Widget type: tabs