class Primer::IconButton
[Learn more about best functional image practices (WAI Images)](www.w3.org/WAI/tutorials/images/functional)
‘“Search”` instead of `“Magnifying glass”`.
if your `IconButton` renders a magnifying glass icon and invokes a search action, the `aria-label` should be
The `aria-label` should describe the action to be invoked rather than the icon itself. For instance,
`IconButton` requires an `aria-label`, which will provide assistive technologies with an accessible label.
@accessibility
Use `IconButton` to render Icon-only buttons without the default button styles.
def call
def call render(Primer::BaseButton.new(**@system_arguments)) do render(Primer::OcticonComponent.new(icon: @icon)) end end
def initialize(icon:, scheme: DEFAULT_SCHEME, box: false, **system_arguments)
-
system_arguments(Hash) -- <%= link_to_system_arguments_docs %> -
box(Boolean) -- Whether the button is in a <%= link_to_component(Primer::BorderBoxComponent) %>. If `true`, the button will have the `Box-btn-octicon` class. -
type(Symbol) -- <%= one_of(Primer::BaseButton::TYPE_OPTIONS) %> -
tag(Symbol) -- <%= one_of(Primer::BaseButton::TAG_OPTIONS) %> -
icon(String) -- Name of <%= link_to_octicons %> to use. -
scheme(Symbol) -- <%= one_of(Primer::IconButton::SCHEME_OPTIONS) %>
Other tags:
- Example: In a BorderBox -
Example: Schemes -
Example: Default -
def initialize(icon:, scheme: DEFAULT_SCHEME, box: false, **system_arguments) @icon = icon @system_arguments = system_arguments @system_arguments[:classes] = class_names( "btn-octicon", SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_OPTIONS, scheme, DEFAULT_SCHEME)], system_arguments[:classes], "Box-btn-octicon" => box ) validate_aria_label end