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
<meta itemprop="description" content="Default primary button demonstrating base button usage and styling.">
<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
Triggers actions via click, Enter, or Space. USE variant to set
hierarchy: primary (SHOULD limit one per page), secondary, tertiary,
or danger. Renders a native <button> with delegatesFocus for
keyboard access. MUST use label for icon-only buttons to set the
ARIA accessible name. Supports form association (submit/reset).
Slots
2
| Slot Name | Summary | Description |
|---|---|---|
icon slot for visual indicators |
Contains the button's icon or state indicator (e.g. spinner). Wrapped in aria-hidden span so screen readers skip decorative icons. Close and play variants auto-populate this slot via #renderIcon(). |
|
button text label |
Text content displayed inside the button. Hidden from screen readers
via aria-hidden when the label attribute is set. For close and play
variants, text is visually hidden but remains accessible. SHOULD
provide concise, action-oriented text (e.g. "Submit", "Delete"). |
Attributes
9
| Attribute | DOM Property | Description | Type | Default |
|---|---|---|---|---|
|
|
disabled |
Disables the button, preventing user interaction. When true, the button
receives |
|
|
|
|
type |
Controls the button's behavior within a form context. Accepts 'button' (no default form behavior), 'submit' (submits the form), or 'reset' (resets form fields). When omitted, defaults to implicit submit behavior. |
|
|
|
|
label |
Accessible name for the button, applied as |
|
|
|
|
value |
Form value submitted with the button when it triggers form submission.
Paired with |
|
|
|
|
name |
Form name for the button, used with |
|
|
|
|
icon |
Shorthand for the |
|
|
|
|
iconSet |
Icon set for the |
|
|
|
|
variant |
Controls the visual hierarchy and style of the button. Accepts ‘primary’ | ‘secondary’ | ‘tertiary’ | ‘close’ | ‘play’. Defaults to ‘primary’. SHOULD limit primary to one per page. USE secondary for general actions, tertiary for low-emphasis actions. Close and play variants render icon-only circular buttons with visually hidden text. |
|
|
|
|
danger |
Applies danger styling for destructive or irreversible actions like
deleting data. Combines with |
|
|
Methods
1
| 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
|
Events
0
None
CSS Shadow Parts
2
| Part Name | Summary | Description |
|---|---|---|
|
|
internal button element |
Native button element that receives focus via delegatesFocus. Screen readers announce this as a button with the label or slotted text. |
|
|
icon slot for visual indicators |
Contains the button's icon or state indicator (e.g. spinner). Wrapped in aria-hidden span so screen readers skip decorative icons. Close and play variants auto-populate this slot via #renderIcon(). |
CSS Custom Properties
2
| CSS Property | Description | Default |
|---|---|---|
--rh-color-text-status-disabled |
—
|
|
--rh-color-status-disabled |
—
|
Design Tokens
37
| Token | Description | Copy |
|---|---|---|
--rh-font-size-body-text-md
|
Button text size 16px font size |
|
--rh-font-weight-body-text-regular
|
Button font weight Regular font weight |
|
--rh-line-height-body-text
|
Button line height Line height for body text |
|
--rh-length-4xs
|
Button focus ring offset 1px length token |
|
--rh-border-radius-default
|
Button corner radius; uses --rh-border-radius-default design token Button corner rounding 3px border radius; Example: Card |
|
--rh-space-sm
|
Button vertical spacing Button content gap 6px spacer |
|
--rh-space-lg
|
Button horizontal spacing 16px spacer |
|
--rh-color-interactive-primary-hover-on-light
|
Primary interactive - hover (Light theme) |
|
--rh-color-interactive-primary-hover
|
|
|
--rh-color-text-primary-on-dark
|
Primary text color for dark theme |
|
--rh-color-text-primary-on-light
|
Primary text color for light theme |
|
--rh-color-status-danger
|
|
|
--rh-color-border-status-danger
|
|
|
--rh-color-red-60
|
Dark brand red |
|
--rh-color-red-30
|
Lighter brand red |
|
--rh-border-width-sm
|
1px border width; Example: Secondary CTA or Button |
|
--rh-color-text-primary
|
|
|
--rh-color-border-strong
|
|
|
--rh-border-width-md
|
2px border width: Example: Alert |
|
--rh-color-blue-70
|
Alert - Info title text |
|
--rh-color-interactive-primary-hover-on-dark
|
Primary interactive - hover (Dark theme) |
|
--rh-color-icon-secondary
|
|
|
--rh-color-interactive-secondary-active
|
|
|
--rh-color-interactive-secondary-focus
|
|
|
--rh-color-interactive-secondary-hover
|
|
|
--rh-length-lg
|
Button width 16px length token |
|
--rh-opacity-50
|
50% opacity |
|
--rh-color-interactive-primary-default
|
|
|
--rh-color-gray-90
|
Secondary surface (dark theme) |
|
--rh-opacity-80
|
80% opacity |
|
--rh-length-4xl
|
Button width 64px length token |
|
--rh-color-icon-secondary-on-dark
|
|
|
--rh-color-icon-secondary-on-light
|
|
|
--rh-color-gray-50
|
Subtle icon |
|
--rh-color-gray-60
|
Secondary text (light theme) |
|
--rh-color-gray-30
|
Subtle borders (light theme) |
|
--rh-color-gray-40
|
Subtle icon (hover state) |
|
Other libraries
To learn more about our other libraries, visit this page.
Feedback
To give feedback about anything on this page, contact us.