Raxol.UI.Components.Input.Button (Raxol v0.2.0)
View SourceButton component for interactive UI elements.
This component provides a clickable button with customizable appearance and behavior.
Summary
Functions
Handles input events for the button component.
Initializes the button component state.
Creates a new button component with the given options.
Renders the button component based on its current state.
Updates the button component state based on external messages.
Types
Functions
Handles input events for the button component.
Parameters
button
- The button componentevent
- The input event to handlecontext
- The event context
Returns
{:update, updated_button}
if the button state changed,
{:handled, button}
if the event was handled but state didn't change,
:passthrough
if the event wasn't handled by the button.
Initializes the button component state.
Creates a new button component with the given options.
Options
:id
- Unique identifier for the button:label
- Text to display on the button:on_click
- Function to call when the button is clicked:disabled
- Whether the button is disabled:focused
- Whether the button currently has focus (default: false):theme
- Theme overrides for the button:width
- Optional fixed width for the button:height
- Optional fixed height for the button:shortcut
- Optional keyboard shortcut for the button:tooltip
- Optional tooltip text:role
- Optional semantic role affecting appearance (:primary, :secondary, :danger, :success)
Returns
A new button component struct.
Renders the button component based on its current state.
Parameters
button
- The button component to rendercontext
- The rendering context
Returns
A rendered view representation of the button.
Updates the button component state based on external messages.