Icon
Shows a Material icon by name.
Type:
leaf
Icon play_arrow size:48 color:#FFFFFF
Parameters
| Parameter | Type | Description |
|---|---|---|
| (positional 0) | string |
Icon name (or the named
icon
)
|
size
|
double | Icon size (24 by default) |
color
|
color | Icon color |
label
|
string |
Name for the screen reader. Without it the icon is decoration: in the app it is excluded from semantics, on the site it is hidden (
aria-hidden
)
|
font
|
string |
Icon set:
material
(default),
cupertino
or a project set from
data/icons/icons.json
|
style
|
string |
Variant for sets with variants (Material):
baseline
(default),
outlined
,
rounded
,
sharp
|
Available icons
An icon is a
ligature name
in an icon font: the name is drawn as text in that font, so the whole set is available, not a list. The name is written as in the set (
more_vert
) or in camelCase (
moreVert
— turned into
more_vert
).
-
material— the default set, Material Icons:home,search,settings,favorite,arrow_forward,close,check,menu,more_vert… It has variants —style:appends a suffix to the name (home+outlined→home_outlined); a name that already has a suffix is left alone. -
cupertino— iOS-style icons (font:cupertino), without variants. -
Your own project set is added with the
data/icons/icons.jsonfile and selected by its name infont:.
The site draws the same thing: a
<span>
with the ligature name in the set's font.
Row spacing:12
Icon home
Icon home style:outlined
Icon heart font:cupertino
For the screen reader
An icon font draws a glyph from text: the site's markup contains the ligature name —
menu_baseline
,
arrow_forward
— and a screen reader would read it aloud. So an icon without
label
is hidden from the screen reader, as in Flutter.
label
is needed only when the glyph itself carries meaning that the text next to it does not say.
For a button made of a single icon, the name comes from the button, not the icon:
IconButton onPressed:(){} tooltip:"Open menu"
Icon menu
tooltip
is the button's name both in the app and on the site (
aria-label
). Any other tappable element (
InkWell
) is named by a
Semantics label:"…"
around it. A button or link left without a name on the site is shown by the editor in the diagnostics as
web_unnamed_control
.
Examples
An icon in a row
Row spacing:8 crossAxisAlignment:center
Icon star color:#FFD700 size:20
Text "4.8"
A button with an icon
ElevatedButton onPressed:"navigate:/search"
Row spacing:12 mainAxisSize:min
Icon search size:24 color:#FFFFFF
Text "Search"
See also
- Image — an arbitrary image by URL