IconButton

A row of small square buttons, each with its own icon and action.

The smallest icon strip#

Luau
main:IconButton({
    Text = "Playback",
    Buttons = {
        { Icon = "play",  Callback = play },
        { Icon = "pause", Callback = pause },
    },
})
Preview

My Script

v1.0

Icon strip

Each entry carries its own behaviour.

Building it up#

Each entry in Buttons is its own control, with its own icon, action and colour:

Luau
main:IconButton({
    Text = "Playback",
    Description = "Each entry carries its own behaviour.",
    Buttons = {
        { Icon = "play",       Callback = play },
        { Icon = "pause",      Callback = pause },
        { Icon = "refresh-cw", Callback = restart, Click = { Rotate = 360 } },
        { Icon = "trash-2",    Callback = clear,   Danger = true },
    },
})

For one button, drop Buttons and put the entry's options on the control itself. The icon goes on the button, and the row keeps its label:

Luau
main:IconButton({
    Text = "Config",
    Icon = "trash-2",
    Danger = true,
    Callback = clearConfig,
})

Options#

OptionTypeDefaultWhat it does
TextreqstringThe label for the whole row.
Buttonstable[]One entry per square button. Leave it out and the options table itself is the single button.
DescriptionstringA quieter second line.
IconstringAn icon for the row's label. In the single-button form it goes on the button instead.
TooltipstringShown while the pointer is over the row.
DisabledbooleanfalseRefuses input and dims the whole row.
DisabledReasonstringShown as a tooltip while it is disabled.

Each entry in Buttons takes:

OptionTypeDefaultWhat it does
IconreqstringThe glyph for this button.
CallbackfunctionCalled when this button is pressed. Takes no arguments.
DangerbooleanfalsePaints this one with the danger colour.
HovertableAnimation spec played while hovered.
ClicktableAnimation spec played on press.
HoverColorColor3 | stringThe border and glyph colour on hover, or a theme role name.
HoverFillColor3 | stringThe background colour on hover, or a theme role name.

Tooltip, Disabled and DisabledReason are read on the row, not per entry. Disabling the row disables every button in it.

The handle carries Buttons, the array of TextButton instances in the order you declared them, alongside the usual Show, Hide and Destroy.

When to use it#

An icon strip is right when the actions are related and obvious, such as play and pause. Four glyphs in a row take one line where four Button rows take four.

It is wrong when the actions need explaining. An icon alone cannot say "regenerate the config from the server", so use separate buttons with written labels for anything a first-time reader would have to guess at.