WarUI documentation

Button theming and density

stable

Set a theme and density on any container to scope tokens.

Live example

Example controls

Expected behavior

The button uses the scoped colors and spacing independently of the portal settings.

Source

<div data-war-theme="dark" data-war-density="compact">
  <war-button>Save changes</war-button>
</div>

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.