Skip to main content

Button

Use cases:

  • Submit forms
  • Trigger actions
  • Create interactive elements
  • Set options

Example

Default ButtonPrimary Color ButtonSecondary Color ButtonButton with start slotButton with end slotDisabled Button

Declaration

<rapid-button>Button</rapid-button>

Usage

@customElement({
name: 'my-element',
template: html`
<rapid-button
@click="${x => x.handleButtonClicked()}">
Default Button
</rapid-button>
<rapid-button
appearance="primary"
@click="${x => x.handleButtonClicked()}">
Primary Color Button
</rapid-button>
<rapid-button
appearance="secondary"
@click="${x => x.handleButtonClicked()}">
Secondary Color Button
</rapid-button>
<rapid-button
@click="${x => x.handleButtonClicked()}">
<rapid-icon
name="plus"
slot="start">
</rapid-icon>
Button with start slot
</rapid-button>
<rapid-button
@click="${x => x.handleButtonClicked()}">
Button with end slot
<rapid-icon
name="warning"
slot="end">
</rapid-icon>
</rapid-button>
<rapid-button disabled>
Disabled Button
</rapid-button>
`,
})
export class MyElement extends GenesisElement {
handleButtonClicked() {
alert('button clicked')
}
}

API

Property and attribute binding examples for Genesis Component syntax. Closing tag omitted.

NameTypeDescriptionExample
autofocusbooleanThe boolean value of whether the button is checked.
<rapid-button autofocus>
disabledbooleanMakes the component visually opaque, and configures it so that the user cannot alter the state via the web browser.
<rapid-button disabled>
formstringAssociates this component with a form. The Form id must be passed. If no Id is passed, then it will be associated with the ancestor form.
<rapid-button form="myForm">
namestringDefines the name of the element.
<rapid-button name="buttonName">
typestringDefines the mode of the button. button (default) - performs an action when clicked | reset - can influence a group of components associated with the same form)
<rapid-button type="button">
valuestringDefines the value associated with this button.
<rapid-button value="sample">

Properties

This component doesn't have any properties which are not also controlled via attributes.

Slots

SlotUse
startStart slot.
endEnd slot.

Parts

PartDescription
controlThe button element.
contentThe element wrapping button content.

Events fired

EventUse
clickEmits a change event when the button is pressed

Events listened to

This component doesn't listen to any events.

Further details

This component is an implementation of an HTML button element.