iced-cube

Actions

Icon Button

A square button that shows only an icon, with a label and an optional pressed state.

use iced_cube::{icon_button, lucide};
use iced_cube::primitives::button::Size;
use iced_cube::primitives::icon_button::Variant;
API reference
Formatting toolbar: Toggles that stay pressed while a format is on, with labels shown as tooltips.Formatting toolbar: Toggles that stay pressed while a format is on, with labels shown as tooltips.
Static preview
Formatting toolbar. Toggles that stay pressed while a format is on, with labels shown as tooltips.

Usage

Give every icon button a label. The icon alone rarely says enough, and the label shows as a tooltip so people can check what a button does before they press it. iced 0.14 has no screen reader support, so the label cannot reach assistive technology yet.

A pressed icon button is a toggle: the app holds the on or off value and passes it to .pressed, and the button’s message flips it. Use pressed buttons for formatting in a toolbar, or for a group where exactly one option is on, such as text alignment.

Icon buttons share their sizes and colours with Button. There is no Link variant, because a link needs text to read as one; on an icon alone it would look the same as Ghost. The icon-button feature turns on button and tooltip.

A disabled icon button draws its icon at half opacity, like the label of a disabled text button.

Examples

Variants

The same variants as a text button.

Variants: The same variants as a text button.Variants: The same variants as a text button.
Static preview

Sizes

Small, medium and large squares.

Sizes: Small, medium and large squares.Sizes: Small, medium and large squares.
Static preview

Enabled and disabled

Undo and redo turn off when there is nothing to undo or redo. A disabled icon is drawn at half opacity.

Enabled and disabled: Undo and redo turn off when there is nothing to undo or redo. A disabled icon is drawn at half opacity.Enabled and disabled: Undo and redo turn off when there is nothing to undo or redo. A disabled icon is drawn at half opacity.
Static preview

API

ItemDescription
icon_button(glyph)Creates a square ghost button showing a Lucide icon. It renders disabled until it has a message.
.label(text)Names the action, such as "Bold". The label shows as a tooltip on hover.
.tooltip(Option<Position>)Where the label's tooltip appears, or None to never show it. Defaults to Some(Position::Top).
.pressed(bool)Draws the button as switched on, for toolbar toggles. Pass the value your app holds.
.variant(Variant)Primary, Secondary, Destructive, Outline or Ghost: the text button variants without Link. Defaults to Ghost.
.size(Size)The button Size: Sm is 32 pixels square, Md is 36 and Lg is 40. Defaults to Md.
.on_press(message) / .on_press_maybe(option)Sets the message emitted on press. None disables the button.
.id(id)Sets a widget id, for clicking the button in tests.
colours(tokens, variant, pressed, status) / style(...)The resolved colours and iced style, for reuse in custom widgets.
Esc