m3e/button

button provides Lustre support for the M3E Button component

Types

Button holds all the values necessary to construct am M3E Button

Fields:

  • disabled: Whether the element is disabled or enabled
  • disabled_interactive: Whether the element is disabled and interactive
  • form_submission: handles this button’s role in form submission
  • icons: Renders an icon before the button’s label, Renders an icon after the button’s label, Renders an icon before the button’s label, when selected
  • label: Renders the label of the button
  • link: Make the button behave like a link
  • selected: Whether the toggle button is selected
  • selected_label: Renders the label of the button, when selected
  • shape: The shape of the button
  • size: The size of the button
  • toggle: Whether the button will toggle between selected and unselected states
  • variant: The appearance variant of the button
pub opaque type Button(msg)

Config allows for a declarative configuration of the Button

pub type Config(msg) {
  Config(
    disabled: types.Interaction,
    disabled_interactive: types.Interaction,
    form_submission: option.Option(form_submission.FormSubmission),
    icons: List(element.Element(msg)),
    label: String,
    link: option.Option(link.Link),
    selected: types.SelectionState,
    selected_label: option.Option(String),
    shape: option.Option(Shape),
    size: option.Option(size_many.Size),
    toggle: Bool,
    variant: option.Option(Variant),
  )
}

Constructors

The visual shape of the button.

pub type Shape {
  Rounded
  Square
}

Constructors

  • Rounded
  • Square

Slot gives type-safe names to each of the defined HTML named slots

pub type Slot {
  Icon
  SelectedSlot
  SelectedIcon
  TrailingIcon
}

Constructors

  • Icon
  • SelectedSlot
  • SelectedIcon
  • TrailingIcon

The visual variant (style) of the button.

pub type Variant {
  Elevated
  Filled
  Outlined
  Text
  Tonal
}

Constructors

  • Elevated
  • Filled
  • Outlined
  • Text
  • Tonal

Values

pub fn default_config() -> Config(msg)

default_config returns a default Config

pub const default_shape: Shape

Default shape

pub const default_variant: Variant

Default variant

pub fn disabled(
  b: Button(msg),
  disabled: types.Interaction,
) -> Button(msg)

disabled sets the disabled field

pub fn disabled_interactive(
  b: Button(msg),
  disabled: types.Interaction,
) -> Button(msg)

disabled_interactive sets the disabled_interactive field

pub fn form(
  b: Button(msg),
  fs: option.Option(form_submission.FormSubmission),
) -> Button(msg)

form_submission sets up a Button to participate in an HTML form

Parameters:

  • b: a Button
  • fs: a FormSubmission
pub fn from_config(c: Config(msg)) -> Button(msg)

from_config creates a Button from a Config

pub fn icons(
  b: Button(msg),
  icons: List(element.Element(msg)),
) -> Button(msg)

icons sets the icons field

pub fn label(b: Button(msg), label: String) -> Button(msg)

label sets the label field

pub fn link(
  b: Button(msg),
  link: option.Option(link.Link),
) -> Button(msg)

link sets the link field

pub fn new(label: String, variant: Variant) -> Button(msg)

new creates a new Button

Parameters:

  • label: the text on the button
  • variant: the button variety
pub fn render(
  b: Button(msg),
  attributes: List(attribute.Attribute(msg)),
) -> element.Element(msg)

render creates a Lustre Element from a Button

Parameters:

  • b: a Button
  • attributes: a list of additional Attributes
pub fn render_config(
  c: Config(msg),
  attributes: List(attribute.Attribute(msg)),
) -> element.Element(msg)

render_config creates a Lustre Element from a Config

pub fn selected(
  b: Button(msg),
  s: types.SelectionState,
) -> Button(msg)

selected sets theselected field of a Button

pub fn selected_label(b: Button(msg), lab: String) -> Button(msg)

selected_label sets theselected_label field of a Button

pub fn shape(b: Button(msg), s: Shape) -> Button(msg)

shape sets theshape field of a Button

pub fn size(b: Button(msg), s: size_many.Size) -> Button(msg)

size sets thesize field of a Button

pub fn slot(s: Slot) -> attribute.Attribute(msg)

slot creates a Lustre ‘slot’ Attribute(msg) for a Slot

pub fn toggle(b: Button(msg), t: Bool) -> Button(msg)

toggle sets thetoggle field of a Button

pub fn variant(b: Button(msg), v: Variant) -> Button(msg)

variant sets thevariant field of a Button

Search Document