WarUI documentation

Icon-only button

stable

Use an explicit label when the button has only an icon.

Live example

Example controls

Expected behavior

The visible icon takes up little space and assistive technology announces the supplied label.

Source

<war-button icon-only label="Settings"><span aria-hidden="true">⚙</span></war-button>

API reference

war-button manifest
KindNameTypeDescription
Propertyvariant'primary' | 'secondary' | 'tertiary' | 'danger' | 'ghost' | 'link'—
Propertysize'sm' | 'md' | 'lg'—
PropertyfullWidthboolean—
PropertyiconOnlyboolean—
Propertylabelstring—
Propertyloadingboolean—
Propertydisabledboolean—
PropertysoftDisabledboolean—
Propertyhrefstring | undefined—
Propertytargetstring | undefined—
Propertyrelstring | undefined—
Propertydownloadstring | undefined—
Propertytype'button' | 'submit' | 'reset'—
Propertynamestring—
Propertyvaluestring—
PropertyformHTMLFormElement | null—
Attributevariant'primary' | 'secondary' | 'tertiary' | 'danger' | 'ghost' | 'link'Visual emphasis.
Attributesize'sm' | 'md' | 'lg'Size of the control.
Attributefull-widthbooleanFill the available inline space.
Attributeicon-onlybooleanDisplay the default slot as an icon.
AttributelabelstringExplicit accessible name.
AttributeloadingbooleanPending state blocks activation.
AttributedisabledbooleanRemove from the tab order and block activation.
Attributesoft-disabledbooleanRemain focusable but block activation.
Attributehrefstring | undefinedRender a link instead of a button.
Attributetargetstring | undefinedLink target context.
Attributerelstring | undefinedLink relationship.
Attributedownloadstring | undefinedSuggested download name.
Attributetype'button' | 'submit' | 'reset'Native form action.
AttributeformstringID of the associated form.
AttributenamestringSubmitter name.
AttributevaluestringSubmitter value.
Eventwar-clickCustomEvent<{type:string}>Cancelable event before activation.
Slot(default)—Visible label or icon.
Slotstart—Leading content.
Slotend—Trailing content.
CSS partbase—Native control.
CSS partlabel—Label wrapper.
CSS partstart—Leading content wrapper.
CSS partend—Trailing content wrapper.
CSS partspinner—Loading indicator.
CSS property--war-button-background—Custom background.
CSS property--war-button-foreground—Custom foreground.
CSS property--war-button-border—Custom border color.