Sidebar
A sidebar widget that provides an opinionated layout for navigation on the side of the screen.
A sidebar is typically used with FScaffold
. Usage of FScaffold
can be found here.
Preview
CLI
To generate and customize this style:
dart run forui style create sidebar
Anatomy
This segment describes the anatomy of the various elements of a sidebar.
FSidebar
The widget that provides an opinionated layout on the side of the screen. The widget has the following sections:
Name | Parameter | Position | Optional |
---|---|---|---|
header | header | sticky | âś… |
content | child/children | scrollable | ❌ |
footer | footer | sticky | âś… |
FSidebarGroup
A widget that is used to group several FSidebarItem
s.
FSidebarItem
Represents an item on the sidebar. May be nested in FSidebarItem.children
to create nested items.
Usage
FSidebar(...)
FSidebar(
style: FSidebarStyle(...),
width: 250,
header: const Text('Header'),
footer: const Text('Footer'),
children: [FSidebarGroup(...)],
);
FSidebar.builder(...)
FSidebar.builder(
style: FSidebarStyle(...),
width: 250,
header: const Text('Header'),
footer: const Text('Footer'),
itemCount: 5,
itemBuilder: (context, index) => FSidebarGroup(...),
);
FSidebar.raw(...)
FSidebar.raw(
style: FSidebarStyle(...),
width: 250,
header: const Text('Header'),
footer: const Text('Footer'),
child: SizedBox(),
);
FSidebarGroup(...)
FSidebarGroup(
style: FSidebarGroupStyle(...),
label: const Text('Group'),
action: const Icon(FIcons.plus),
onActionPress: () {},
children: [FSidebarItem(...)],
);
FSidebarItem(...)
FSidebarItem(
style: FSidebarItemStyle(...),
icon: const Icon(FIcons.box),
label: const Text('Item'),
selected: false,
initiallyExpanded: false,
onPress: () {},
onLongPress: () {},
onHoverChange: (hovered) {},
onStateChange: (states) {},
children: [FSidebarItem(...)],
);
Examples
Sheet Sidebar
Suited for devices with limited screen space.
Preview
Custom Width
Preview
Nested FSidebarItem
Preview
Last updated on