IconButton

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

Description

Use IconButton to render Icon-only buttons without the default button styles.

IconButton will always render with a tooltip unless the tag is :summary.

Accessibility

IconButton requires an aria-label, which will provide assistive technologies with an accessible label. The aria-label should describe the action to be invoked rather than the icon itself. For instance, if your IconButton renders a magnifying glass icon and invokes a search action, the aria-label should be "Search" instead of "Magnifying glass". Either aria-label or aria-description will be used for the Tooltip text, depending on which one is present. Either aria-label or aria-description will be used for the Tooltip text, depending on which one is present. Learn more about best functional image practices (WAI Images)

Additional markup is required if setting the tag argument to either :a or :summary.

  • :a requires you to pass in an href attribute
  • :summary requires you to wrap the component in a <details> element

Arguments

NameRequiredDescription
icon
String

Name of Octicons to use.

tag
Symbol

One of :a, :button, :clipboard-copy, or :summary.

scheme
Symbol

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

size
Symbol

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

disabled
Boolean

Whether or not the button is disabled. If true, this option forces tag: to :button.

type
Symbol

One of :button, :reset, or :submit.

aria-label
String

String that can be read by assistive technology. A label should be short and concise. See the accessibility section for more information.

aria-description
String

String that can be read by assistive technology. A description can be longer as it is intended to provide more context and information. See the accessibility section for more information.

show_tooltip
Boolean

Whether or not to show a tooltip when this button is hovered. Tooltips should only be hidden if the aria label is redundant, i.e. if the icon has a widely understood definition.

tooltip_direction
Symbol

One of :e, :n, :ne, :nw, :s, :se, :sw, or :w.

system_arguments