Toolbar

Toolbar

Action toolbar with grouped buttons and keyboard navigation.

Based on APG Toolbar Pattern.

Demo

Usage

@styled_toolbar.toolbar(
  "formatting",
  [
    @styled_toolbar.ToolbarGroup([
      @styled_toolbar.toolbar_item_config("bold", "B", pressed=true),
      @styled_toolbar.toolbar_item_config("italic", "I"),
      @styled_toolbar.toolbar_item_config("underline", "U"),
    ]),
    @styled_toolbar.ToolbarGroup([
      @styled_toolbar.toolbar_item_config("left", "L"),
      @styled_toolbar.toolbar_item_config("center", "C"),
      @styled_toolbar.toolbar_item_config("right", "R"),
    ]),
  ],
  aria_label="Text formatting",
  on_item_click=fn(id) { println("Clicked: " + id) },
)

Props

PropTypeDefaultDescription
idString-Toolbar ID
groupsArray[ToolbarGroup]-Button groups
aria_labelString"Toolbar"Accessible label
classString?NoneAdditional CSS class
onitemclick(String) -> Unit-Click handler

BEM Classes

ClassDescription
.toolbarRoot container
.toolbar__innerInner wrapper with border
.toolbar__groupButton group
.toolbar__itemIndividual button
.toolbar__separatorGroup separator

States

StateDescription
data-pressedToggle button pressed
data-selectedSelected item
data-disabledDisabled item

Keyboard

KeyAction
Arrow LeftPrevious button
Arrow RightNext button
HomeFirst button
EndLast button