Button theming and density
stable
Set a theme and density on any container to scope tokens.
Live example
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><div data-war-theme="dark" data-war-density="compact">
<WarButton>Save changes</WarButton>
</div><div data-war-theme="dark" data-war-density="compact">
<war-button-angular>Save changes</war-button-angular>
</div><div data-war-theme="dark" data-war-density="compact">
<WarButton>Save changes</WarButton>
</div><div data-war-theme="dark" data-war-density="compact">
<WarButton>Save changes</WarButton>
</div>API reference
| Kind | Name | Type | Description |
|---|---|---|---|
| Property | variant | 'primary' | 'secondary' | 'tertiary' | 'danger' | 'ghost' | 'link' | — |
| Property | size | 'sm' | 'md' | 'lg' | — |
| Property | fullWidth | boolean | — |
| Property | iconOnly | boolean | — |
| Property | label | string | — |
| Property | loading | boolean | — |
| Property | disabled | boolean | — |
| Property | softDisabled | boolean | — |
| Property | href | string | undefined | — |
| Property | target | string | undefined | — |
| Property | rel | string | undefined | — |
| Property | download | string | undefined | — |
| Property | type | 'button' | 'submit' | 'reset' | — |
| Property | name | string | — |
| Property | value | string | — |
| Property | form | HTMLFormElement | null | — |
| Attribute | variant | 'primary' | 'secondary' | 'tertiary' | 'danger' | 'ghost' | 'link' | Visual emphasis. |
| Attribute | size | 'sm' | 'md' | 'lg' | Size of the control. |
| Attribute | full-width | boolean | Fill the available inline space. |
| Attribute | icon-only | boolean | Display the default slot as an icon. |
| Attribute | label | string | Explicit accessible name. |
| Attribute | loading | boolean | Pending state blocks activation. |
| Attribute | disabled | boolean | Remove from the tab order and block activation. |
| Attribute | soft-disabled | boolean | Remain focusable but block activation. |
| Attribute | href | string | undefined | Render a link instead of a button. |
| Attribute | target | string | undefined | Link target context. |
| Attribute | rel | string | undefined | Link relationship. |
| Attribute | download | string | undefined | Suggested download name. |
| Attribute | type | 'button' | 'submit' | 'reset' | Native form action. |
| Attribute | form | string | ID of the associated form. |
| Attribute | name | string | Submitter name. |
| Attribute | value | string | Submitter value. |
| Event | war-click | CustomEvent<{type:string}> | Cancelable event before activation. |
| Slot | (default) | — | Visible label or icon. |
| Slot | start | — | Leading content. |
| Slot | end | — | Trailing content. |
| CSS part | base | — | Native control. |
| CSS part | label | — | Label wrapper. |
| CSS part | start | — | Leading content wrapper. |
| CSS part | end | — | Trailing content wrapper. |
| CSS part | spinner | — | Loading indicator. |
| CSS property | --war-button-background | — | Custom background. |
| CSS property | --war-button-foreground | — | Custom foreground. |
| CSS property | --war-button-border | — | Custom border color. |