Raxol.View.Components (Raxol v0.4.0)

View Source

Provides component functions for Raxol views.

This module contains functions for creating various UI components that can be used in Raxol views.

Summary

Functions

Creates a button component with options for label, click action, style, and disabled state.

Creates a label component with options for text, width, and style.

Creates a space component with options for width and height.

Creates a text component with options for content, style, foreground, and background colors.

Creates a text input component with options for value, placeholder, change action, and style.

Functions

button(label, opts \\ [])

Creates a button component with options for label, click action, style, and disabled state.

Options

  • :label - The button text
  • :on_click - Function to call when clicked
  • :style - Style options for the button
  • :disabled - Whether the button is disabled

Example

button("Submit", on_click: &handle_submit/0, style: [bg: :blue])

label(text, opts \\ [])

Creates a label component with options for text, width, and style.

Options

  • :width - Width of the label in characters
  • :style - Style options for the label
  • :align - Text alignment (:left, :center, :right)

Example

label("Username:", width: 10)
label("Password:", width: 10, align: :right)

space(opts \\ [])

Creates a space component with options for width and height.

Options

  • :width - Width of the space in characters
  • :height - Height of the space in lines
  • :style - Style options for the space

Example

space(width: 2)
space(width: 1, height: 2)

text(content, opts \\ [])

Creates a text component with options for content, style, foreground, and background colors.

Options

  • :content - The text content to display
  • :style - Style options for the text (font, size, etc.)
  • :fg - Foreground color
  • :bg - Background color

Example

text("Hello World", style: [bold: true], fg: :blue)

text_input(opts \\ [])

Creates a text input component with options for value, placeholder, change action, and style.

Options

  • :value - Current input value
  • :placeholder - Placeholder text
  • :on_change - Function to call when value changes
  • :style - Style options for the input

Example

text_input(value: name, placeholder: "Enter your name", on_change: &handle_name_change/1)