Button
On this page
Importing
Add rh-button to your page with this import statement:
<script type="module">
import '@rhds/elements/rh-button/rh-button.js';
</script>
Copy to Clipboard
Copied!
Wrap lines
Overflow lines
To learn more about installing RHDS elements on your site using an import map read our getting started docs.
Usage
<rh-button>Primary</rh-button>
<script type="module">
import '@rhds/elements/rh-button/rh-button.js';
</script>
Copy to Clipboard
Copied!
Wrap lines
Overflow lines
rh-button
A button is clickable text or an icon that triggers an action on the page or in the background. Depending on the action, content, and hierarchy, a button can be used on its own or grouped with other buttons.
| Slot Name | Summary | Description |
|---|---|---|
|
Contains the button's icon or state indicator, e.g. a spinner. |
||
|
Contains button text |
| Attribute | DOM Property | Description | Type | Default |
|---|---|---|---|---|
|
|
disabled |
Disables the button |
|
|
|
|
type |
button type |
|
|
|
|
label |
Accessible name for the button, use when the button does not have slotted text |
|
|
|
|
value |
Form value for the button |
|
|
|
|
name |
Form name for the button |
|
|
|
|
icon |
Shorthand for the |
|
|
|
|
iconSet |
Icon set for the |
|
|
|
|
variant |
Changes the style of the button.
|
|
|
|
|
danger |
Use danger buttons for actions a user can take that are potentially destructive or difficult/impossible to undo, like deleting or removing user data. |
|
|
| Method Name | Description |
|---|---|
|
|
Programmatically moves focus to the button element. This method focuses the internal button element, making it the active element on the page. Useful for managing focus flow after dynamic content changes or user interactions. Usage guidelines
Accessibility
|
| Part Name | Summary | Description |
|---|---|---|
|
|
Internal button element |
|
|
|
Container for the icon slot |
| CSS Property | Description | Default |
|---|---|---|
--rh-color-text-status-disabled |
—
|
|
--rh-color-status-disabled |
—
|
| Token | Summary | Copy |
|---|---|---|
--rh-font-size-body-text-md
|
|
|
--rh-font-weight-body-text-regular
|
|
|
--rh-line-height-body-text
|
|
|
--rh-length-4xs
|
|
|
--rh-border-radius-default
|
|
|
--rh-space-sm
|
|
|
--rh-space-lg
|
|
|
--rh-color-interactive-primary-hover-on-light
|
|
|
--rh-color-interactive-primary-hover
|
|
|
--rh-color-text-primary-on-dark
|
|
|
--rh-color-text-primary-on-light
|
|
|
--rh-color-status-danger
|
|
|
--rh-color-border-status-danger
|
|
|
--rh-color-red-60
|
|
|
--rh-color-red-30
|
|
|
--rh-border-width-sm
|
|
|
--rh-color-text-primary
|
|
|
--rh-color-border-strong
|
|
|
--rh-border-width-md
|
|
|
--rh-color-blue-70
|
|
|
--rh-color-interactive-primary-hover-on-dark
|
|
|
--rh-color-icon-secondary
|
|
|
--rh-color-interactive-secondary-active
|
|
|
--rh-color-interactive-secondary-focus
|
|
|
--rh-color-interactive-secondary-hover
|
|
|
--rh-length-lg
|
|
|
--rh-opacity-50
|
|
|
--rh-color-interactive-primary-default
|
|
|
--rh-color-gray-90
|
|
|
--rh-opacity-80
|
|
|
--rh-length-4xl
|
|
|
--rh-color-icon-secondary-on-dark
|
|
|
--rh-color-icon-secondary-on-light
|
|
|
--rh-color-gray-50
|
|
|
--rh-color-gray-60
|
|
|
--rh-color-gray-30
|
|
|
--rh-color-gray-40
|
|
Other libraries
To learn more about our other libraries, visit this page.
Feedback
To give feedback about anything on this page, contact us.