Expand description
Button — a labelled, activatable action trigger.
Button is the primary action surface in Teksilo. It renders a text
label (optionally with a leading, trailing, top, or bottom icon), fires
a closure on click / Space / Enter / AT click, and advertises seven
design-language variants via ButtonVariant. Chrome (fill, border,
focus ring, padding) is delegated to the active [ButtonStyle]; the
default RecipeButtonStyle implements the Int UI token ladder.
§When to use
- Primary action:
.variant(ButtonVariant::Filled)— one per context. - Secondary / cancel: default
ButtonVariant::Plain. - Danger:
ButtonVariant::Destructive(IntUI maps this to Filled). - Text-only link:
ButtonVariant::Link/ButtonVariant::Ghost.
§Touch and pen
The pressed visual is the framework’s, not the button’s own: the router
keeps one press record per contact and Button mirrors it onto its
InteractionState (bind_press_interaction). That buys four things a
PointerDown / PointerUp pair inside a handler cannot see — a press that
slides off its target goes out and comes back on re-entry (WCAG 2.2
SC 2.5.2), a press a pan claimant or an ancestor drag wins is cleared with
no release to hang the reset on, a cancel clears it, and a press inside a
scrollable withholds the visual for 100 ms so a finger that turns out to be
scrolling never flashes a highlight. docs/touch-and-pen.md §7.1.
Activation has always been on_tap, so it already lands on the release.
After a mouse or pen release the button rests hovered as it always has;
after a finger release it rests idle, because a finger sends no
hover-leave to correct a hovered state with.
The whole family — IconButton, CommandLinkButton, every Toolbar
command — shares build_interaction_handlers and gets all of this with it.
§Label colour
The label and icon take their colour from the interaction state
(OnAccent on accent fills, Primary otherwise, Link for links). The
active [ButtonStyle] may redirect it per variant with label_text_role,
or per variant and state with label_text_role_for — for example to
brighten the label on hover. Both are repaint-only; a per-call
Button::text_role wins over them.
§Accessibility
Announces as Role::Button with the resolved label as its AT name.
Keyboard: Space / Enter activate; the lone-KeyUp guard prevents spurious
re-activation when a shortcut consumes the KeyDown and returns focus here.
let _btn = Button::new(lit!("Save"))
.variant(ButtonVariant::Filled)
.on_activate_fn(|ctx| ctx.send_intent(Intent::new("app.save")));Structs§
- Button
- A labelled action trigger; use
Button::newand chain builder methods.
Enums§
- Button
Variant - Closed enum naming the design-language variants of
Button. Seeteksilo_core::styles::ButtonVariantfor the canonical definition. - Icon
Location - Where an optional icon is placed relative to the button label.
- Interaction
State - Internal interaction state.