Raxol.UI.Components.Input.Button (Raxol v2.3.0)

View Source

Button component for user input.

Summary

Functions

Handles input events for the button component.

Initializes the Button component state from the given props.

Mounts the Button component. Performs any setup needed after initialization.

Creates a new Button state map, applying defaults. Expects opts to be a Map.

Renders the button component based on its current state.

Unmounts the Button component, performing any necessary cleanup.

Updates the Button component state in response to messages or prop changes.

Types

t()

@type t() :: %{
  id: String.t(),
  label: String.t(),
  on_click: function() | nil,
  disabled: boolean(),
  focused: boolean(),
  pressed: boolean(),
  theme: map(),
  style: map(),
  width: integer() | nil,
  height: integer() | nil,
  shortcut: String.t() | nil,
  tooltip: String.t() | nil,
  role: :primary | :secondary | :danger | :success | nil
}

Functions

broadcast(msg)

command(cmd)

errors(button)

handle_event(event, button, context)

Handles input events for the button component.

Parameters

  • event - The input event to handle
  • button - The button component state
  • context - 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.

init(state)

Initializes the Button component state from the given props.

mount(state)

Mounts the Button component. Performs any setup needed after initialization.

new(attrs)

Creates a new Button state map, applying defaults. Expects opts to be a Map.

render(button, context)

Renders the button component based on its current state.

Parameters

  • button - The button component to render
  • context - The rendering context

Returns

A rendered view representation of the button.

schedule(msg, delay)

unmount(state)

Unmounts the Button component, performing any necessary cleanup.

update(message, state)

Updates the Button component state in response to messages or prop changes.