Tabs
A tabbed interface component for organizing content into separate panels
A tabbed interface component for organizing content into separate switchable panels.
When to use this
- Content organization: Group related content into separate sections
- Navigation: Switch between different views or categories
- Settings panels: Organize settings into categorized tabs
- Multi-step forms: Break complex forms into manageable sections
Basic implementation
Basic implementation
import 'package:flutter/material.dart';
import 'package:remix/remix.dart';
class TabsExample extends StatefulWidget {
const TabsExample({super.key});
@override
State<TabsExample> createState() => _TabsExampleState();
}
class _TabsExampleState extends State<TabsExample> {
String _tab = 'tab1';
@override
Widget build(BuildContext context) {
return SizedBox(
width: 320,
height: 280,
child: RemixTabs(
selectedTabId: _tab,
onChanged: (id) => setState(() => _tab = id),
child: Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
RemixTabBar(
style: tabBarStyle,
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
RemixTab(tabId: 'tab1', style: tabStyle, label: 'Tab 1'),
const SizedBox(width: 8),
RemixTab(tabId: 'tab2', style: tabStyle, label: 'Tab 2'),
],
),
),
const SizedBox(height: 8),
Expanded(
child: RemixTabView(
tabId: 'tab1',
style: tabViewStyle,
child: const Text('Content for Tab 1'),
),
),
Expanded(
child: RemixTabView(
tabId: 'tab2',
style: tabViewStyle,
child: const Text('Content for Tab 2'),
),
),
],
),
),
);
}
RemixTabBarStyle get tabBarStyle {
return RemixTabBarStyle()
.paddingAll(4)
.borderRounded(12)
.color(const Color(0xFFF4F6FF))
.borderAll(color: Colors.indigo.shade100);
}
RemixTabStyle get tabStyle {
return RemixTabStyle()
.paddingX(18)
.paddingY(10)
.borderRounded(10)
.color(Colors.transparent)
.labelFontSize(14)
.labelFontWeight(FontWeight.w600)
.labelColor(Colors.indigo.shade600)
.iconColor(Colors.indigo.shade500)
.onHovered(
RemixTabStyle()
.color(Colors.indigo.shade50)
.labelColor(Colors.indigo.shade700),
)
.onSelected(
RemixTabStyle()
.color(Colors.white)
.borderAll(color: Colors.indigo.shade400, width: 2)
.labelColor(Colors.indigo.shade700)
.iconColor(Colors.indigo.shade600),
);
}
RemixTabViewStyle get tabViewStyle {
return RemixTabViewStyle()
.paddingAll(20)
.borderRounded(14)
.color(Colors.white)
.borderAll(color: Colors.indigo.shade100);
}
}
Fortal styles
Remix includes Fortal-themed style helpers for this component:
Fortal base style
import 'package:flutter/material.dart';
import 'package:remix/remix.dart';
class FortalTabsExample extends StatefulWidget {
const FortalTabsExample({super.key});
@override
State<FortalTabsExample> createState() => _FortalTabsExampleState();
}
class _FortalTabsExampleState extends State<FortalTabsExample> {
String _tab = 'tab1';
@override
Widget build(BuildContext context) {
return RemixTabs(
selectedTabId: _tab,
onChanged: (id) => setState(() => _tab = id),
child: Column(
children: [
RemixTabBar(
style: FortalTabBarStyle.base(),
child: Row(
children: [
RemixTab(tabId: 'tab1', label: 'Tab 1', style: FortalTabStyle.base()),
RemixTab(tabId: 'tab2', label: 'Tab 2', style: FortalTabStyle.base()),
],
),
),
RemixTabView(tabId: 'tab1', style: FortalTabViewStyle.base(), child: Text('Content 1')),
RemixTabView(tabId: 'tab2', style: FortalTabViewStyle.base(), child: Text('Content 2')),
],
),
);
}
}
See the FortalTabsStyle source code for all available options.
Constructor
Constructor
// Tabs Container
const RemixTabs({
Key? key,
required String selectedTabId,
required ValueChanged<String> onChanged,
required Widget child,
})
// Tab Bar
const RemixTabBar({
Key? key,
required Widget child,
RemixTabBarStyle style = const RemixTabBarStyle.create(),
RemixTabBarSpec? styleSpec,
})
// Individual Tab
const RemixTab({
Key? key,
required String tabId,
String? label,
IconData? icon,
RemixTabStyle style = const RemixTabStyle.create(),
RemixTabSpec? styleSpec,
})
// Tab View
const RemixTabView({
Key? key,
required String tabId,
required Widget child,
RemixTabViewStyle style = const RemixTabViewStyle.create(),
RemixTabViewSpec? styleSpec,
})

