`<pacem-button>` is the button: you click it, tap it, or hit space or enter on it, and it does something.
It can carry an icon, ask for confirmation first, and turn a click into a named *command* for somebody else to handle.
```html
<pacem-button class="button fill-primary" icon-glyph="send"
on-click="#sent.model = true">Send</pacem-button>
<pacem-button class="button" command-name="remove"
command-argument="{{ item.id }}">Remove</pacem-button>
```
## Usage
**Click it.** `click` fires for the mouse, for touch, and for the **spacebar** and the **enter** key on a focused button
(the button is focusable by default: `tab-order` is `0`). While `disabled` is on, nothing fires.
**Give it a look.** The `button` class makes it a button; a `fill-*` utility colors it (`fill-primary`, `fill-danger`,
`fill-accent-container`...), and `fill-interactive` makes the color answer to hover and press.
`flat` takes the fill away, `button-circular` makes an icon-only round one.
```html
<pacem-button class="button fill-danger fill-interactive">Delete</pacem-button>
<pacem-button class="button flat">Cancel</pacem-button>
<pacem-button class="button-circular circle-small"
icon-glyph="close"></pacem-button>
```
**Add an icon.** `icon-glyph` is a *ligature* of the icon font (`send`, `edit`, `thumb_up`...) drawn before the content;
`icon-url` points to an image instead.
> The old color classes (`button-primary`, `button-danger`...) still work: they are aliases of the `fill-*` utilities.
**Line them up.** Buttons that belong together go in a `pacem-buttonset buttons`: the corners are squared between neighbors.
**Ask first.** Point `confirmation-dialog` to a `<pacem-dialog>` and set `confirmation-message`: the click is processed
only if the user answers *yes*.
**Name the click.** With `command-name` (and a `command-argument`, any JSON) the click also fires `command`.
It *bubbles*: a `pacem-event-proxy` on an ancestor can listen once for all the buttons below it (inside a repeater, the repeater itself turns commands into `item*` events).
## Customization
Every button of the page changes with **one token**. The hover and press colors derive from it, and the ink stays readable.
```css
:root {
--pacem-color-button: #1d6f5f;
}
```
Roundness has a token of its own, `--pacem-border-button-radius`: `0` squares them, a big value makes them pills.
```css
:root {
--pacem-border-button-radius: 999px;
}
```
For a single button, a `fill-*` utility is the shortest way; for a one-off color, write the surface token on it.
```html
<pacem-button class="button"
style="--pacem-surface-background-color: #1d6f5f">Teal, just here</pacem-button>
```
## Examples
### Ask before deleting `confirmation-dialog` holds the click back: the file goes away only on *yes*, and *no* drops the click.
### One handler for many buttons Each button names its command, and the argument says how much. A `pacem-event-proxy` listens for `command` once, on the container, and decides by name.
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.