| Name | Description | Default | Type |
|---|---|---|---|
children* | Text or content for the Button. | | ReactNode |
aria-label | The aria label text will be inserted as the aria-label on the Button. | | string |
as | HTML tag or React Component to render the component as. | | ElementType<any> |
className | Additional CSS classes. | | string |
compact | Used for a smaller sized button. | false | boolean |
disabled | Determines if the Button will be disabled. | false | boolean |
forwardedAs | HTML tag or React Component to finally render the component as. | | ElementType<any> |
href | A location to navigate to. Passing an href will render an anchor styled as a Button. | | string |
icon | Set the Icon prop to | false | boolean |
label | The label text will be used inside a Tooltip. | | string |
loading | Optionally renders an indeterminate progress indicator in a button. | false | boolean |
ref | Ref forwarded to the wrapping element. | | Ref<HTMLButtonElement> |
type | Controls the behavior of a Button within a Form. | "button" | 'button' |'reset' |'submit' |
variant | Controls the styling of the Button. | "secondary" | 'link' |'text' |'primary' |'secondary' |'simple' |
Button
Note: All components shown on this site are supported by the Constellation design system. To learn how to configure Theme Cosmos, visit Pega Community.
Buttons execute any action when a user interacts with them, including submitting Forms. Unlike Links, they do not perform navigation.
Variants
The Button component offers multiple variants that alter the physical appearance and interactions of the Button. For each variant, the Button style can be further modified by setting it as compact.
Any Button with a label provided will render a Tooltip upon hover or focus of the Button. The Tooltip will contain the label provided, as will the aria-label attribute, unless explicitly set otherwise.
Example
Disabled Buttons
When Buttons are disabled, they become opaque and non-interactable.
Example
Icon Buttons
If a Button's only content is an Icon, you should set the icon prop to true so that the Button is sized appropriately. You should also make sure to include a label for icon-only Buttons for accessibility reasons.
Example
Loading Buttons
If the loading prop is set true on a Button, a small spinning Progress ring will appear. The loading animation will replace whatever content was passed to the Button children without altering the original size of the Button. The loading animation should only be applied to Buttons with variants of either primary or secondary.
Example
Link Buttons
If you need a native <a/> in your DOM, but would like the styling of a Button, you can simply pass an href to the Button of choice. Keep in mind, if you pass an href to a Button with a link variant, you should just use the Link component instead.
Example
Related components
Properties
Custom theming
You can override the styles of the Button component by setting a custom theme on the Configuration component.
Example
Theme properties
{
height:'base.hit-area.mouse-min',// → base.hit-area.mouse-min'border-width':'0.0625rem','border-radius':9999,color:'base.palette.interactive',// → base.palette.interactive'secondary-color':'base.palette.primary-background',// → base.palette.primary-background'focus-shadow':'base.shadow.focus',// → base.shadow.focuspadding:'0 1rem',
height:'base.hit-area.finger-min',// → base.hit-area.finger-minpadding:'0 1.5rem'}}}}