gbr/ui/admin/button

⚉ Gleam UI button super element.

Supose button text and svg at left side:

import gbr/ui/button

import gbr/ui/svg
import gbr/ui/svg/icons

import gbr/ui/core/model.{type UIRender, uilabel}

fn render(id: String) -> UIRender(a) {
  label = uilabel("Button w/ icon back!", [])
  let inner = [
    svg.new("id-svg", 20, 20)
      |> icons.back()
      |> svg.render()
    ]
  ]
  button.new(id)
    |> button.label(label)
    |> button.at_left(inner)
    |> button.on_click(onclick)
    |> button.render()
}

Roadmap

🚧 Work in progress

Types

Button super element.

pub opaque type UIButton

Button render type.

pub type UIButtonRender(a) {
  UIButtonRender(
    in: UIButton,
    inner: List(element.Element(a)),
    onclick: option.Option(a),
  )
}

Constructors

Values

pub fn app_nav(
  id: String,
  open: Bool,
  onclick: option.Option(a),
) -> element.Element(a)

Render app nav mobile toggle button.

pub fn at(in: UIButton) -> UIButtonRender(a)

New button render at default.

pub fn at_left(
  in: UIButton,
  inner: List(element.Element(a)),
) -> UIButtonRender(a)

New button render at left inner and onclick event.

pub fn at_right(
  in: UIButton,
  inner: List(element.Element(a)),
) -> UIButtonRender(a)

New button render at right inner and onclick event.

pub fn back(
  id: String,
  text: String,
  onclick: a,
) -> element.Element(a)

Render back history button.

pub fn class(in: UIButton, class: String) -> UIButton

Set button class.

pub fn classes(
  in: UIButton,
  classes: List(#(String, Bool)),
) -> UIButton

Set button classes.

pub fn dark_mode(
  id: String,
  onclick: option.Option(a),
) -> element.Element(a)

Render dark mode toggle button.

pub fn disabled(in: UIButton, disabled: Bool) -> UIButton

Set button disabled.

pub fn label(in: UIButton, text: String) -> UIButton

Set button label.

pub fn new(id: String) -> UIButton

New button super element.

pub fn on_click(
  in: UIButtonRender(a),
  onclick: a,
) -> UIButtonRender(a)
pub fn on_click_opt(
  in: UIButtonRender(a),
  onclick: option.Option(a),
) -> UIButtonRender(a)

Set button render onclick event.

pub fn primary(in: UIButton) -> UIButton

Set button disabled.

pub fn render(at: UIButtonRender(a)) -> element.Element(a)

Render button super element to lustre/element.{type Element}.

pub fn sidebar(
  id: String,
  open: Bool,
  onclick: option.Option(a),
) -> element.Element(a)

Render sidebar toggle button.

Search Document