lustre/prefab/link

Link component for lustre_prefab.

A hyperlink styled as a button.

Types

Opaque Link type with builder pattern

pub opaque type Link(msg)

Link size

pub type Size {
  Normal
  Small
  Large
}

Constructors

  • Normal
  • Small
  • Large

Link color style

pub type Style {
  Primary
  Secondary
  Success
  Danger
  Warning
  Info
}

Constructors

  • Primary
  • Secondary
  • Success
  • Danger
  • Warning
  • Info

Link style variant

pub type Variant {
  Solid
  Outline
  Flat
}

Constructors

  • Solid
  • Outline
  • Flat

Values

pub fn new(label: String, path: String) -> Link(msg)

Create a new link styled as a button

Example

link.new("Home", "/")
|> link.with_style(link.Primary)
|> link.view([])
pub fn view(
  link_element: Link(msg),
  extra_attrs: List(@internal Attribute(@internal Aligned, msg)),
) -> stylish.Element(msg)

Render the link

Example

link.new("Go to Settings", "/settings")
  |> link.with_style(link.Primary)
  |> link.view([])
pub fn with_label_hidden(link_element: Link(msg)) -> Link(msg)

Hide the label of the link (useful with icons)

pub fn with_size(
  link_element: Link(msg),
  size: Size,
) -> Link(msg)

Modify the size of the link

pub fn with_style(
  link_element: Link(msg),
  style: Style,
) -> Link(msg)

Modify the style of the link

pub fn with_variant(
  link_element: Link(msg),
  variant: Variant,
) -> Link(msg)

Modify the variant of the link

pub fn without_caps(link_element: Link(msg)) -> Link(msg)

Remove all caps from the link

Search Document