# Material 3 Expressive > Flutter UI library (v1.2.4) implementing the Material 3 Expressive component set as direct `M3E*` widgets from one import: `package:material_3_expressive/material_3_expressive.dart`. A faithful Flutter implementation of the [Material 3](https://m3.material.io/components) **Expressive** component set. ## Installation Add the package to your `pubspec.yaml`: ```yaml dependencies: material_3_expressive: ^1.2.4 ``` Then fetch it: ```bash flutter pub get ``` Or add it from the command line: ```bash flutter pub add material_3_expressive ``` ## Quick start Import the library — a single import exposes every component and foundation: ```dart import 'package:material_3_expressive/material_3_expressive.dart'; ``` ### Recommended: `M3EMaterialApp` Wrap your app in `M3EMaterialApp` for adaptive theming, dynamic color, and Material `ThemeMode` alignment (same pattern as the example gallery): ```dart void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return M3EMaterialApp( title: 'My App', data: M3EThemeData.light(seedColor: const Color(0xFF6750A4)), autoTheming: true, dynamicColoring: true, drawUnderSystemBars: true, // transparent system bars, edge-to-edge layout home: const HomePage(), ); } } ``` Surfaces draw behind the OS navigation bar; components such as `M3ENavigationBar` keep interactive content above the gesture area via `viewPadding`. Actionable controls draw an outset **keyboard focus ring** when focused via Tab (hidden after pointer interaction). Override globally with `focusRingTheme` / `keyboardFocusIndicators` on `M3EThemeData`, or try the example **Focus rings** playground (View tab): ```dart M3EThemeData.light(seedColor: seed).copyWith( keyboardFocusIndicators: true, focusRingTheme: const M3EFocusRingTheme( color: Color(0xFF6750A4), width: 2, gap: 2, ), ); ``` ### Alternative: `M3ETheme` subtree If you already have an app shell, wrap any subtree in `M3ETheme`: ```dart M3ETheme( data: M3EThemeData.light(seedColor: const Color(0xFF6750A4)), child: myApp, ); ``` Use `M3EThemeData.dark(...)` for a dark scheme. If no `M3ETheme` is found, components fall back to a default light theme. Unlike `M3EMaterialApp`, this path does not set a system bar style, so wrap your app in an `AnnotatedRegion` (for example `SystemUiOverlayStyle.dark` for a light theme) to restore it after modals close. ### Accessing theme tokens ```dart final theme = M3ETheme.of(context); final scheme = theme.colorScheme; final type = theme.typeScale; // Toggle brightness at runtime (requires adaptive M3EMaterialApp / M3EThemeScope) M3ETheme.controllerOf(context)?.toggleBrightness( fallback: theme.brightness, autoTheming: true, ); ``` ## Theming `M3EThemeData` bundles expressive tokens and per-component themes: ```dart final theme = M3EThemeData.light( seedColor: const Color(0xFF6750A4), ); // Override a single component theme final custom = theme.copyWith( buttonTheme: M3EButtonTheme.defaults.copyWith(/* ... */), ); ``` Key properties on `M3EThemeData`: - `colorScheme` — `M3EColorScheme` with M3 semantic roles - `typography` — `M3ETypography` with baseline and emphasized scales (30 styles) - `typeScale` — baseline alias for `typography.baseline` (used by components) - `spacing`, `visualDensity`, per-component `*Theme` extensions - `focusRingTheme` / `keyboardFocusIndicators` — keyboard focus chrome - Per-component `M3ESpring` motion fields on themes such as `switchTheme`, `fabMenuTheme`, `navigationRailTheme`, `listTheme`, `toolbarTheme`, `sliderTheme`, `iconButtonTheme`, `checkboxTheme`, and `refreshIndicatorTheme` (defaults preserve prior hard-coded springs) The M3 type system has 15 baseline and 15 emphasized roles. Use emphasized styles for selection, actions, and editorial hierarchy: ```dart final theme = M3ETheme.of(context); Text('Headline', style: theme.typography.emphasized.headlineSmall); ``` Shared typography (font family, fallback, package, size factor/delta, color, decoration, brand/plain typefaces, and variable-font axes) is applied through `M3ETypography.apply` or theme `copyWith` — not a full `TextStyle`: ```dart final themed = M3EThemeData.light(seedColor: seed).copyWith( typography: M3ETypography.material3().apply( fontFamily: 'Roboto Flex', fontVariations: M3ETypeVariations.graded.variations, ), ); // Sugar: same result without building typography by hand final alsoThemed = M3EThemeData.light(seedColor: seed).copyWith( fontFamily: 'Roboto Flex', fontVariations: M3ETypeVariations.graded.variations, ); // Per-role variable-font axes (opsz, wght, split ROND, emphasized GRAD) final variable = M3EThemeData.light(seedColor: seed).copyWith( fontFamily: 'Roboto Flex', typeScaleMode: M3ETypeScaleMode.variable, variableFont: const M3EVariableFontConfig( global: M3EVariableFontAxes(wght: 500, opsz: 16), brand: M3EVariableFontAxes(rond: 25), body: M3EVariableFontAxes(rond: 50), ), ); // Convert any TextStyle to a spec variant final converted = M3ETypeStyleConversion.toVariant( Theme.of(context).textTheme.bodyLarge!, variant: M3ETypeScaleVariant.emphasized, role: M3ETypeRole.bodyLarge, ); // Customize token fields before building a TextStyle final tokens = M3ETypeStyleTokens.fromTextStyle(style).copyWith( letterSpacing: 0.25, ); final custom = tokens.toTextStyle(fontFamily: 'Roboto Flex'); ``` `M3EMaterialApp` additionally supports `autoTheming` (platform brightness) and `dynamicColoring` (OS seed color on supported platforms — Material You primary on Android 12+, accent color on desktop — with schemes generated via `ColorScheme.fromSeed`). Pass `fontFamily` / `fontFamilyFallback` / `fontVariations`, `typeScaleMode`, `typeface`, or `variableFont` to apply type-scale knobs at the shell. Use [`buildM3EThemeDefaults()`](https://github.com/paadevelopments/material_3_expressive/blob/main/lib/foundations/theme/m3e_theme_defaults.dart) to assemble a full [`M3EThemeData`](https://github.com/paadevelopments/material_3_expressive/blob/main/lib/foundations/theme/m3e_theme_data.dart) from core tokens, or [`M3EDynamicColorHost`](https://github.com/paadevelopments/material_3_expressive/blob/main/lib/foundations/theme/m3e_dynamic_color_host.dart) when you need device dynamic color outside `M3EMaterialApp`: ```dart M3EMaterialApp( data: M3EThemeData.light(seedColor: seed), fontFamily: 'Roboto Flex', typeScaleMode: M3ETypeScaleMode.variable, variableFont: const M3EVariableFontConfig(), home: const HomePage(), ); ``` `M3ETypeVariations` is an enum of Roboto Flex axis presets (`.variations`): regular, graded (alias for the weight+grade preset formerly named emphasized), condensed, extra condensed, wide, extra wide, and round. This is not the M3 emphasized type scale — use `theme.typography.emphasized` for that. Static and mono fonts ignore axes they do not define. The shell projects the baseline type scale onto `ThemeData.textTheme` and `DefaultTextStyle`. ## Components Every component is a widget you construct directly. Snippets use the single import above. Stateful controls show `// in State` where a `setState` wrapper is needed. Each component is customized through its `M3E*Theme`. ### Actions > See also: [`example/lib/pages/playground/do/`](https://github.com/paadevelopments/material_3_expressive/blob/main/example/lib/pages/playground/do/) (Do tab) #### M3EButton Text button in five sizes with a press shape morph and the sparkle ripple. Styles are elevated, filled, tonal, outlined and text. `isSelected` turns it into a toggle that morphs round to square, with optional `selectedIcon` and `selectedLabel` (not on text buttons). State layers are **0.08** hover and **0.1** focus and press. Gradients and per-state colors go on `M3EButtonDecoration`; customize defaults on `M3EButtonTheme`. ```dart M3EButton( style: M3EButtonStyle.elevated, onPressed: () {}, child: const Text('Elevated'), ); // Toggle (in State) M3EButton.filled( icon: const Icon(M3EIcons.favorite_border), selectedIcon: const Icon(M3EIcons.favorite), isSelected: isFavorite, onPressed: () => setState(() => isFavorite = !isFavorite), ); ``` Keyboard: Tab, then Space or Enter. #### M3EIconButton Icon-only button in filled (default), tonal, outlined and standard variants. Toggle it with `isSelected` and `selectedIcon`. Customize it on `M3EIconButtonTheme`. ```dart M3EIconButton( icon: const Icon(M3EIcons.edit), onPressed: () {}, ); // Toggle (in State) M3EIconButton( icon: const Icon(M3EIcons.add), selectedIcon: const Icon(M3EIcons.check), isSelected: isFavorite, onPressed: () => setState(() => isFavorite = !isFavorite), ); ``` Keyboard: Tab, then Space or Enter. #### M3EFab Floating action button in `small` **40**, `regular` **56**, `medium` **80** (default) and `large` **96**. `M3EFabController` with `M3EFabScrollVisibility` hides it on scroll, and `openBuilder` opens a full-screen container transform. Customize it on `M3EFabTheme`. ```dart M3EFab( icon: const Icon(M3EIcons.add), size: M3EFabSize.large, color: M3EFabColor.tertiary, openBuilder: (context) => const ComposePage(), // optional transform onPressed: () {}, ); ``` Keyboard: Tab, then Space or Enter. #### M3EExtendedFab FAB with a required label, in `small` **56** (default), `medium` **80** and `large` **96**. `M3EExtendedFabController` with `M3EExtendedFabScrollVisibility` hides it on scroll, and `openBuilder` opens a container transform. Customize it on `M3EExtendedFabTheme`. ```dart M3EExtendedFab( label: 'Compose', icon: const Icon(M3EIcons.edit), size: M3EExtendedFabSize.medium, onPressed: () {}, ); ``` Keyboard: Tab, then Space or Enter. #### M3EFabMenu Speed-dial menu of **2–6** items. The trigger morphs into a **56** close button, and back closes the menu before the route. Tapping an item closes the menu unless `closeOnItemTap` is false; an item with an `openBuilder` keeps it open. Customize it on `M3EFabMenuTheme`. ```dart M3EFabMenu( expandIcon: const Icon(M3EIcons.add), collapseIcon: const Icon(M3EIcons.close), closeOnItemTap: true, // false keeps the menu open after a tap items: [ M3EFabMenuItem(icon: const Icon(M3EIcons.edit), label: 'Note', onPressed: () {}), M3EFabMenuItem(icon: const Icon(M3EIcons.schedule), label: 'Reminder', onPressed: () {}), ], ); ``` Keyboard: Tab walks the items. Escape closes. #### M3EButtonGroup Standard or connected group of `M3EButton` actions with single or multi selection. Density changes the height, not the gap. Customize it on `M3EButtonGroupTheme`. ```dart // in State M3EButtonGroup( type: M3EButtonGroupType.connected, selectedIndex: groupIndex, onSelectedIndexChanged: (i) => setState(() => groupIndex = i), actions: const [ M3EButtonGroupAction(label: Text('Day')), M3EButtonGroupAction(label: Text('Week')), M3EButtonGroupAction(label: Text('Month')), ], ); ``` Keyboard: Tab, then Space or Enter. #### M3ESegmentedButton Outlined single or multi-select control with **2–5** segments, **40** tall with a **48** target, and a **1** **outline** border. Density lowers the height. Customize it on `M3ESegmentedButtonTheme`. ```dart // in State M3ESegmentedButton( segments: const [ M3ESegment(value: 'list', label: 'List'), M3ESegment(value: 'grid', label: 'Grid'), ], selected: viewMode, onSelectionChanged: (v) => setState(() => viewMode = v), ); ``` Keyboard: Tab, then Space or Enter. #### M3ESplitButton A primary action and a menu trigger, **2** apart. The menu comes from `items` or `m3eMenuBuilder`, and back closes it before the route. Customize it on `M3ESplitButtonTheme`. ```dart M3ESplitButton( label: 'Save', leadingIcon: M3EIcons.check, onPressed: () {}, onSelected: (value) {}, items: const [ M3ESplitButtonItem(value: 'draft', child: Text('Save as draft')), M3ESplitButtonItem(value: 'copy', child: Text('Save a copy')), ], ); ``` Keyboard: Tab, then Space or Enter. Escape closes the menu. ### Selection > See also: [`example/lib/pages/playground/pick/`](https://github.com/paadevelopments/material_3_expressive/blob/main/example/lib/pages/playground/pick/) (Pick tab) #### M3ECheckbox Checkbox with an **18** box, **2** corners, a **40** state layer and a **48** target, with optional `tristate` and `label`. Customize it on `M3ECheckboxTheme`. ```dart // in State M3ECheckbox( value: checked, label: const Text('Remember me'), onChanged: (v) => setState(() => checked = v), ); ``` Keyboard: Tab, then Space or Enter. #### M3ERadio Radio with a **20** icon, a **40** state layer and a **48** target. Wrap options in `M3ERadioGroup` for arrow-key selection. Customize it on `M3ERadioTheme`. ```dart // in State M3ERadioGroup( groupValue: plan, groupLabel: 'Plan', onChanged: (v) => setState(() => plan = v), child: M3ERadio( value: 'pro', groupValue: plan, label: const Text('Pro'), onChanged: (v) => setState(() => plan = v), ), ); ``` Keyboard: Tab enters the selected radio. Arrows move, select and wrap. #### M3ESwitch Switch with a **52×32** track. The handle is **16** off, **24** on or with an icon, and **28** pressed. Dragging past the midpoint toggles it. Customize it on `M3ESwitchTheme`. ```dart // in State M3ESwitch( value: wifiEnabled, selectedIcon: const Icon(M3EIcons.check), onChanged: (v) => setState(() => wifiEnabled = v), ); ``` Keyboard: Tab, then Space or Enter. #### M3EChip Assist, filter, input and suggestion chips, **32** tall with **8** corners. `M3EChipGroup` moves focus between chips with the arrow keys. Customize them on `M3EChipTheme`. ```dart M3EChip( label: 'Assist', leading: const Icon(M3EIcons.edit), onPressed: () {}, ); // Filter chip (in State) M3EChip( label: 'Flutter', type: M3EChipType.filter, selected: chips.contains('flutter'), onPressed: () => toggleChip('flutter'), ); ``` Keyboard: Tab, then Space or Enter. In a group, arrows move. Backspace or Delete removes an input chip. #### M3EDropdownMenu Dropdown for one or many values, with optional search, a selection `limit` and async items (`.future`). Back closes the panel before the route. Customize it on `M3EDropdownMenuTheme`. ```dart M3EDropdownMenu( singleSelect: true, items: const [ M3EDropdownItem(label: 'Flutter', value: 'flutter'), M3EDropdownItem(label: 'Dart', value: 'dart'), ], fieldStyle: const M3EDropdownFieldStyle(hintText: 'Choose a framework'), onSelectionChanged: (items) {}, ); ``` Keyboard: Space or Enter opens. Arrows move in the panel. Escape closes. #### M3ESlider Value or range slider, also centered, wavy and vertical. Sizes `xs`–`xl` scale the track (**16–96**) and handle (**44–108**) together. The active track and handle are **primary**, the inactive track **secondary container**, and `divisions` adds stops. Customize it on `M3ESliderTheme`. ```dart // in State M3ESlider( value: volume, size: M3ESliderSize.l, divisions: 5, onChanged: (v) => setState(() => volume = v), ); M3ERangeSlider( values: range, onChanged: (v) => setState(() => range = v), ); ``` Keyboard: arrows step. Page Up and Page Down jump. Home and End go to the ends. #### M3EDatePicker Inline calendar (`M3ECalendarDatePicker`) and dialogs for one date or a range, with a year grid and text input. The inline calendar is **328** wide. Customize it on `M3EDatePickerTheme`. ```dart // Inline (in State) M3ECalendarDatePicker( initialDate: date, firstDate: DateTime(2020), lastDate: DateTime(2030), onDateChanged: (v) => setState(() => date = v), ); // Dialog; use showRange for a range final picked = await M3EDatePicker.show( context, initialDate: date, firstDate: DateTime(2020), lastDate: DateTime(2030), ); ``` Keyboard: Tab, then Space or Enter. Left and Right change the month. #### M3ETimePicker Dialog and inline dial (**256**) for a time of day. Customize it on `M3ETimePickerTheme`. ```dart final M3ETime? picked = await M3ETimePicker.show(context, initialTime: time); // Inline (in State) M3EDialTimePicker( value: time, onChanged: (v) => setState(() => time = v), ); ``` Keyboard: Tab, then Enter moves focus on. ### Containment > See also: [`example/lib/pages/playground/view/`](https://github.com/paadevelopments/material_3_expressive/blob/main/example/lib/pages/playground/view/) (View tab) #### M3ECard Elevated, filled and outlined card with **16** content padding and a **secondary** **3** focus ring. It has optional media, headline, supporting text, actions and overflow slots, a swipe action, and an `openBuilder` container transform. `M3ECardGroup` lays out and reorders a set of cards. Customize it on `M3ECardTheme`. ```dart M3ECard( variant: M3ECardVariant.outlined, media: Image.network(imageUrl, fit: BoxFit.cover), headline: 'Weekend trip', supportingText: '12 photos · 3 people', actions: M3EButton.text(onPressed: () {}, child: const Text('Share')), onPressed: () {}, ); ``` Keyboard: Tab, then Space or Enter. Left and Right reveal a swipe action, and Escape hides it. #### M3ECarousel Multi-browse, uncontained, multi-aspect, hero and full-screen carousels, horizontal or vertical (`axis`). Items are `M3ECarouselItem`, `onChange` reports the focal item, and `M3ECarouselController` steps, jumps or opens the show-all list. Customize it on `M3ECarouselTheme`. ```dart M3ECarousel( type: M3ECarouselType.hero, children: [ for (final url in imageUrls) M3ECarouselItem( image: Image.network(url, fit: BoxFit.cover), title: const Text('Title'), showScrim: const M3ECarouselScrim.gradient(), // fades under the text onTap: () {}, ), ], ); ``` Keyboard: Tab or arrows move between items. Space or Enter opens one. #### M3EListItem List row with a headline, supporting text, and leading and trailing slots. Rows are **56**, **72** and **88** tall for one, two and three lines, with **16** side padding. `variant` and `border` style a standalone row. Customize it on `M3EListItemTheme`. ```dart M3EListItem( headline: 'Wireless charging', supportingText: 'On · Fast charge enabled', leading: const Icon(M3EIcons.schedule), trailing: const Icon(M3EIcons.chevron_right), onTap: () {}, ); ``` Keyboard: Tab, then Space or Enter. #### M3EList The list widget, with segmented (default) or standard corners. Rows opt into swipe actions, expansion, sub-lists (a nested `M3EList`) and container transforms, and the list adds selection and drag-to-reorder. Expanded rows fill **surface container high**. Use `.scrollable` for a lazy list and `.sliver` in a `CustomScrollView`. Customize it on `M3EListTheme`. ```dart M3EList( variant: M3ECardVariant.outlined, itemCount: 3, onTap: (index) {}, itemBuilder: (context, index) => M3EListItem( headline: 'Inbox $index', leading: const Icon(M3EIcons.schedule), ), ); ``` Keyboard: the list is one Tab stop. Arrows move through rows, row actions and sub-rows. Space or Enter activates. #### M3ESwipeToDismissBox A generic dismissible container whose content slides over a background. Start and end are logical directions (right-to-left aware), the positional threshold is **56**, and a **125** logical-pixel-per-second fling dismisses early. `M3ESwipeToDismissBoxState` exposes the live values plus `dismiss` / `reset` / `snapTo`, and `onDismiss` fires when the box settles dismissed. The background is sized to the content, so swiping does not shift layout. ```dart final state = M3ESwipeToDismissBoxState(); M3ESwipeToDismissBox( state: state, backgroundContent: ColoredBox( color: M3ETheme.of(context).colorScheme.errorContainer, child: const Align( alignment: Alignment.centerRight, child: Padding( padding: EdgeInsets.all(24), child: Icon(M3EIcons.delete), ), ), ), content: const M3ECard( variant: M3ECardVariant.filled, headline: 'Swipe to dismiss', ), onDismiss: (direction) {}, ); // Programmatic dismissal and reset. state.dismiss(M3ESwipeToDismissBoxValue.endToStart); state.reset(); ``` Keyboard: None; dismissal uses pointer swipes or the state API. #### M3ESelection Multi-select host: an `M3ESelectionAppBar` swaps its `idle` bar for a contextual bar with a count, select-all and `actions` while rows are selected, over any list body. Selected rows use `selectedColor`. Customize it on `M3ESelectionTheme`. ```dart final selection = M3ESelectionController(); M3ESelection( controller: selection, itemCount: items.length, appBar: M3ESelectionAppBar( idle: M3EAppBar.top(titleText: 'Files'), actions: [ M3EIconButton(icon: const Icon(M3EIcons.delete), onPressed: () {}), ], ), body: M3EList.scrollable( itemCount: items.length, selection: true, selectionController: selection, itemBuilder: (context, i) => M3EListItem(headline: items[i]), ), ); ``` Keyboard: Tab, then Space or Enter selects a row. #### M3EDivider **1** **outline variant** line, full width unless `inset` or `outerMargin` is set, horizontal or vertical. Customize it on `M3EDividerTheme`. ```dart const M3EDivider(); const M3EDivider(axis: M3EDividerAxis.vertical); ``` #### M3EScrollbar Overlay scrollbar for vertical or horizontal scrollables, without adding a gutter. Non-interactive is **4** thick with **0** cross-axis inset; interactive is **8** thick with **2** inset and adds thumb dragging and track presses. Both use a **24** minimum thumb, **2** main-axis inset, an `outline` thumb at **70%** idle / **80%** hovered / **95%** active, and a **250ms** fade after **400ms**. Customize it on `M3EScrollbarTheme`, or override colors per instance. ```dart final controller = ScrollController(); M3EScrollbar.nonInteractive( controller: controller, child: ListView.builder( itemCount: 40, itemBuilder: (context, index) => M3EListItem(headline: 'Item $index'), ), ); M3EScrollbar.interactive( controller: controller, onThumbDrag: (double fraction) { controller.jumpTo(fraction * controller.position.maxScrollExtent); }, onTrackPress: (double fraction) { controller.jumpTo(fraction * controller.position.maxScrollExtent); }, child: ListView.builder( itemCount: 40, itemBuilder: (context, index) => M3EListItem(headline: 'Item $index'), ), ); ``` Keyboard: None; the scrollbar follows the scrollable's scrolling keys. #### M3EDialog Basic and full-screen dialogs. A basic dialog is **280–560** wide on **surface container high**, with **28** corners and **24** padding, over a **0.32** scrim. The headline is optional, and it and the actions stay pinned while content scrolls. `showAdaptive` is full-screen below **600**. Customize it on `M3EDialogTheme`. ```dart M3EDialog.show( context, dialog: M3EDialog( title: 'Reset settings?', content: const Text('This restores default values.'), actions: [ M3EButton.text(onPressed: () => Navigator.pop(context), child: const Text('Cancel')), M3EButton.text(onPressed: () => Navigator.pop(context), child: const Text('Reset')), ], ), ); // Full screen below 600dp, basic dialog above. M3EDialog.showAdaptive( context, title: 'Create album', content: const Text('Album details'), confirmLabel: 'Save', onConfirm: () => Navigator.pop(context), ); ``` Keyboard: Tab and Shift+Tab stay inside. Space or Enter activates. Escape closes. #### M3EBottomSheet Modal and standard bottom sheets, full width up to **640**, on **surface container low**, with **28** top corners and a **32×4** drag handle. A modal sheet opens over a **0.32** scrim at up to half the screen and can be pulled up to its content height. `.standard` sits next to the content without a scrim. Customize it on `M3EBottomSheetTheme`. ```dart // Modal M3EBottomSheet.show( context, builder: (context) => const ShareTargets(), ); // Standard, driven by a controller final controller = M3EBottomSheetController(); M3EBottomSheet.standard( controller: controller, previewHeight: 64, child: const PlacesList(), ); ``` Keyboard: Tab focuses the handle, and Space or Enter cycles the heights. Escape closes a modal sheet. #### M3ESideSheet Modal and standard side sheets on the end edge, **256** wide (up to **400**). A modal sheet is on **surface container low** with **16** corners over a **0.32** scrim. A standard sheet is on **surface** and pushes the content. `M3ESideSheetLayout` makes it modal below **600**. Customize it on `M3ESideSheetTheme`. ```dart // Modal M3ESideSheet.show( context, title: 'Filters', body: const FilterList(), ); // Standard next to your content, modal on compact windows M3ESideSheetLayout( controller: controller, body: const Inbox(), sheet: const M3ESideSheet.standard(title: 'Details', body: Details()), ); ``` Keyboard: Tab moves through the icons, content and actions. Escape closes a modal sheet. ### Navigation > See also: [`example/lib/pages/playground/nav/`](https://github.com/paadevelopments/material_3_expressive/blob/main/example/lib/pages/playground/nav/) (Nav tab) #### M3EAppBar Top, search, sliver and bottom app bars. The small bar is **64**, flexible medium **112** and large **120** (taller with a subtitle), and docked bars pad for the system bars (`safeArea`). `hideMode` and `M3EAppBarController` collapse or hide the bar on scroll. For a `.top` or `.search` bar that collapses, set `extendBodyBehindAppBar: true` on the `Scaffold` so the bar moves with the content. Customize it on `M3EAppBarTheme`. ```dart Scaffold( extendBodyBehindAppBar: true, appBar: M3EAppBar.top( titleText: 'Inbox', variant: M3EAppBarVariant.mediumFlexible, actions: const [Icon(M3EIcons.search)], ), body: ListView(children: messages), ); // In a CustomScrollView M3EAppBar.sliver(titleText: 'Inbox'); ``` Keyboard: Tab, then Space or Enter on the actions. #### M3ETabs Primary and secondary tab bars, **48** tall (**64** for primary icon and label), with a **3** (primary) or **2** (secondary) indicator. `M3ETabsView` keeps a swipeable body in sync, and `.sliver` scrolls away with content. Customize it on `M3ETabTheme`. ```dart // in State M3ETabs( selectedIndex: tabIndex, onTabSelected: (i) => setState(() => tabIndex = i), tabs: const [ M3ETab(label: 'Overview'), M3ETab(label: 'Specs'), ], ); ``` Keyboard: Tab enters. Left and Right move. Space or Enter selects. #### M3ENavigationBar Bottom navigation with a selection pill that scales in place. Wide windows get a row of icon-and-label chips, and `hideOnScroll` with `M3ENavigationBarController` hides it on scroll. Customize it on `M3ENavigationBarTheme`. ```dart // in State M3ENavigationBar( destinations: const [ M3ENavigationBarDestination(icon: Icon(M3EIcons.home), label: 'Home'), M3ENavigationBarDestination(icon: Icon(M3EIcons.search), label: 'Search'), ], selectedIndex: barIndex, onDestinationSelected: (i) => setState(() => barIndex = i), ); ``` Keyboard: Tab enters. Left and Right move. Space or Enter selects. #### M3ENavigationRail Vertical navigation, **96** wide collapsed (**80** narrow) and **220–360** expanded, with an optional FAB slot. A modal rail closes on the scrim, Escape or back. `M3ENavigationRailController` expands, collapses and selects. Customize it on `M3ENavigationRailTheme`. ```dart // in State M3ENavigationRail( sections: const [ M3ENavigationRailSection( destinations: [ M3ENavigationRailDestination(icon: Icon(M3EIcons.home), label: 'Home'), M3ENavigationRailDestination(icon: Icon(M3EIcons.search), label: 'Search'), ], ), ], selectedIndex: railIndex, onDestinationSelected: (i) => setState(() => railIndex = i), ); ``` Keyboard: Tab enters. Arrows move. Space or Enter selects. Escape closes a modal rail. #### M3ENavigationDrawer Standard (default) or modal drawer, **360** wide with **16** end corners. A modal drawer closes on a destination, the scrim, a drag or back, and `M3ENavigationDrawerController` opens and closes it. Customize it on `M3ENavigationDrawerTheme`. ```dart // in State M3ENavigationDrawer( headline: 'Mail', destinations: const [ M3ENavigationDestination(icon: Icon(M3EIcons.inbox), label: 'Inbox'), M3ENavigationDestination(icon: Icon(M3EIcons.favorite), label: 'Starred'), ], selectedIndex: drawerIndex, onDestinationSelected: (i) => setState(() => drawerIndex = i), ); ``` Keyboard: Tab enters. Up and Down move. Space or Enter selects. #### M3EToolbar Floating (default) or docked toolbar, **64** tall. A floating toolbar is a pill placed by `alignment`, **16** off the edge (`screenOffset`), with an optional paired FAB. `M3EToolbar.docked` spans the width and lays out actions at **600** and wider with `contentAlignment`. Customize it on `M3EToolbarTheme`. ```dart M3EToolbar( actions: [ M3EToolbarAction(icon: M3EIcons.edit, onPressed: () {}), M3EToolbarAction(icon: M3EIcons.share, onPressed: () {}), ], ); M3EToolbar.docked( actions: [ M3EToolbarAction(icon: M3EIcons.search, onPressed: () {}), M3EToolbarAction(icon: M3EIcons.delete, onPressed: () {}), ], ); ``` Keyboard: Tab or arrows move between actions. Space or Enter activates. #### M3EMenu Vertical and baseline menus, **112–280** wide with **48** entries, plus groups, submenus and multi-select. Opening focuses the first enabled item, and back closes a submenu, then the menu. Customize it on `M3EMenuTheme`. ```dart M3EMenu( anchorBuilder: (context, open) => M3EButton( onPressed: open, child: const Text('Open menu'), ), children: [ M3EMenuGroup.entries( entries: [ M3EMenuEntry(label: 'Edit', onPressed: () {}), M3EMenuEntry(label: 'Copy', trailingText: '⌘C', onPressed: () {}), ], ), ], ); ``` Keyboard: Up and Down move. Left and Right open or close a submenu. Letters jump. Enter or Space activates. Escape closes. ### Feedback > See also: [`example/lib/pages/playground/find/`](https://github.com/paadevelopments/material_3_expressive/blob/main/example/lib/pages/playground/find/) (Find tab) #### M3EBadge A **6** dot or a label badge (at least **16**) in **error** and **on error**, drawn over its child without moving it. Counts cap at **999**. Customize it on `M3EBadgeTheme`. ```dart const M3EBadge( count: 8, child: Icon(M3EIcons.mail), ); ``` #### M3EProgressIndicator Circular and linear progress, flat or wavy, determinate or indeterminate. The indicator is **primary** on a **secondary container** track (`showTrack: false` hides it). Customize it on `M3EProgressIndicatorTheme`. ```dart const M3EProgressIndicator.circular(); // indeterminate M3EProgressIndicator.linearWavy(value: 0.6); ``` #### M3ELoadingIndicator Indeterminate morphing shape, **48** outer and **38** active by default, plain or `contained`. `size` scales both together. Customize it on `M3ELoadingIndicatorTheme`. ```dart const M3ELoadingIndicator(); const M3ELoadingIndicator( variant: M3ELoadingIndicatorVariant.contained, size: 96, ); ``` #### M3ERefreshIndicator Pull-to-refresh for scrollables that shows a contained `M3ELoadingIndicator`. It arms once fully revealed, and `M3ERefreshIndicatorController.show()` refreshes from code. Customize it on `M3ERefreshIndicatorTheme`. ```dart M3ERefreshIndicator( onRefresh: () async => reload(), child: ListView(children: items), ); ``` #### M3ETooltip Plain tooltip (up to **200** wide, above the target) or rich tooltip (up to **320**, with a title and actions). `persistent` keeps a rich tooltip open. Customize it on `M3ETooltipTheme`. ```dart M3ETooltip( message: 'Compose a new message', child: M3EIconButton( icon: const Icon(M3EIcons.edit), onPressed: () {}, ), ); ``` Keyboard: the tooltip shows when its child gets keyboard focus. #### M3ESnackbar Short message at the bottom, at least **48** tall and up to **600** wide, with an optional action and close button. A bar with either stays until dismissed. Customize it on `M3ESnackbarTheme`. ```dart M3ESnackbar.show( context, message: 'Draft saved', actionLabel: 'Undo', onAction: () {}, ); ``` Keyboard: Escape dismisses it when focused. #### M3ETextField Filled or outlined field, **56** tall with **4** corners, and a label that springs between the middle and the top. It supports icons, prefix and suffix text, a placeholder, supporting or error text, a counter, required and read-only fields, clear and password buttons, multi-line input and `density` (**0** to **-3**). Focus is **primary** and errors are **error**. Customize it on `M3ETextFieldTheme` and `M3ETextFieldColorTheme`. ```dart M3ETextField( controller: nameController, label: 'Full name', supportingText: 'As it appears on your ID', showClearButton: true, ); const M3ETextField( label: 'Password', variant: M3ETextFieldVariant.outlined, obscureText: true, showPasswordToggle: true, ); ``` Keyboard: Tab focuses enabled fields. Escape unfocuses. #### M3ESearchBar / M3ESearchAnchor / M3ESliverSearchBar **56** pill search bar on **surface container high**, **24** from its pane and **12** when focused, and a search view (contained or divided) that is full-screen below **600** and docked above. `M3ESliverSearchBar` scrolls away with content. Customize it on `M3ESearchBarTheme` and `M3ESearchViewTheme`. ```dart final controller = M3ESearchController(); M3ESearchAnchor.bar( searchController: controller, barHintText: 'Search messages', suggestionsBuilder: (context, controller) => [ for (final name in names) M3EListItem(headline: name, onTap: () => controller.closeView(name)), ], ); ``` Keyboard: Tab, then Space or Enter opens the view. Arrows move through results. Escape closes. ### Modal surfaces Several components present transient UI over the app. They all require a `BuildContext` with a `Navigator` / `Overlay` ancestor (any `MaterialApp` or `WidgetsApp` provides this): | Component | API | | --------- | --- | | `M3EDialog` | `M3EDialog.show`, `.showSelectionScreen`, `.showFullScreen`, `.showAdaptive` | | `M3EBottomSheet` | `M3EBottomSheet.show`, `.showAdaptive`, `.standard` | | `M3ESideSheet` | `M3ESideSheet.show`, `M3ESideSheetLayout` | | `M3ESnackbar` | `M3ESnackbar.show` | ## Migrating from Flutter Material widgets Every M3E component is a plain widget from a single import (`package:material_3_expressive/material_3_expressive.dart`). Swap the Flutter widget for its M3E counterpart below. Callbacks keep the usual Flutter shapes (`VoidCallback`, `ValueChanged`) unless the notes say otherwise. ### App shell and theme | Flutter | M3E | Notes | | ------- | --- | ----- | | `MaterialApp` | `M3EMaterialApp` | Pass `data: M3EThemeData.light(seedColor: ...)`. Adds `autoTheming`, `dynamicColoring` and `drawUnderSystemBars`. | | `ThemeData` / `ColorScheme.fromSeed` | `M3EThemeData.light` / `M3EThemeData.dark` | Per-component themes are fields on `M3EThemeData`, changed with `copyWith`. | | `Theme(data: ..., child: ...)` | `M3ETheme(data: ..., child: ...)` | Read tokens with `M3ETheme.of(context)`. | | `Theme.of(context).textTheme` | `M3ETheme.of(context).typography` | `.baseline` and `.emphasized` scales; `typeScale` is the baseline alias. | | `Icons.*` | `M3EIcons.*` | Bundled glyph set. | ### Actions | Flutter | M3E | Notes | | ------- | --- | ----- | | `ElevatedButton` | `M3EButton.elevated` | Or `M3EButton(style: M3EButtonStyle.elevated, ...)`. | | `FilledButton` | `M3EButton.filled` | `M3EButton` defaults to filled. | | `FilledButton.tonal` | `M3EButton.tonal` | | | `OutlinedButton` | `M3EButton.outlined` | | | `TextButton` | `M3EButton.text` | | | `FilledButton.icon` and similar | `M3EButton.icon` | Takes `icon` and `label` widgets plus `style`. | | `IconButton` | `M3EIconButton` | Defaults to the filled variant; pass `variant: M3EIconButtonVariant.standard` for a plain icon button. Toggle with `isSelected` and `selectedIcon`. | | `IconButton.filled` / `.filledTonal` / `.outlined` | `M3EIconButton(variant: ...)` | `M3EIconButtonVariant.filled`, `.tonal`, `.outlined`. | | `FloatingActionButton` (and `.small` / `.large`) | `M3EFab` | `size: M3EFabSize.small / regular / medium / large`; default is `medium`. | | `FloatingActionButton.extended` | `M3EExtendedFab` | `label` is a required `String`. | | `SegmentedButton` | `M3ESegmentedButton` | `segments` are `M3ESegment(value:, label:)` with a `String` label. `selected` is a `Set`; set `multiSelect: true` for several. | | `ToggleButtons` | `M3EButtonGroup` | `actions` are `M3EButtonGroupAction`; selection by `selectedIndex` and `onSelectedIndexChanged`. | | `PopupMenuButton` next to a button | `M3ESplitButton` | Items are `M3ESplitButtonItem(value:, child:)`. | ### Selection | Flutter | M3E | Notes | | ------- | --- | ----- | | `Checkbox` / `CheckboxListTile` | `M3ECheckbox` | Optional `label` replaces the list tile. `onChanged` is `ValueChanged`. | | `Radio` / `RadioListTile` | `M3ERadio` | Wrap options in `M3ERadioGroup` for arrow-key selection. | | `Switch` / `SwitchListTile` | `M3ESwitch` | `selectedIcon` shows an icon in the handle. | | `ActionChip` | `M3EChip` | `type: M3EChipType.assist` (default). `label` is a `String`. | | `FilterChip` | `M3EChip(type: M3EChipType.filter)` | Pass `selected`; toggle in `onPressed`. | | `InputChip` | `M3EChip(type: M3EChipType.input)` | | | `ChoiceChip` | `M3EChip(type: M3EChipType.filter)` | Keep single selection in your own state. | | Suggestion `ActionChip` | `M3EChip(type: M3EChipType.suggestion)` | | | `DropdownButton` / `DropdownMenu` | `M3EDropdownMenu` | Items are `M3EDropdownItem(label:, value:)`; `singleSelect: true` for one value. `.future` loads items async. | | `Slider` | `M3ESlider` | `size: M3ESliderSize.xs ... xl`. Also `.centered`, `.wavy`, `.vertical`. | | `RangeSlider` | `M3ERangeSlider` | | | `CalendarDatePicker` | `M3ECalendarDatePicker` | | | `showDatePicker` | `M3EDatePicker.show` | Returns `Future`. | | `showDateRangePicker` | `M3EDatePicker.showRange` | Returns `Future`. | | `showTimePicker` | `M3ETimePicker.show` | Returns `Future`, not `TimeOfDay`. Inline dial: `M3EDialTimePicker`. | ### Containment | Flutter | M3E | Notes | | ------- | --- | ----- | | `Card` / `Card.filled` / `Card.outlined` | `M3ECard` | `variant: M3ECardVariant.elevated` (default), `.filled`, `.outlined`. Slots: `media`, `headline`, `supportingText`, `actions`. | | `Dismissible` | `M3ESwipeToDismissBox` | Pass a `M3ESwipeToDismissBoxState`, `content` and `backgroundContent`; `onDismiss` gets a `M3ESwipeToDismissBoxValue`. | | `CarouselView` | `M3ECarousel` | `type: M3ECarouselType.*`; children are `M3ECarouselItem`. | | `ListTile` | `M3EListItem` | `headline` and `supportingText` are `String`s; `leading` / `trailing` widgets. | | `ListView` of tiles | `M3EList` | `itemCount` + `itemBuilder`; `.scrollable` for a lazy list, `.sliver` for a `CustomScrollView`. | | `Divider` / `VerticalDivider` | `M3EDivider` | `axis: M3EDividerAxis.vertical` for vertical. | | `Scrollbar` / `RawScrollbar` | `M3EScrollbar.nonInteractive` / `M3EScrollbar.interactive` | Takes the scrollable's `controller`. The interactive variant reports `onThumbDrag` and `onTrackPress` as a fraction; you scroll the controller. | | `showDialog` + `AlertDialog` | `M3EDialog.show(context, dialog: M3EDialog(...))` | `title` is an optional `String`. Full-screen: `M3EDialog.showFullScreen`; adaptive: `M3EDialog.showAdaptive`. | | `showModalBottomSheet` | `M3EBottomSheet.show(context, builder: ...)` | | | `BottomSheet` (persistent) | `M3EBottomSheet.standard` | Driven by `M3EBottomSheetController`. | | `Scaffold.endDrawer` used as a side panel | `M3ESideSheet.show` / `M3ESideSheetLayout` | | ### Navigation | Flutter | M3E | Notes | | ------- | --- | ----- | | `AppBar` | `M3EAppBar.top` | `titleText` for a `String` title; `variant: M3EAppBarVariant.small` (default), `.medium`, `.large`, `.mediumFlexible`, `.largeFlexible`. | | `SliverAppBar` (and `.medium` / `.large`) | `M3EAppBar.sliver` | | | `BottomAppBar` | `M3EAppBar.bottom` or `M3EToolbar.docked` | | | `TabBar` | `M3ETabs` | `tabs` are `M3ETab(label:)`; selection by `selectedIndex` and `onTabSelected` (no `TabController` needed). `variant: M3ETabsVariant.secondary` for secondary tabs. | | `TabBarView` | `M3ETabsView` | | | `NavigationBar` / `BottomNavigationBar` | `M3ENavigationBar` | Destinations are `M3ENavigationBarDestination(icon:, label:)`. | | `NavigationRail` | `M3ENavigationRail` | Destinations sit in `sections: [M3ENavigationRailSection(destinations: [...])]`. | | `NavigationDrawer` / `Drawer` | `M3ENavigationDrawer` | Destinations are `M3ENavigationDestination`. | | `MenuAnchor` / `PopupMenuButton` | `M3EMenu` | `anchorBuilder: (context, open) => ...`; entries in `M3EMenuGroup.entries`. | ### Feedback and input | Flutter | M3E | Notes | | ------- | --- | ----- | | `Badge` / `Badge.count` | `M3EBadge` | `count` or a `String` `label` for a large badge; `showDot: true` for a small dot. | | `CircularProgressIndicator` | `M3EProgressIndicator.circular` | Also `.circularWavy`. Omit `value` for indeterminate. | | `LinearProgressIndicator` | `M3EProgressIndicator.linear` | Also `.linearWavy`. | | (no Flutter equivalent) | `M3ELoadingIndicator` | Morphing-shape indeterminate loader. | | `RefreshIndicator` | `M3ERefreshIndicator` | Same `onRefresh` + `child` shape. | | `Tooltip` | `M3ETooltip` | `message` for a plain tooltip; `richTitle` and actions for a rich one. | | `ScaffoldMessenger.of(context).showSnackBar` | `M3ESnackbar.show(context, message: ...)` | `actionLabel` + `onAction` for an action. | | `TextField` / `TextFormField` | `M3ETextField` | `label` is a `String`; `variant: M3ETextFieldVariant.filled` (default) or `.outlined`. Built-in `showClearButton` and `showPasswordToggle`. | | `SearchBar` | `M3ESearchBar` | | | `SearchAnchor` / `SearchAnchor.bar` | `M3ESearchAnchor` / `M3ESearchAnchor.bar` | Controller is `M3ESearchController`. | | `SliverAppBar` with a search field | `M3ESliverSearchBar` | | Generated from README.md by tools/llms/generate_llms.dart. Do not edit by hand.