Button -- clickable widget that emits %Widget{type: :click, id: id} events.
The button can contain either a text label (via the label or content prop)
or arbitrary child content (if children are provided, the first child is rendered).
Props
label(string) -- text label displayed on the button. Also acceptscontentas an alias.style-- named preset atom (:primary(default),:secondary,:success,:warning,:danger,:text,:background,:subtle) orStyleMap.t()for custom styling. SeeToddy.Iced.StyleMap.width(length) -- button width. Default: shrink. SeeToddy.Iced.Length.height(length) -- button height. Default: shrink.padding(number | map) -- internal padding. SeeToddy.Iced.Padding.clip(boolean) -- clip child content that overflows. Default: false.disabled(boolean) -- disable the button (no click events). Default: false.enabled(boolean) -- inverse of disabled. Default: true.a11y(map) -- accessibility overrides. SeeToddy.Iced.A11y.
Events
%Widget{type: :click, id: id}-- emitted on press (unless disabled).
Summary
Functions
Sets accessibility annotations.
Converts this button struct to a ui_node() map via the Toddy.Iced.Widget protocol.
Sets whether child content is clipped on overflow.
Sets whether the button is disabled.
Sets the button height.
Creates a new button struct with the given label and optional keyword opts.
Sets the button padding.
Sets the button style. Accepts a preset atom or StyleMap.
Sets the button width.
Applies keyword options to an existing button struct.
Types
@type option() :: {:width, Toddy.Iced.Length.t()} | {:height, Toddy.Iced.Length.t()} | {:padding, Toddy.Iced.Padding.t()} | {:clip, boolean()} | {:style, style()} | {:disabled, boolean()} | {:enabled, boolean()} | {:a11y, Toddy.Iced.A11y.t()}
@type preset() ::
:subtle
| :background
| :text
| :danger
| :warning
| :success
| :secondary
| :primary
@type style() :: preset() | Toddy.Iced.StyleMap.t()
@type t() :: %Toddy.Iced.Widget.Button{ a11y: Toddy.Iced.A11y.t() | nil, clip: boolean() | nil, disabled: boolean() | nil, height: Toddy.Iced.Length.t() | nil, id: String.t(), label: String.t(), padding: Toddy.Iced.Padding.t() | nil, style: style() | nil, width: Toddy.Iced.Length.t() | nil }
Functions
@spec a11y(button :: t(), a11y :: Toddy.Iced.A11y.t()) :: t()
Sets accessibility annotations.
@spec build(button :: t()) :: Toddy.Iced.ui_node()
Converts this button struct to a ui_node() map via the Toddy.Iced.Widget protocol.
Sets whether child content is clipped on overflow.
Sets whether the button is disabled.
@spec height(button :: t(), height :: Toddy.Iced.Length.t()) :: t()
Sets the button height.
Creates a new button struct with the given label and optional keyword opts.
@spec padding(button :: t(), padding :: Toddy.Iced.Padding.t()) :: t()
Sets the button padding.
Sets the button style. Accepts a preset atom or StyleMap.
@spec width(button :: t(), width :: Toddy.Iced.Length.t()) :: t()
Sets the button width.
Applies keyword options to an existing button struct.