ButtonGroup

readyNot reviewed for a11y
This page may be removed. Primer plans to move all Rails component documentation to Lookbook.

Description

Use ButtonGroup to render a series of buttons.

Arguments

NameRequiredDescription
scheme
Symbol

DEPRECATED. One of :danger, :default, :invisible, :link, :primary, or :secondary.

size
Symbol

One of :large, :medium, or :small.

system_arguments

Slots

buttons

List of buttons to be rendered. Add buttons via the #with_button, #with_menu_button, and #with_clipboard_copy_button methods (see below).

Methods

with_button(icon: Symbol, system_arguments: Hash)

Adds a button.

Parameters

NameRequiredDescription
icon
Symbol

If included, adds a Primer::Beta::IconButton with the given Octicons. Otherwise, a Primer::Beta::Button is added instead.

system_arguments
Hash

The arguments accepted by Primer::Beta::Button or Primer::Beta::IconButton, depending on the value of the icon: argument.

with_menu_button(system_arguments: Hash)

Adds a button that activates a menu when clicked.

Parameters

NameRequiredDescription
system_arguments
Hash

The arguments accepted by Primer::Beta::ButtonGroup::MenuButton.

with_clipboard_copy_button(system_arguments: Hash)

Adds a Primer::Beta::ClipboardCopyButton.

Parameters

NameRequiredDescription
system_arguments
Hash

The arguments accepted by Primer::Beta::ClipboardCopyButton.

ButtonGroup::MenuButton

Renders a button in a Primer::Beta::ButtonGroup that displays an Primer::Alpha::ActionMenu when clicked. This component should not be used outside of a ButtonGroup context.

This component yields both the button and the list to the block when rendered.

<%= render(Primer::Beta::ButtonGroup.new) do |group| %>
  <% group.with_menu_button do |menu, button| %>
    <% menu.with_item(label: "Item 1") %>
    <% button.with_trailing_visual_icon(icon: "triangle-down") %>
  <% end %>
<% end %>

Arguments

NameRequiredDescription
menu_arguments
Hash

The arguments accepted by Primer::Alpha::ActionMenu.

button_arguments
Hash

The arguments accepted by Primer::Beta::Button or Primer::Beta::IconButton, depending on the value of the icon: argument.