Rendered by GPUI’s web backend from the real component. Requires a browser with WebGPU.
Button is the activation primitive the other controls build on. It owns
pointer and Enter/Space activation, focus, the disabled state and the native
Button role; its content, spacing, shape and state styling belong to the
application.
Copy the same light and dark button variants used in the preview into your application.
cargo run -p gpui-deck-cli --locked -- add button --to ../my-app/src/uiuse ui::{Appearance, recipes::ButtonVariant};
let palette = Appearance::Settings.palette();
ButtonVariant::Primary
.apply(Button::new("save").accessibility_label("Save session"), palette)
.on_click(|_, window, cx| {
// The application decides what activation does.
})
.child("Save")Activation and focus
A click, Enter or Space activates the button once. .disabled(true) ignores
activation and removes the Tab stop; a button disabled while focused keeps its
focus binding until focus leaves, so Tab can continue in either direction.
.track_focus(&handle) uses an application-owned focus handle, for example to
restore focus after a dialog closes. .tab_index(...) and .tab_stop(...)
adjust traversal.
Accessibility
Name the button with .accessibility_label(...) whenever its children are not
plain text, such as an icon-only button. .selected(true) drives selected
styling only; .current(true) separately exposes aria-current="page" for
navigation entries, so a selected look never implies the current page.
Toggle, the Collapsible and Tooltip triggers, CarouselControl and the menu triggers compose Button, so they share this activation and focus contract.