howdy/ui/accordion

Accordions and collapsibles: sections that open and close.

accordion.accordion([], [
  accordion.item("faq", open: True, summary: [text("Is it accessible?")], content: [
    text("Yes. Each section is a native details element."),
  ]),
  accordion.item("faq", open: False, summary: [text("Is it styled?")], content: [
    text("Yes, from the theme."),
  ]),
])

Each section is a <details> element, so it works without scripts and the browser’s find-in-page opens the section it matches. Items that share a group name are exclusive: opening one closes the others. Give each item its own name, or "", to let several stay open. A live view hears a section open or close with event.on("toggle", ...).

Values

pub fn accordion(
  attributes: List(attribute.Attribute(msg)),
  children: List(element.Element(msg)),
) -> element.Element(msg)

A list of items with a line between each.

pub fn accordion_class() -> css.Class
pub fn classes() -> List(css.Class)

Every class this module uses, for howdy/ui/export.

pub fn collapsible(
  attributes: List(attribute.Attribute(msg)),
  open open: Bool,
  summary summary: List(element.Element(msg)),
  content content: List(element.Element(msg)),
) -> element.Element(msg)

A single section that opens and closes, without the accordion’s lines.

pub fn collapsible_class() -> css.Class
pub fn content_class() -> css.Class
pub fn item(
  group: String,
  open open: Bool,
  summary summary: List(element.Element(msg)),
  content content: List(element.Element(msg)),
) -> element.Element(msg)

One section of an accordion.

pub fn item_class() -> css.Class
✨ Search Document