lustre/prefab/button
Button component for lustre_prefab.
Modeled after the Clarity Design System’s button component. See: https://clarity.design/documentation/button
Types
Button size options
pub type Size {
Normal
Small
Large
Block
}
Constructors
-
Normal -
Small -
Large -
Block
Button style options (color scheme)
pub type Style {
Primary
Secondary
Success
Danger
Warning
Info
}
Constructors
-
Primary -
Secondary -
Success -
Danger -
Warning -
Info
Values
pub fn new(
label: String,
on_click: option.Option(msg),
) -> Button(msg)
Create a new button with a label and optional onClick message
Example
button.new("Submit", Some(Submit))
|> button.with_style(button.Primary)
|> button.view([])
pub fn view(
btn: Button(msg),
extra_attrs: List(@internal Attribute(@internal Aligned, msg)),
) -> stylish.Element(msg)
Render the button
Example
button.new("Click me", Some(ButtonClicked))
|> button.with_style(button.Primary)
|> button.view([])
pub fn with_label_hidden(btn: Button(msg)) -> Button(msg)
Hide the button label (useful for icon-only buttons)
pub fn with_style(btn: Button(msg), style: Style) -> Button(msg)
Set the button style (color scheme)
pub fn with_variant(
btn: Button(msg),
variant: Variant,
) -> Button(msg)
Set the button variant (visual style)