fossui
Components

Tabs

A row or column of tabs that switch between panels, with an indicator that slides to the active tab.

Tabs let one region show several panels, one at a time. Give each FossTab a value, a label, and optionally an icon and a content panel; the active tab's panel is the only one that renders. Pick a look with variant and an axis with orientation. Colors, type, and the indicator slide come from the theme.

import 'package:fossui/fossui.dart';

FossTabs<String>(
  initialValue: 'overview',
  tabs: const [
    FossTab(value: 'overview', label: 'Overview', content: OverviewBody()),
    FossTab(value: 'activity', label: 'Activity', content: ActivityBody()),
  ],
);

Controlled and uncontrolled

Pass value with onChanged to hold the selection yourself, or leave value null and seed initialValue to let the widget track its own. When uncontrolled and no initialValue is set, the first enabled tab wins.

FossTabs<String>(
  value: selected,
  onChanged: (v) => setState(() => selected = v),
  tabs: const [
    FossTab(value: 'account', label: 'Account'),
    FossTab(value: 'billing', label: 'Billing'),
  ],
);

Variants

Two looks. segmented (the default) is a filled bar with a pill sliding behind the active tab. underline is a bare strip with a colored bar riding the active tab's edge.

FossTabs<String>(
  variant: FossTabsVariant.underline,
  tabs: const [
    FossTab(value: 'code', label: 'Code'),
    FossTab(value: 'preview', label: 'Preview'),
  ],
);

Orientation

horizontal (the default) lays tabs in a row with the panel below. vertical stacks them in a column with the panel beside.

FossTabs<String>(
  orientation: FossTabsOrientation.vertical,
  tabs: const [
    FossTab(value: 'general', label: 'General', content: GeneralBody()),
    FossTab(value: 'members', label: 'Members', content: MembersBody()),
  ],
);

Icons

Each tab takes an optional icon, any widget, sized and tinted to match its label.

FossTabs<String>(
  tabs: const [
    FossTab(value: 'home', label: 'Home', icon: Icon(LucideIcons.house)),
    FossTab(value: 'search', label: 'Search', icon: Icon(LucideIcons.search)),
  ],
);

Disabled tabs

Set enabled: false on a tab to dim it and drop it from selection and keyboard navigation. The arrow keys skip over it.

FossTabs<String>(
  tabs: const [
    FossTab(value: 'draft', label: 'Draft'),
    FossTab(value: 'archived', label: 'Archived', enabled: false),
  ],
);

One-off styling

Global retheming comes first, but a single tab set can override the resolved look with a FossTabsStyle. Every field is optional and falls back to the theme.

FossTabs<String>(
  tabs: tabs,
  style: const FossTabsStyle(indicatorColor: Color(0xFF10B981)),
);

API

FossTabs

PropTypeDefaultDescription
tabsList<FossTab<T>>requiredThe ordered tabs.
valueT?nullSelected value when controlled. Null hands selection to the widget.
onChangedValueChanged<T>?nullCalled with a tab's value when it is selected.
initialValueT?nullInitial selection when uncontrolled. Falls back to the first enabled tab.
variantFossTabsVariantsegmentedThe look.
orientationFossTabsOrientationhorizontalThe axis.
styleFossTabsStyle?nullPer-instance overrides on the theme.

FossTab

PropTypeDefaultDescription
valueTrequiredThe value this tab selects. Unique within a FossTabs.
labelStringrequiredThe text shown on the trigger.
iconWidget?nullOptional leading glyph, sized to 18.
contentWidget?nullThe panel shown when active. Null leaves the panel to the caller.
enabledbooltrueWhether the tab accepts focus and selection.

FossTabsStyle

PropTypeDefaultDescription
barColorColor?nullFill of the segmented strip bar. Unused by the underline variant.
indicatorColorColor?nullFill of the active indicator: the pill or the underline bar.
indicatorShadowList<BoxShadow>?nullShadow layers under the segmented pill.
hoverColorColor?nullBackground tint of a hovered underline tab.
activeForegroundColor?nullLabel color of the active tab.
inactiveForegroundColor?nullLabel color of inactive tabs.
labelStyleTextStyle?nullText style of every tab label.

FossTabsVariant

segmented, underline.

FossTabsOrientation

horizontal, vertical.

Live demo

Open the interactive gallery to try every variant, size, and state with live knobs.

On this page