Raxol.UI.Components.Input.Checkbox (Raxol v0.5.0)

View Source

Checkbox component for toggling boolean values.

This component provides a selectable checkbox with customizable appearance and behavior. Fully supports style and theme props (with correct merging/precedence), implements robust lifecycle hooks, and supports accessibility/extra props.

Summary

Functions

Initializes the Checkbox component state from the given props.

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

Creates a new checkbox component with the given options. See init/1 for details.

Renders the Checkbox component using the current state and context.

Unmounts the Checkbox component, performing any necessary cleanup.

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

Types

t()

@type t() :: %{
  id: String.t(),
  label: String.t(),
  checked: boolean(),
  on_toggle: function() | nil,
  disabled: boolean(),
  style: map(),
  theme: map(),
  tooltip: String.t() | nil,
  required: boolean(),
  aria_label: String.t() | nil,
  focused: boolean()
}

Functions

init(props)

@spec init(keyword()) :: {:ok, t()}

Initializes the Checkbox component state from the given props.

mount(state)

@spec mount(t()) :: {t(), list()}

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

new(opts \\ [])

@spec new(keyword()) :: t()

Creates a new checkbox component with the given options. See init/1 for details.

render(state, context)

@spec render(t(), map()) :: any()

Renders the Checkbox component using the current state and context.

unmount(state)

@spec unmount(t()) :: t()

Unmounts the Checkbox component, performing any necessary cleanup.

update(props, state)

@spec update(map(), t()) :: {:ok, t(), list()}
@spec update(term(), t()) :: {:ok, t(), list()}

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