class Primer::Alpha::SegmentedControl::Item

It wraps the Button and IconButton components to provide the correct styles
SegmentedControl::Item is a private component that is only used by SegmentedControl

def before_render

def before_render
  content
end

def initialize(

Parameters:
  • hide_labels (Symbol) -- Whether to only show the icon
  • icon (Symbol) -- The icon to use
  • selected (Boolean) -- Whether the item is selected
  • label (String) -- The label to use
def initialize(
  label:,
  selected: false,
  icon: nil,
  hide_labels: false,
  **system_arguments
)
  @selected = selected
  @system_arguments = system_arguments
  @system_arguments[:"data-action"] = "click:segmented-control#select" if system_arguments[:href].nil?
  @system_arguments[:"aria-current"] = selected
  @system_arguments[:scheme] = :invisible
  if hide_labels
    @button = Primer::Beta::IconButton.new(
      icon: icon,
      "aria-label": label,
      **@system_arguments
    )
  else
    @button = Primer::Beta::Button.new(**@system_arguments)
    @button.with_leading_visual_icon(icon: icon) if icon
    @button.with_content(label)
  end
end

def with_trailing_visual_label(**system_arguments, &block)

Parameters:
  • system_arguments (Hash) -- The arguments accepted by <%= link_to_component(Primer::Beta::Button) %>'s `with_trailing_visual_label` slot.
def with_trailing_visual_label(**system_arguments, &block)
  @button.with_trailing_visual_label(**system_arguments, &block)
end