Buttons
The buttons on this page belong to GTK. Gtk.Button is the plain button every
other one is built on; the rest are the ones that add a state or a target to it —
Gtk.ToggleButton stays pressed, Gtk.LinkButton follows a URI, Gtk.ScaleButton
opens a scale, and the two dialog buttons open a colour or a font chooser.
Gtk.MenuButton is the one whose press opens a menu. Libadwaita ships none of
them. The buttons it does ship are on
Adwaita Buttons.
Button Styles
Section titled “Button Styles”Add a style class to restyle a plain button. .pill makes it rounded and
prominent, .circular suits an icon-only button, .suggested-action and
.destructive-action colour an affirmative or a dangerous action, and .flat
drops the visible background. They compose, and they mean the same thing
everywhere in the toolkit.
Toggle Button
Section titled “Toggle Button”A button that stays pressed. It is a Gtk.Button with one more property,
active, so the label, the icon and every style class of the plain button work
on it unchanged. Listen for toggled (or notify::active) to follow the state.
group makes two or more of them mutually exclusive: setting one active releases
the others, and the member you linked cannot be clicked back off, so a group always
keeps exactly one press. Link the later button to the earlier one — loop.group = mute puts loop into mute’s group, which is the half that stops being
clickable-off. To pick exactly one of several style classes instead, use the
toggle group.
Link Button
Section titled “Link Button”A button that follows a URI — a uri, and a visited state saying it has
been followed. Clicking launches the URI and marks the link visited; pointing the
button somewhere new un-visits it, because the new target has not been seen. Listen
for activate-link to handle the click yourself: cancel the event and neither the
launch nor the visit happens.
The context menu of the native widget (copy the URL, on Shift+F10) is the platform’s own here — a browser already owns that menu on a button.
Scale Button
Section titled “Scale Button”A button whose press opens a scale — the volume control of a media player, the brightness slider of a toolbar. It is a toggle button with an icon plus a popover holding a minus stepper, the scale and a plus one.
The icon follows the value, and how depends on how many names the icons list
holds: none draws image-missing; one name is used throughout; two split the range
in half; three or more put the first at the bottom and the second at the top, and
spread what is left evenly over the values between. The steppers move by the range’s page increment and
go insensitive at their end of it. Listen for value-changed to follow the value.
has-frame draws the icon button with a frame (it has none by default, so it is flat), and the orientation axis is vertical unless you say otherwise — which is why a scale button grows upwards.
Color Dialog Button
Section titled “Color Dialog Button”A button that shows a colour and opens a chooser for it — the swatch in a preferences dialog. rgba is the colour, in any spelling the browser knows, and the swatch announces its channel percentages (“Red 75%, Green 25%, Blue 25%”), with the alpha clause appearing only while the colour is translucent.
The button is insensitive until a dialog is set, which is GTK’s own rule, so
markup needs the dialog attribute and code needs the dialog property. The
chooser itself is the platform’s colour picker here, which has no alpha channel: a
colour chosen in it keeps the alpha the button already had.
Font Dialog Button
Section titled “Font Dialog Button”A button that shows a font and opens a chooser for it. The font-desc is a
Pango font description — "Sans Bold 12", the spelling Pango itself reads and
writes — and the label is its family, with its size beside it.
The level decides how much of the font the chooser offers, and what the label
shows: at family the label is the family name alone and no size is drawn; at
face the style words join it; from font up the size appears beside it. use-font
draws the family label in the selected font, and use-size decides whether the size
is drawn in it too. font-features and language ride along with them.
As with the colour button, the button is insensitive until a dialog is set.
Menu Button
Section titled “Menu Button”When a button’s only job is to open a menu, use a menu button: the hamburger at the end of a header bar, with no action of its own and every choice in the popover it opens.
Related
Section titled “Related”- Controls: the entry and the drop down, the other two GTK widgets the Adwaita stylesheet paints.
- Layout: the separator, the first of the GTK layout widgets.
- Adwaita Buttons: button content, the split button and the toggle group.
- Adwaita Storybook: the same widgets in a live component browser you can poke at.