Tabs
Tabs switch between related sections of the same view. Keep their names short and their order stable. Use a segmented control for choosing a value in a form.
Switch sections
#Select Overview or Activity to change the content below the tab bar.
components/tabs/appliance/draft_sections.dart
import 'package:flutter/widgets.dart';
import 'package:appliance_ui/appliance_ui.dart';
class DraftSections extends StatefulWidget {
const DraftSections({super.key});
@override
State<DraftSections> createState() => _DraftSectionsState();
}
class _DraftSectionsState extends State<DraftSections> {
int selected = 0;
@override
Widget build(BuildContext context) => Column(
mainAxisSize: MainAxisSize.min,
children: [
ApplianceTabBar<int>(
tabs: const [
ApplianceSegment(value: 0, label: 'Overview'),
ApplianceSegment(value: 1, label: 'Activity'),
],
value: selected,
onChanged: (index) => setState(() => selected = index),
),
const SizedBox(height: 16),
Text(selected == 0 ? 'Private draft' : 'Created today'),
],
);
}
Parameters
ApplianceTabBar API ↗tabs- ApplianceSegment entries with a value and label.
value- Value of the selected segment.
onChanged- Receives the chosen value.
expand- Controls how the tabs fill their row.
semanticLabel- Supplies an accessible name.
style- Overrides the component’s themed appearance.
Shared behaviour
- Keyboard and focus. Tab reaches the bar. In looks that use
DesignTabBar, one tab stop serves the bar and the horizontal arrows move selection in reading order. - Screen readers. Each tab exposes its label and selected state. Read past the bar to reach the current section’s content.
- Direction and type. RTL reverses the horizontal direction. Labels inherit the text scale, so both directions can be tried with larger type.