Add an icon to a button or a menu entry
An icon helps a reader find a control at a glance. A plus sign says “new”. A pencil says “edit”. MatterData has a fixed set of icons. You name one, and the engine draws it.
Put an icon beside a label
Section titled “Put an icon beside a label”Write icon and a name after the label. The icon appears before the text.
nav main "Club" { dashboard "Overview" icon layout_dashboard members icon users}The same words work after the label of a button, a row_action and a transition.
report of members "Members" { button "New member" icon plus -> member row_action "Edit" icon pencil -> member}Find the name you need on the Icons page. Names use underscores, for
example trash_2. If you write a name that is not in the set, the compiler stops and shows the
names it knows.
Show an icon without its label
Section titled “Show an icon without its label”Some controls are small, and the icon is clear enough. Add only after the name.
report of members "Members" { button "Import" icon upload only -> import row_action "Edit" icon pencil only -> member}You still write the label. The engine keeps it as the name of the control, so a screen reader
announces Edit and a mouse shows Edit as a tooltip. Use only for actions that most
readers know. Keep the label visible for actions that are new to them.
Two rules apply:
- A menu entry always shows its label, so
onlyon a menu entry is a compile error. - A button in the menu next to the main button of a report always shows its label. The menu draws
the icon and ignores
only.
What the engine does for you
Section titled “What the engine does for you”- The icon has the colour of the text, in light and dark mode.
- The icon is hidden from screen readers. The label is what they read.
- The sheet draws its own icons. Undo and redo are icons. Add row, Delete rows and Save show an icon beside their words. You do not declare these.
The icons are from Lucide, under the ISC licence. matterdata notices prints the licence
notice.