lustre/prefab/radio
Radio component for lustre_prefab.
A radio button group with multiple layout options.
Types
The arrangement of the radio buttons.
pub type Layout {
Vertical
VerticalInline
Horizontal
HorizontalInline
Compact
}
Constructors
-
Vertical -
VerticalInline -
Horizontal -
HorizontalInline -
Compact
Values
pub fn new(
label label: String,
on_change on_change: fn(value) -> msg,
selected selected: option.Option(value),
) -> Radio(value, msg)
Create a new radio button group.
Example
radio.new(
label: "Choose option",
on_change: fn(val) { SelectOption(val) },
selected: Some(model.selected),
)
|> radio.with_options([Option1, Option2, Option3])
|> radio.with_serializer(option_to_string)
|> radio.view([])
pub fn view(
radio: Radio(value, msg),
extra_attrs: List(@internal Attribute(@internal Aligned, msg)),
) -> stylish.Element(msg)
View the radio button group.
Example
radio.new(
label: "Select size",
on_change: UpdateSize,
selected: Some(model.size),
)
|> radio.with_options([Small, Medium, Large])
|> radio.with_serializer(size_to_string)
|> radio.with_layout(radio.Horizontal)
|> radio.view([])
pub fn with_layout(
radio: Radio(value, msg),
layout: Layout,
) -> Radio(value, msg)
Change the arrangement of the radio buttons.
pub fn with_message(
radio: Radio(value, msg),
message: String,
) -> Radio(value, msg)
Add a help message to the radio buttons.
pub fn with_options(
radio: Radio(value, msg),
options: List(value),
) -> Radio(value, msg)
Change the options of the radio buttons.