class Primer::Alpha::SegmentedControl

See the [Accessibility section](primer.style/design/components/segmented-control#accessibility) of the SegmentedControl interface guidelines for more details.
A ‘SegmentedControl` should not be used in a form as a replacement for something like a radio group or select.
@accessibility
Use a segmented control to let users select an option from a short list and immediately apply the selection

def initialize(hide_labels: HIDE_LABELS_DEFAULT, full_width: FULL_WIDTH_DEFAULT, size: Primer::Beta::Button::DEFAULT_SIZE, **system_arguments)

Parameters:
  • system_arguments (Hash) -- <%= link_to_system_arguments_docs %>
  • size (Symbol) -- <%= one_of(Primer::Beta::Button::SIZE_OPTIONS) %>
  • full_width (Boolean) -- If the component should be full width
  • hide_labels (Boolean) -- Whether to hide the labels and only show the icons
def initialize(hide_labels: HIDE_LABELS_DEFAULT, full_width: FULL_WIDTH_DEFAULT, size: Primer::Beta::Button::DEFAULT_SIZE, **system_arguments)
  @full_width = full_width
  @size = size
  @hide_labels = hide_labels
  @system_arguments = system_arguments
  @system_arguments[:tag] = :ul
  @system_arguments[:role] = "list"
  @system_arguments[:classes] = class_names(
    system_arguments[:classes],
    SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE)],
    "SegmentedControl",
    "SegmentedControl--iconOnly": hide_labels,
    "SegmentedControl--fullWidth": full_width
  )
  validate_aria_label
end

def render?

def render?
  valid_items_count = items.count <= (@hide_labels ? 6 : 5) && items.count >= 2
  raise ArgumentError, "A segmented control should have 2–5 choices with text labels, or up to 6 icon-only buttons." if !valid_items_count && !Rails.env.production?
  valid_items_count
end