Material buttons
Ready-made Material 3 buttons: filled, outlined, text, icon button and floating action button, plus
InkResponse
— a tappable area with an "ink" ripple and no button styling. All of them draw their child (text, icon, row) and call a handler on tap. A plain unstyled button and
ElevatedButton
are described in
Button
.
Which one to use:
the main action of a screen —
FilledButton
; a secondary one next to it —
OutlinedButton
; a third, least prominent one ("Cancel", "Details") —
TextButton
; an action shown as a single icon —
IconButton
; one main action above the content —
FloatingActionButton
.
The handler is written as on other elements: as an action string (
onPressed:"navigate:/home"
,
onPressed:"form:submit"
) or as a function (
onPressed:(){count = count + 1}
).
A button without
onPressed
is disabled
: gray and not tappable — both in the app and on the site.
FilledButton
A filled Material 3 button — the most prominent action on a screen. The default background is the theme's primary color.
Type:
single-child
@count:0
FilledButton onPressed:(){count = count + 1}
Text "Confirm"
| Parameter | Type | Default | Description |
|---|---|---|---|
onPressed
|
callback | — | Called on tap. Without it the button is disabled |
onHover
|
callback | — | Called when the pointer enters the button (app only) |
onExit
|
callback | — | Called when the pointer leaves the button (app only) |
#style
|
ButtonStyle | — |
Styling: colors, padding, shape, border, sizes — see "Styling with
#style
" below
|
OutlinedButton
A button with a border and a transparent background — a secondary action next to the main one.
Type:
single-child
OutlinedButton onPressed:"navigate:/back"
Text "Back"
| Parameter | Type | Default | Description |
|---|---|---|---|
onPressed
|
callback | — | Called on tap. Without it the button is disabled |
onHover
|
callback | — | The pointer entered the button (app only) |
onExit
|
callback | — | The pointer left the button (app only) |
#style
|
ButtonStyle | — |
Styling — see "Styling with
#style
" below. The border is set by
#side
|
TextButton
A flat button: just a label in the theme color, with no background or border. For the least important actions and links in text.
Type:
single-child
TextButton onPressed:"navigate:/terms"
Text "Terms of use"
| Parameter | Type | Default | Description |
|---|---|---|---|
onPressed
|
callback | — | Called on tap. Without it the button is disabled |
onHover
|
callback | — | The pointer entered the button (app only) |
onExit
|
callback | — | The pointer left the button (app only) |
#style
|
ButtonStyle | — |
Styling — see "Styling with
#style
" below
|
IconButton
A round button with an icon. The child is usually an
`Icon`
. The
tooltip
caption is shown on hover and long press and serves as the button's name for a screen reader — a button made of a single icon has no other name.
Type:
single-child
@liked:false
IconButton tooltip:"Add to favorites" onPressed:(){liked = !liked}
Icon favorite
| Parameter | Type | Default | Description |
|---|---|---|---|
onPressed
|
callback | — | Called on tap. Without it the button is disabled |
tooltip
|
string | — | Tooltip and the button's name for a screen reader |
iconSize
|
double | 24 | Icon size (24 by default in Flutter) |
color
|
color | — | Icon color |
disabledColor
|
color | — | Icon color of a disabled button |
splashColor
|
color | — | Ripple color on tap |
highlightColor
|
color | — | Highlight color while the button is pressed |
splashRadius
|
double | — | Ripple radius |
#padding
|
EdgeInsets | — | Padding around the icon (8 on all sides by default in Flutter) |
#visualDensity
|
VisualDensity | — |
Density:
standard
,
comfortable
,
compact
,
adaptivePlatformDensity
|
#style
|
ButtonStyle | — |
Styling — see "Styling with
#style
" below
|
Row spacing:4
IconButton tooltip:"Share" iconSize:32 color:#4f46e5 onPressed:"action:share"
Icon share
IconButton tooltip:"Delete" onPressed:"action:delete"
#padding all 4
#visualDensity compact
Icon delete
FloatingActionButton
A floating button for the main action: round (56 points by default,
mini
— 40), with a shadow. Usually one per screen; in a
Scaffold
it goes into its floating button slot.
Type:
single-child
FloatingActionButton tooltip:"Create" onPressed:"navigate:/new"
Icon add
| Parameter | Type | Default | Description |
|---|---|---|---|
onPressed
|
callback | — | Called on tap |
tooltip
|
string | — | Tooltip and the button's name for a screen reader (app only) |
backgroundColor
|
color | theme primary color | Button color |
foregroundColor
|
color | — | Color of the icon and text |
elevation
|
double | 6 | Shadow elevation |
mini
|
bool | false | Small 40×40 button |
#shape
|
OutlinedBorder | circle | Button shape (app only) |
heroTag
|
string | — | Tag for the flight between screens. Two floating buttons on one screen must have different tags |
// on the site tooltip does not become the button's name — Semantics gives the name
Semantics label:"Edit"
FloatingActionButton tooltip:"Edit" mini:true backgroundColor:#4f46e5 foregroundColor:#ffffff onPressed:"navigate:/edit"
Icon edit
InkResponse
A tappable area with a Material ripple — like
InkWell
, but by default the ripple spreads in a circle from the tap point and is
not clipped
by the child's bounds. Use it when the ripple must extend beyond a small icon; for a card or a list row
InkWell
is simpler.
Type:
single-child
@stars:0
InkResponse radius:30 onTap:(){stars = stars + 1}
Row spacing:4
Icon star color:#f59e0b
Text $"Rate: ${stars}"
| Parameter | Type | Default | Description |
|---|---|---|---|
onTap
|
callback | — | Tap |
onDoubleTap
|
callback | — | Double tap (app only) |
onLongPress
|
callback | — | Long press (app only) |
containedInkWell
|
bool | false |
Clip the ripple to the child's bounds (as
InkWell
does)
|
radius
|
double | — | Ripple radius |
splashColor
|
color | — | Ripple color |
highlightColor
|
color | — | Highlight color while the area is pressed |
hoverColor
|
color | — | Highlight color on hover |
focusColor
|
color | — | Highlight color on focus |
#borderRadius
|
BorderRadius | — | Corner radius of the highlight and of the ripple clip |
#customBorder
|
OutlinedBorder | — | Shape of the highlight and of the ripple clip |
InkResponse containedInkWell:true splashColor:#c7d2fe onTap:"navigate:/profile"
#borderRadius circular 12
Padding
#padding all 16
Text "Profile"
Styling with
#style
FilledButton
,
OutlinedButton
,
TextButton
,
IconButton
(as well as
ElevatedButton
and
SegmentedButton
) take the same
#style
structure.
FilledButton onPressed:"form:submit"
#style foregroundColor:#ffffff elevation:2
#backgroundColor default:#4f46e5 pressed:#3730a3 disabled:#9ca3af
#padding symmetric horizontal:32 vertical:14
#shape rounded
#borderRadius circular 12
#minimumSize fromHeight 48
Text "Send"
| Parameter | Type | Description |
|---|---|---|
backgroundColor
|
color or per state | Background |
foregroundColor
|
color or per state | Color of the label and icon |
iconColor
|
color or per state | Icon color (if different from the label) |
overlayColor
|
color or per state | Color of the layer on hover and press |
shadowColor
|
color or per state | Shadow color |
surfaceTintColor
|
color or per state | Surface tint that depends on elevation |
elevation
|
double or per state | Shadow elevation |
iconSize
|
double or per state | Icon size |
#textStyle
|
TextStyle | Label style |
#padding
|
EdgeInsets | Padding inside the button |
#shape
|
OutlinedBorder |
Shape:
rounded
,
beveled
,
circle
,
stadium
…
|
#side
|
BorderSide |
Border:
color
,
width
|
#minimumSize
,
#maximumSize
,
#fixedSize
|
Size |
Sizes:
square 48
,
fromWidth 200
,
fromHeight 48
|
Per state.
A color or a number can be set once for all states (
backgroundColor:#4f46e5
) or as a structure with state keys:
#backgroundColor default:… pressed:… hovered:… focused:… disabled:…
(also
selected
,
dragged
,
error
,
enabled
).
Examples
Main and secondary action
@saved:0
Column spacing:12
Row spacing:8
OutlinedButton onPressed:(){saved = 0}
Text "Reset"
FilledButton onPressed:(){saved = saved + 1}
#style backgroundColor:#4f46e5
#padding symmetric horizontal:24 vertical:12
Text "Save"
TextButton
Text "Unavailable"
Text $"Times saved: ${saved}"
A button with a border of its own color
OutlinedButton onPressed:"navigate:/back"
#style foregroundColor:#4f46e5
#side color:#4f46e5 width:2
#shape stadium
Row spacing:8 size:min
Icon arrowBack
Text "Back"
Differences between the app and the site
On the site the buttons are real
<button>
elements; a disabled button (without
onPressed
) gets
disabled
.
-
onHover/onExitonFilledButton,OutlinedButton,TextButtonare not called on the site. -
#style: the site readsbackgroundColor,foregroundColor,elevation,shadowColor,#paddingand#shape(rounded/stadium/beveledwith their own#borderRadiusand#side). Per-state values,#textStyle, sizes and#sidewritten directly in#style(not inside#shape) are not read on the site: theOutlinedButtonborder stays thin and gray. -
IconButton:iconSizeis not read on the site (the icon is 24 points);tooltipbecomes the button's name (aria-label), but there is no tooltip popup. On the sitecolor:paints both the icon and the button's background in one color — the icon is invisible; for now it is better to set the icon color on theIconitself. -
FloatingActionButton:backgroundColor,foregroundColor,elevation,miniare read;tooltip,#shape,heroTagare not. A button made of a single icon has no name for a screen reader on the site — wrap it inSemantics label:"…". -
InkResponseis drawn on the site as InkWell : the ripple is always clipped to the bounds;onDoubleTap,onLongPress,radius,containedInkWell,#borderRadius,#customBorderare not read. The colorssplashColor,highlightColor,hoverColor,focusColorwork.
See also
-
Button
— a plain unstyled button and
ElevatedButton - InkWell — a tappable area for cards and rows
-
Icon
— the icon for
IconButtonandFloatingActionButton -
Choosing from options
—
SegmentedButtonandToggleButtons -
Form
— a button with
onPressed:"form:submit"submits the form