Browse documentation

Button group

Keep related actions together without losing each button's own label and behavior.

Import

Load the optional component layer before using the examples below.

Ruby
require "zaniah/ui"

Example

Pass buttons as children. Use a group only when the actions are closely related.

Rendered example
Two adjacent action buttons in the Zaniah gallery.
Rendered by Zaniah's headless backend.
Ruby
Zaniah::UI::ButtonGroup.new(
  Zaniah::UI::Button.new("Day", size: :sm),
  Zaniah::UI::Button.new("Week", size: :sm)
)

API summary

Constructor options and behaviors are drawn from the component reference.

ComponentConstructor and methodsVariants or behavior
ButtonGroup(*buttons), childhorizontal

Accessibility

The group contains independently focusable buttons.

ComponentSemantic role
ButtonGroupgroup