lustre/stylish/input

Form input elements for lustre_stylish

This module provides form input elements matching elm-ui’s Element.Input API.

All input elements have required labels for accessibility.

Types

Configuration for a button

pub type ButtonConfig(msg) {
  ButtonConfig(
    on_press: option.Option(msg),
    label: stylish.Element(msg),
  )
}

Constructors

Configuration for a checkbox input

pub type CheckboxConfig(msg) {
  CheckboxConfig(
    on_change: fn(Bool) -> msg,
    icon: fn(Bool) -> stylish.Element(msg),
    checked: Bool,
    label: Label(msg),
  )
}

Constructors

  • CheckboxConfig(
      on_change: fn(Bool) -> msg,
      icon: fn(Bool) -> stylish.Element(msg),
      checked: Bool,
      label: Label(msg),
    )

A label for an input. Labels are required for accessibility.

pub opaque type Label(msg)

Configuration for a multiline text input

pub type MultilineConfig(msg) {
  MultilineConfig(
    on_change: fn(String) -> msg,
    text: String,
    placeholder: option.Option(Placeholder(msg)),
    label: Label(msg),
    spellcheck: Bool,
  )
}

Constructors

  • MultilineConfig(
      on_change: fn(String) -> msg,
      text: String,
      placeholder: option.Option(Placeholder(msg)),
      label: Label(msg),
      spellcheck: Bool,
    )

The state of a radio option

pub type OptionState {
  Idle
  Focused
  Selected
}

Constructors

  • Idle
  • Focused
  • Selected

Configuration for a password input

pub type PasswordConfig(msg) {
  PasswordConfig(
    on_change: fn(String) -> msg,
    text: String,
    placeholder: option.Option(Placeholder(msg)),
    label: Label(msg),
    show: Bool,
  )
}

Constructors

Placeholder text for an input

pub opaque type Placeholder(msg)

Configuration for a radio button group

pub type RadioConfig(msg, value) {
  RadioConfig(
    on_change: fn(value) -> msg,
    options: List(RadioOption(value, msg)),
    selected: option.Option(value),
    label: Label(msg),
  )
}

Constructors

A radio option

pub opaque type RadioOption(value, msg)

Configuration for a slider input

pub type SliderConfig(msg) {
  SliderConfig(
    on_change: fn(Float) -> msg,
    label: Label(msg),
    min: Float,
    max: Float,
    value: Float,
    thumb: Thumb(msg),
    step: option.Option(Float),
  )
}

Constructors

  • SliderConfig(
      on_change: fn(Float) -> msg,
      label: Label(msg),
      min: Float,
      max: Float,
      value: Float,
      thumb: Thumb(msg),
      step: option.Option(Float),
    )

Configuration for a text input

pub type TextConfig(msg) {
  TextConfig(
    on_change: fn(String) -> msg,
    text: String,
    placeholder: option.Option(Placeholder(msg)),
    label: Label(msg),
  )
}

Constructors

The draggable thumb of a slider

pub opaque type Thumb(msg)

Values

pub fn button(
  attributes: List(@internal Attribute(@internal Aligned, msg)),
  config: ButtonConfig(msg),
) -> stylish.Element(msg)

A button with optional onClick behavior.

The button will trigger on click. (TODO: Add Enter and Space key support)

pub fn checkbox(
  attributes: List(@internal Attribute(@internal Aligned, msg)),
  config: CheckboxConfig(msg),
) -> stylish.Element(msg)

A checkbox input.

pub fn current_password(
  attributes: List(@internal Attribute(@internal Aligned, msg)),
  config: PasswordConfig(msg),
) -> stylish.Element(msg)

A current password input (helps browser autofill).

pub fn default_checkbox(checked: Bool) -> stylish.Element(msg)

The default checkbox icon (blue with checkmark when checked)

pub fn default_thumb() -> Thumb(msg)

The default slider thumb (small circle)

pub fn email(
  attributes: List(@internal Attribute(@internal Aligned, msg)),
  config: TextConfig(msg),
) -> stylish.Element(msg)

An email input (helps browser autofill and validation).

pub fn focused_on_load() -> @internal Attribute(
  @internal Aligned,
  msg,
)

Mark an input to be focused when the page loads

pub fn label_above(
  attributes: List(@internal Attribute(@internal Aligned, msg)),
  content: stylish.Element(msg),
) -> Label(msg)

Create a label positioned above the input

pub fn label_below(
  attributes: List(@internal Attribute(@internal Aligned, msg)),
  content: stylish.Element(msg),
) -> Label(msg)

Create a label positioned below the input

pub fn label_hidden(text: String) -> Label(msg)

Create a hidden label (for accessibility only).

pub fn label_left(
  attributes: List(@internal Attribute(@internal Aligned, msg)),
  content: stylish.Element(msg),
) -> Label(msg)

Create a label positioned to the left of the input

pub fn label_right(
  attributes: List(@internal Attribute(@internal Aligned, msg)),
  content: stylish.Element(msg),
) -> Label(msg)

Create a label positioned to the right of the input

pub fn multiline(
  attributes: List(@internal Attribute(@internal Aligned, msg)),
  config: MultilineConfig(msg),
) -> stylish.Element(msg)

A multiline text input (textarea).

pub fn new_password(
  attributes: List(@internal Attribute(@internal Aligned, msg)),
  config: PasswordConfig(msg),
) -> stylish.Element(msg)

A new password input (helps browser autofill).

pub fn option(
  value: value,
  label: stylish.Element(msg),
) -> RadioOption(value, msg)

Create a radio option with default styling

pub fn option_with(
  value: value,
  view: fn(OptionState) -> stylish.Element(msg),
) -> RadioOption(value, msg)

Create a radio option with custom state rendering

pub fn placeholder(
  attributes: List(@internal Attribute(@internal Aligned, msg)),
  content: stylish.Element(msg),
) -> Placeholder(msg)

Create placeholder text for an input

pub fn radio(
  attributes: List(@internal Attribute(@internal Aligned, msg)),
  config: RadioConfig(msg, value),
) -> stylish.Element(msg)

A radio button group (vertical layout).

pub fn radio_row(
  attributes: List(@internal Attribute(@internal Aligned, msg)),
  config: RadioConfig(msg, value),
) -> stylish.Element(msg)

A radio button group (horizontal layout).

pub fn search(
  attributes: List(@internal Attribute(@internal Aligned, msg)),
  config: TextConfig(msg),
) -> stylish.Element(msg)

A search input (provides browser hints for search).

pub fn slider(
  attributes: List(@internal Attribute(@internal Aligned, msg)),
  config: SliderConfig(msg),
) -> stylish.Element(msg)

A slider for selecting numeric values.

pub fn spell_checked(
  attributes: List(@internal Attribute(@internal Aligned, msg)),
  config: TextConfig(msg),
) -> stylish.Element(msg)

A text input with spell checking enabled.

pub fn text_input(
  attributes: List(@internal Attribute(@internal Aligned, msg)),
  config: TextConfig(msg),
) -> stylish.Element(msg)

A basic text input.

pub fn thumb(
  attributes: List(@internal Attribute(@internal Aligned, msg)),
) -> Thumb(msg)

Create a custom slider thumb

pub fn username(
  attributes: List(@internal Attribute(@internal Aligned, msg)),
  config: TextConfig(msg),
) -> stylish.Element(msg)

A username input (helps browser autofill).

Search Document