Button
Save, submit, or move to the next step. Give users a clear action for the task they want to complete.
Usage guide
#Use a Button to execute the user's choice. Use links for navigation. Within one task area, emphasize the most important action first.
Examples
#Feature examples
#Choose a feature from 14 topics. Explore property settings, method calls, event results, and slot layouts through live examples and code.
No matching features.
API reference
#Hover over a name or focus it with the keyboard to see an example. On touch screens, tap the name.
Properties
| Attribute | Type | Default | Description |
|---|---|---|---|
default | primary | secondary | borderless | default | Visual style of the button | |
small | medium | large | medium | Button size | |
boolean | false | Block clicks and keyboard activation | |
boolean | false | Show progress and block additional clicks | |
boolean | false | Fill the parent's width | |
boolean | false | Configure an icon-only button. Place only an icon in the slot | |
string | "" | Default tooltip. Accessible name for an icon-only button | |
button | submit | reset | button | Standard action, form submission, or reset | |
boolean | false | Skip form validation on submit |
Slots
| Name | Description |
|---|---|
| Button text and icons. Add them as child elements without a slot name. |
Methods
| Method | Returns | Description |
|---|---|---|
Promise<void> | Click the internal button. Does not run when disabled or loading | |
Promise<void> | Focus the internal button | |
Promise<void> | Remove focus from the internal button | |
Promise<void> | Update the group direction and the shape of the first and last buttons. In normal use, sy-button-group manages this, so place the button inside a group. |
Events
| Event | Description |
|---|---|
The standard click event for a button. Subscribe with addEventListener. Handle form submission in the form's submit event. |
The examples below target a button with
id="action-button". JavaScript
const button = document.querySelector('#action-button');
await customElements.whenDefined('sy-button');
button.addEventListener('click', () => {
console.log('Button clicked.');
});
await button.setFocus();