Chips
A chip is a compact tag with a label and, optionally, an icon on the left (
avatar
) and a delete cross. The five kinds differ in behavior:
Chip
just shows a label,
ActionChip
— an action on tap,
ChoiceChip
— one option out of several,
FilterChip
— a toggle filter with a check mark,
InputChip
— an entered value (a recipient, a tag) that can be selected and deleted.
The chip's content is set by
children with an
id
:
id:label
— the label (required: without it the chip is not drawn),
id:avatar
— the icon on the left,
id:deleteIcon
— your own delete icon (on
Chip
and
InputChip
). Like
Checkbox
, selectable chips do not store state: they show
selected
and report a tap through the
onSelected
handler, which receives the new value.
Common styling parameters
All five chips have these parameters (except those marked in the tables below):
| Parameter | Type | Default | Description |
|---|---|---|---|
backgroundColor
|
color | — | Background |
shadowColor
|
color | — | Shadow color |
surfaceTintColor
|
color | — | Surface tint that depends on elevation |
elevation
|
double | — | Shadow height |
#shape
|
OutlinedBorder | — |
Shape:
#shape rounded
with its own
#borderRadius
,
stadium
|
#side
|
BorderSide | — |
Border:
color
,
width
|
#padding
|
EdgeInsets | — | Padding around the content |
#labelPadding
|
EdgeInsets | — | Padding around the label |
#labelStyle
|
TextStyle | — | Label style |
#visualDensity
|
VisualDensity | — |
Density:
standard
,
comfortable
,
compact
,
adaptivePlatformDensity
|
Chip
A label without selection: a tag, a category, a status. With
onDeleted
a delete cross appears on the right.
Type:
multi-child
Chip
Text id:label "New"
| Parameter | Type | Default | Description |
|---|---|---|---|
onDeleted
|
callback | — | Tap on the cross. Without it there is no cross |
backgroundColor
,
shadowColor
,
surfaceTintColor
,
elevation
|
— | — | See "Common styling parameters" |
#shape
,
#side
,
#padding
,
#labelPadding
,
#labelStyle
,
#visualDensity
|
— | — | See "Common styling parameters" |
@design:true
Wrap spacing:8
Chip if:$design backgroundColor:#e0e7ff onDeleted:(){design = false}
Text id:label "Design"
CircleAvatar id:avatar radius:12 backgroundColor:#4f46e5
Text "D"
#style color:#ffffff fontSize:10
Chip
Text id:label "Development"
ActionChip
An action chip: calls
onPressed
on tap. Good for suggestions like "Add to calendar".
Type:
multi-child
ActionChip onPressed:"navigate:/calendar"
Text id:label "Add to calendar"
Icon id:avatar event
| Parameter | Type | Default | Description |
|---|---|---|---|
onPressed
|
callback | — | Tap. Without it the chip is disabled |
pressElevation
|
double | — | Shadow height while pressed |
backgroundColor
,
shadowColor
,
surfaceTintColor
,
elevation
|
— | — | See "Common styling parameters" |
#shape
,
#side
,
#padding
,
#labelPadding
,
#labelStyle
,
#visualDensity
|
— | — | See "Common styling parameters" |
ChoiceChip
A chip for picking one option from a group — like
Radio
, but as tags. A group is several chips whose
selected
compares one variable with their own value.
Type:
multi-child
@plan:"month"
Row spacing:8
ChoiceChip selected:{plan == "month"} onSelected:(selected){plan = "month"}
Text id:label "Month"
ChoiceChip selected:{plan == "year"} onSelected:(selected){plan = "year"}
Text id:label "Year"
| Parameter | Type | Default | Description |
|---|---|---|---|
selected
|
bool | false | Whether the chip is selected |
onSelected
|
callback | — |
Tap; receives the new value of
selected
.
Without it the chip is disabled
|
selectedColor
|
color | — | Background of a selected chip |
disabledColor
|
color | — | Background of a disabled chip |
pressElevation
|
double | — | Shadow height while pressed |
backgroundColor
,
shadowColor
,
surfaceTintColor
,
elevation
|
— | — | See "Common styling parameters" |
#shape
,
#side
,
#padding
,
#labelPadding
,
#labelStyle
,
#visualDensity
|
— | — | See "Common styling parameters" |
FilterChip
A toggle filter: a selected chip shows a check mark. Several filters toggle independently, like Checkbox .
Type:
multi-child
@vegan:false
FilterChip selected:$vegan onSelected:(selected){vegan = selected}
Text id:label "Vegetarian"
| Parameter | Type | Default | Description |
|---|---|---|---|
selected
|
bool | false | Whether the filter is on |
onSelected
|
callback | — |
Tap; receives the new value of
selected
.
Without it the chip is disabled
|
checkmarkColor
|
color | — | Color of the check mark |
selectedColor
|
color | — | Background of a selected chip |
disabledColor
|
color | — | Background of a disabled chip |
pressElevation
|
double | — | Shadow height while pressed |
backgroundColor
,
shadowColor
,
surfaceTintColor
,
elevation
|
— | — | See "Common styling parameters" |
#shape
,
#side
,
#padding
,
#labelPadding
,
#labelStyle
,
#visualDensity
|
— | — | See "Common styling parameters" |
InputChip
A chip for an entered value: an email recipient, a chosen tag. It can be tapped (
onPressed
), selected (
selected
/
onSelected
) and deleted (
onDeleted
).
Type:
multi-child
@anna:true
Wrap spacing:8
InputChip if:$anna onDeleted:(){anna = false}
Text id:label "anna@example.com"
CircleAvatar id:avatar radius:12 backgroundColor:#4f46e5
Text "A"
#style color:#ffffff fontSize:10
| Parameter | Type | Default | Description |
|---|---|---|---|
onPressed
|
callback | — | Tap on the chip |
onSelected
|
callback | — |
Selection; receives the new value of
selected
|
onDeleted
|
callback | — | Tap on the cross. Without it there is no cross |
selected
|
bool | false | Whether the chip is selected |
selectedColor
|
color | — | Background of a selected chip |
disabledColor
|
color | — | Background of a disabled chip |
pressElevation
|
double | — | Shadow height while pressed |
backgroundColor
,
shadowColor
,
surfaceTintColor
,
elevation
|
— | — | See "Common styling parameters" |
#shape
,
#side
,
#padding
,
#labelPadding
,
#labelStyle
,
#visualDensity
|
— | — | See "Common styling parameters" |
Examples
A set of filters
@vegan:false
@spicy:true
@fast:false
Wrap spacing:8
FilterChip selected:$vegan checkmarkColor:#4f46e5 selectedColor:#e0e7ff onSelected:(selected){vegan = selected}
Text id:label "Vegetarian"
FilterChip selected:$spicy checkmarkColor:#4f46e5 selectedColor:#e0e7ff onSelected:(selected){spicy = selected}
Text id:label "Spicy"
FilterChip selected:$fast checkmarkColor:#4f46e5 selectedColor:#e0e7ff onSelected:(selected){fast = selected}
Text id:label "Quick"
A chip with a custom shape
Chip backgroundColor:#ffffff
#shape rounded
#borderRadius circular 6
#side color:#cbd5e1 width:1
#labelStyle fontSize:12 fontWeight:w600
Text id:label "BETA"
Differences between the app and the site
On the site chips are drawn as a
static picture
— a tag with the label, the
avatar
icon and, on a selected
FilterChip
, a "✓" check mark in
checkmarkColor
. The
backgroundColor
and
selectedColor
colors are read.
-
Taps are not handled:
onPressed,onSelected,onDeletedare not called on the site. -
selectedis read once when the page is built and does not change afterwards. -
The delete cross (
onDeleted,id:deleteIcon) is not drawn on the site. - For choices on the site, use Radio , Checkbox or buttons.
See also
-
Choosing from options
—
Radio,SegmentedButton - Checkbox — independent checkboxes
- Material buttons — actions as buttons
- Wrap — laying out a set of chips with wrapping