howdy/ui/button
Buttons, and the theme toggle built on them.
Types
How big a button is.
pub type Size {
ExtraSmall
Small
Medium
Large
Icon
IconExtraSmall
IconSmall
IconLarge
}
Constructors
-
ExtraSmall -
Small -
Medium -
Large -
IconA square button for a single icon, as tall as a medium button. Give it an
aria-label. -
IconExtraSmallA square icon button as tall as an extra-small one.
-
IconSmallA square icon button as tall as a small one.
-
IconLargeA square icon button as tall as a large one.
How prominent a button is.
pub type Variant {
Primary
Secondary
Outline
Ghost
Link
Danger
}
Constructors
-
PrimaryThe main action: filled with the primary colour.
-
SecondaryA supporting action: filled with the muted colour.
-
OutlineA supporting action: outlined.
-
GhostA quiet action, such as one in a toolbar: filled only when hovered.
-
LinkAn action that looks like a link.
-
DangerA destructive action: filled with the danger colour.
Values
pub fn button(
variant: Variant,
attributes: List(attribute.Attribute(msg)),
children: List(element.Element(msg)),
) -> element.Element(msg)
A medium button.
pub fn button_class(variant: Variant) -> css.Class
The class of a medium button, for styling your own markup, such as a link, as a button.
pub fn sized(
variant: Variant,
size: Size,
attributes: List(attribute.Attribute(msg)),
children: List(element.Element(msg)),
) -> element.Element(msg)
A button of the given size.
These buttons do not submit a form; use submit for one that does.
Passing attribute.type_("submit") instead would give the button two
types, which a page and a live view resolve differently.
pub fn sized_submit(
variant: Variant,
size: Size,
attributes: List(attribute.Attribute(msg)),
children: List(element.Element(msg)),
) -> element.Element(msg)
A button of the given size that submits its form.
pub fn submit(
variant: Variant,
attributes: List(attribute.Attribute(msg)),
children: List(element.Element(msg)),
) -> element.Element(msg)
A medium button that submits its form.
pub fn theme_toggle(
children: List(element.Element(msg)),
from a: String,
to b: String,
) -> element.Element(msg)
A button that switches the document between two named themes and
remembers the choice in a theme cookie, which the page can read back
with howdy/cookie. Works in server-rendered pages and live views. The
switch is made by howdy/ui/behaviour, and the theme names stay in
HTML-escaped data attributes, never executable code.