Form

Button

A button draws attention to an important action and initializes this action when clicked.

View source

Props

NameTypeDefaultDescription
enabledrequiredboolean
"aria-activedescendant"string
Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application.
"aria-atomic"Booleanish
Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute.
"aria-autocomplete""list" | "none" | "inline" | "both"
Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be presented if they are made.
"aria-busy"Booleanish
Indicates an element is being modified and that assistive technologies MAY want to wait until the modifications are complete before exposing them to the user.
"aria-checked"boolean | "true" | "false" | "mixed"
Indicates the current "checked" state of checkboxes, radio buttons, and other widgets.
"aria-colcount"number
Defines the total number of columns in a table, grid, or treegrid.
"aria-colindex"number
Defines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid.
"aria-colspan"number
Defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.
"aria-controls"string
Identifies the element (or elements) whose contents or presence are controlled by the current element.
"aria-current"boolean | "true" | "false" | "page" | "step" | "location" | "date" | "time"
Indicates the element that represents the current item within a container or set of related elements.
"aria-describedby"string
Identifies the element (or elements) that describes the object.
"aria-details"string
Identifies the element that provides a detailed, extended description for the object.
"aria-disabled"Booleanish
Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable.
"aria-errormessage"string
Identifies the element that provides an error message for the object.
"aria-expanded"Booleanish
Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed.
"aria-flowto"string
Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion, allows assistive technology to override the general default of reading in document source order.
"aria-haspopup"boolean | "true" | "false" | "dialog" | "grid" | "listbox" | "menu" | "tree"
Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element.
"aria-hidden"Booleanish
Indicates whether the element is exposed to an accessibility API.
"aria-invalid"boolean | "true" | "false" | "grammar" | "spelling"
Indicates the entered value does not conform to the format expected by the application.
"aria-keyshortcuts"string
Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element.
"aria-label"string
Defines a string value that labels the current element.
"aria-labelledby"string
Identifies the element (or elements) that labels the current element.
"aria-level"number
Defines the hierarchical level of an element within a structure.
"aria-live""off" | "assertive" | "polite"
Indicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region.
"aria-modal"Booleanish
Indicates whether an element is modal when displayed.
"aria-multiline"Booleanish
Indicates whether a text box accepts multiple lines of input or only a single line.
"aria-multiselectable"Booleanish
Indicates that the user may select more than one item from the current selectable descendants.
"aria-orientation""horizontal" | "vertical"
Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous.
"aria-owns"string
Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship between DOM elements where the DOM hierarchy cannot be used to represent the relationship.
"aria-placeholder"string
Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value. A hint could be a sample value or a brief description of the expected format.
"aria-posinset"number
Defines an element's number or position in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.
"aria-pressed"boolean | "true" | "false" | "mixed"
Indicates the current "pressed" state of toggle buttons.
"aria-readonly"Booleanish
Indicates that the element is not editable, but is otherwise operable.
"aria-relevant""text" | "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals"
Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified.
"aria-required"Booleanish
Indicates that user input is required on the element before a form may be submitted.
"aria-roledescription"string
Defines a human-readable, author-localized description for the role of an element.
"aria-rowcount"number
Defines the total number of rows in a table, grid, or treegrid.
"aria-rowindex"number
Defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid.
"aria-rowspan"number
Defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.
"aria-selected"Booleanish
Indicates the current "selected" state of various widgets.
"aria-setsize"number
Defines the number of items in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.
"aria-sort""none" | "ascending" | "descending" | "other"
Indicates if items in a table or grid are sorted in ascending or descending order.
"aria-valuemax"number
Defines the maximum allowed value for a range widget.
"aria-valuemin"number
Defines the minimum allowed value for a range widget.
"aria-valuenow"number
Defines the current value for a range widget.
"aria-valuetext"string
Defines the human readable text alternative of aria-valuenow for a range widget.
aboutstring
accessKeystring
autoCapitalizestring
autoCorrectstring
autoFocusboolean
autoSavestring
childrenReactNode
classesstring | string[]
Additional CSS classes to set on the button element
classNamestring
colorstring
contentEditableBooleanish | "inherit"
contextMenustring
dangerouslySetInnerHTML{ __html: string; }
datatypestring
defaultCheckedboolean
defaultValuestring | number | readonly string[]
dirstring
disabledboolean
draggableBooleanish
formstring
formActionstring
formEncTypestring
formMethodstring
formNoValidateboolean
formTargetstring
hiddenboolean
hideDisabledboolean
idstring
inlistany
inputMode"none" | "search" | "text" | "tel" | "url" | "email" | "numeric" | "decimal"
Hints at the type of data that might be entered by the user while editing the element or its contents
isstring
Specify that a standard HTML element should behave like a defined custom built-in element
isLoadingboolean
If set to true, forces the button to display a spinner to the left of the text
itemIDstring
itemPropstring
itemRefstring
itemScopeboolean
itemTypestring
langstring
linkstring
namestring
noncestring
onAbortReactEventHandler<HTMLButtonElement>
onAbortCaptureReactEventHandler<HTMLButtonElement>
onAnimationEndAnimationEventHandler<HTMLButtonElement>
onAnimationEndCaptureAnimationEventHandler<HTMLButtonElement>
onAnimationIterationAnimationEventHandler<HTMLButtonElement>
onAnimationIterationCaptureAnimationEventHandler<HTMLButtonElement>
onAnimationStartAnimationEventHandler<HTMLButtonElement>
onAnimationStartCaptureAnimationEventHandler<HTMLButtonElement>
onAuxClickMouseEventHandler<HTMLButtonElement>
onAuxClickCaptureMouseEventHandler<HTMLButtonElement>
onBeforeInputFormEventHandler<HTMLButtonElement>
onBeforeInputCaptureFormEventHandler<HTMLButtonElement>
onBlurFocusEventHandler<HTMLButtonElement>
onBlurCaptureFocusEventHandler<HTMLButtonElement>
onCanPlayReactEventHandler<HTMLButtonElement>
onCanPlayCaptureReactEventHandler<HTMLButtonElement>
onCanPlayThroughReactEventHandler<HTMLButtonElement>
onCanPlayThroughCaptureReactEventHandler<HTMLButtonElement>
onChangeFormEventHandler<HTMLButtonElement>
onChangeCaptureFormEventHandler<HTMLButtonElement>
onClick(() => void) & MouseEventHandler<HTMLButtonElement>
onClickCaptureMouseEventHandler<HTMLButtonElement>
onCompositionEndCompositionEventHandler<HTMLButtonElement>
onCompositionEndCaptureCompositionEventHandler<HTMLButtonElement>
onCompositionStartCompositionEventHandler<HTMLButtonElement>
onCompositionStartCaptureCompositionEventHandler<HTMLButtonElement>
onCompositionUpdateCompositionEventHandler<HTMLButtonElement>
onCompositionUpdateCaptureCompositionEventHandler<HTMLButtonElement>
onContextMenuMouseEventHandler<HTMLButtonElement>
onContextMenuCaptureMouseEventHandler<HTMLButtonElement>
onCopyClipboardEventHandler<HTMLButtonElement>
onCopyCaptureClipboardEventHandler<HTMLButtonElement>
onCutClipboardEventHandler<HTMLButtonElement>
onCutCaptureClipboardEventHandler<HTMLButtonElement>
onDoubleClickMouseEventHandler<HTMLButtonElement>
onDoubleClickCaptureMouseEventHandler<HTMLButtonElement>
onDragDragEventHandler<HTMLButtonElement>
onDragCaptureDragEventHandler<HTMLButtonElement>
onDragEndDragEventHandler<HTMLButtonElement>
onDragEndCaptureDragEventHandler<HTMLButtonElement>
onDragEnterDragEventHandler<HTMLButtonElement>
onDragEnterCaptureDragEventHandler<HTMLButtonElement>
onDragExitDragEventHandler<HTMLButtonElement>
onDragExitCaptureDragEventHandler<HTMLButtonElement>
onDragLeaveDragEventHandler<HTMLButtonElement>
onDragLeaveCaptureDragEventHandler<HTMLButtonElement>
onDragOverDragEventHandler<HTMLButtonElement>
onDragOverCaptureDragEventHandler<HTMLButtonElement>
onDragStartDragEventHandler<HTMLButtonElement>
onDragStartCaptureDragEventHandler<HTMLButtonElement>
onDropDragEventHandler<HTMLButtonElement>
onDropCaptureDragEventHandler<HTMLButtonElement>
onDurationChangeReactEventHandler<HTMLButtonElement>
onDurationChangeCaptureReactEventHandler<HTMLButtonElement>
onEmptiedReactEventHandler<HTMLButtonElement>
onEmptiedCaptureReactEventHandler<HTMLButtonElement>
onEncryptedReactEventHandler<HTMLButtonElement>
onEncryptedCaptureReactEventHandler<HTMLButtonElement>
onEndedReactEventHandler<HTMLButtonElement>
onEndedCaptureReactEventHandler<HTMLButtonElement>
onErrorReactEventHandler<HTMLButtonElement>
onErrorCaptureReactEventHandler<HTMLButtonElement>
onFocusFocusEventHandler<HTMLButtonElement>
onFocusCaptureFocusEventHandler<HTMLButtonElement>
onGotPointerCapturePointerEventHandler<HTMLButtonElement>
onGotPointerCaptureCapturePointerEventHandler<HTMLButtonElement>
onInputFormEventHandler<HTMLButtonElement>
onInputCaptureFormEventHandler<HTMLButtonElement>
onInvalidFormEventHandler<HTMLButtonElement>
onInvalidCaptureFormEventHandler<HTMLButtonElement>
onKeyDownKeyboardEventHandler<HTMLButtonElement>
onKeyDownCaptureKeyboardEventHandler<HTMLButtonElement>
onKeyUpKeyboardEventHandler<HTMLButtonElement>
onKeyUpCaptureKeyboardEventHandler<HTMLButtonElement>
onLoadReactEventHandler<HTMLButtonElement>
onLoadCaptureReactEventHandler<HTMLButtonElement>
onLoadedDataReactEventHandler<HTMLButtonElement>
onLoadedDataCaptureReactEventHandler<HTMLButtonElement>
onLoadedMetadataReactEventHandler<HTMLButtonElement>
onLoadedMetadataCaptureReactEventHandler<HTMLButtonElement>
onLoadStartReactEventHandler<HTMLButtonElement>
onLoadStartCaptureReactEventHandler<HTMLButtonElement>
onLostPointerCapturePointerEventHandler<HTMLButtonElement>
onLostPointerCaptureCapturePointerEventHandler<HTMLButtonElement>
onMouseDownMouseEventHandler<HTMLButtonElement>
onMouseDownCaptureMouseEventHandler<HTMLButtonElement>
onMouseEnterMouseEventHandler<HTMLButtonElement>
onMouseLeaveMouseEventHandler<HTMLButtonElement>
onMouseMoveMouseEventHandler<HTMLButtonElement>
onMouseMoveCaptureMouseEventHandler<HTMLButtonElement>
onMouseOutMouseEventHandler<HTMLButtonElement>
onMouseOutCaptureMouseEventHandler<HTMLButtonElement>
onMouseOverMouseEventHandler<HTMLButtonElement>
onMouseOverCaptureMouseEventHandler<HTMLButtonElement>
onMouseUpMouseEventHandler<HTMLButtonElement>
onMouseUpCaptureMouseEventHandler<HTMLButtonElement>
onPasteClipboardEventHandler<HTMLButtonElement>
onPasteCaptureClipboardEventHandler<HTMLButtonElement>
onPauseReactEventHandler<HTMLButtonElement>
onPauseCaptureReactEventHandler<HTMLButtonElement>
onPlayReactEventHandler<HTMLButtonElement>
onPlayCaptureReactEventHandler<HTMLButtonElement>
onPlayingReactEventHandler<HTMLButtonElement>
onPlayingCaptureReactEventHandler<HTMLButtonElement>
onPointerCancelPointerEventHandler<HTMLButtonElement>
onPointerCancelCapturePointerEventHandler<HTMLButtonElement>
onPointerDownPointerEventHandler<HTMLButtonElement>
onPointerDownCapturePointerEventHandler<HTMLButtonElement>
onPointerEnterPointerEventHandler<HTMLButtonElement>
onPointerEnterCapturePointerEventHandler<HTMLButtonElement>
onPointerLeavePointerEventHandler<HTMLButtonElement>
onPointerLeaveCapturePointerEventHandler<HTMLButtonElement>
onPointerMovePointerEventHandler<HTMLButtonElement>
onPointerMoveCapturePointerEventHandler<HTMLButtonElement>
onPointerOutPointerEventHandler<HTMLButtonElement>
onPointerOutCapturePointerEventHandler<HTMLButtonElement>
onPointerOverPointerEventHandler<HTMLButtonElement>
onPointerOverCapturePointerEventHandler<HTMLButtonElement>
onPointerUpPointerEventHandler<HTMLButtonElement>
onPointerUpCapturePointerEventHandler<HTMLButtonElement>
onProgressReactEventHandler<HTMLButtonElement>
onProgressCaptureReactEventHandler<HTMLButtonElement>
onRateChangeReactEventHandler<HTMLButtonElement>
onRateChangeCaptureReactEventHandler<HTMLButtonElement>
onResetFormEventHandler<HTMLButtonElement>
onResetCaptureFormEventHandler<HTMLButtonElement>
onResizeReactEventHandler<HTMLButtonElement>
onResizeCaptureReactEventHandler<HTMLButtonElement>
onScrollUIEventHandler<HTMLButtonElement>
onScrollCaptureUIEventHandler<HTMLButtonElement>
onSeekedReactEventHandler<HTMLButtonElement>
onSeekedCaptureReactEventHandler<HTMLButtonElement>
onSeekingReactEventHandler<HTMLButtonElement>
onSeekingCaptureReactEventHandler<HTMLButtonElement>
onSelectReactEventHandler<HTMLButtonElement>
onSelectCaptureReactEventHandler<HTMLButtonElement>
onStalledReactEventHandler<HTMLButtonElement>
onStalledCaptureReactEventHandler<HTMLButtonElement>
onSubmitFormEventHandler<HTMLButtonElement>
onSubmitCaptureFormEventHandler<HTMLButtonElement>
onSuspendReactEventHandler<HTMLButtonElement>
onSuspendCaptureReactEventHandler<HTMLButtonElement>
onTimeUpdateReactEventHandler<HTMLButtonElement>
onTimeUpdateCaptureReactEventHandler<HTMLButtonElement>
onTouchCancelTouchEventHandler<HTMLButtonElement>
onTouchCancelCaptureTouchEventHandler<HTMLButtonElement>
onTouchEndTouchEventHandler<HTMLButtonElement>
onTouchEndCaptureTouchEventHandler<HTMLButtonElement>
onTouchMoveTouchEventHandler<HTMLButtonElement>
onTouchMoveCaptureTouchEventHandler<HTMLButtonElement>
onTouchStartTouchEventHandler<HTMLButtonElement>
onTouchStartCaptureTouchEventHandler<HTMLButtonElement>
onTransitionEndTransitionEventHandler<HTMLButtonElement>
onTransitionEndCaptureTransitionEventHandler<HTMLButtonElement>
onVolumeChangeReactEventHandler<HTMLButtonElement>
onVolumeChangeCaptureReactEventHandler<HTMLButtonElement>
onWaitingReactEventHandler<HTMLButtonElement>
onWaitingCaptureReactEventHandler<HTMLButtonElement>
onWheelWheelEventHandler<HTMLButtonElement>
onWheelCaptureWheelEventHandler<HTMLButtonElement>
placeholderstring
prefixstring
primaryboolean
propertystring
radioGroupstring
resourcestring
resultsnumber
roleAriaRole
securitystring
slotstring
smallboolean
If set to true, forces the button to have a smaller size
spellCheckBooleanish
styleCSSProperties
suppressContentEditableWarningboolean
suppressHydrationWarningboolean
tabIndexnumber
targetstring
titlestring
tooltipstring
tooltipPlacement"left" | "right" | "top" | "bottom"
translate"yes" | "no"
type"submit" | "reset" | "button"
typeofstring
unselectable"on" | "off"
valuestring | number | readonly string[]
vocabstring
"aria-dropeffect"deprecated"link" | "none" | "copy" | "execute" | "move" | "popup"
in ARIA 1.1
Indicates what functions can be performed when a dragged object is released on the drop target.
"aria-grabbed"deprecatedBooleanish
in ARIA 1.1
Indicates an element's "grabbed" state in a drag-and-drop operation.
onKeyPressdeprecatedKeyboardEventHandler<HTMLButtonElement>
onKeyPressCapturedeprecatedKeyboardEventHandler<HTMLButtonElement>

Examples

Best Practices

The button label should allow users to foresee what will happen when clicking them.

Avoid multiplying buttons within a page. A page should have only one primary action button. If several secondary action buttons are required, consider using actionable items instead.

Labeling

Keep labels short, preferably under three words. Use trigger words to clearly indicate the action performed by the button. A trigger word is typically a verb that influences users into clicking due to its specificity. For example, use "View profile" rather than "Open profile", and "Create playlist" rather than "Save".

The first word of the label should be a verb. If adding a noun is required for context, avoid including an article. For example, write "Add filter" rather than "Add a filter", but write "Save" and "Cancel".

When using a button to have users confirm the action to execute, use an active word to clearly state the resulting action. For instance, if users must confirm the deletion of a file, write "Delete" and "Cancel" rather than "Yes" and "No".

Order of Buttons

When using a group of related buttons, such as for the "Save" and "Cancel" actions, always put the primary button to the right and the secondary to the left of the primary button.

In such case, the primary button must correspond to an action that moves the user forward through their journey or to the main action that the user should take.

For example, in the Sticky footer of a page where the user edits a configuration, order buttons as follows: "Cancel" (secondary), then "Save" (primary).

Similarly, in the footer of a modal wizard, navigation buttons must be ordered as follows: "Previous" (secondary), then "Next" (primary). At the last step, the “Next” button must be replaced with a primary button with a label indicating the resulting action. For example, an appropriate label would be “Add filter” rather than “Save”.

In a page header, the primary button should appear on the left and the secondary button should be to the right of the primary button. The primary action usually relates to the creation of new elements, while secondary actions are usually used to trigger troubleshooting or management actions, such as activity review. If multiple secondary actions are required, group them using an actionable item on the rightmost side of the header.

Variants

TypePurpose
PrimaryA primary button draws the users' attention to the main action. There should be only one primary button per section or page.
SecondaryA secondary button triggers an action of lesser importance. Multiple secondary buttons may trigger actions of similar importance.
Icon + labelAdd a icon left of the label to clarify the action or draw attention to the button. Ensure the icon is highly recognizable.
Label + iconAdd an icon right of the label to indicate that additional options are available when clicking the button. This indicates that clicking the button doesn't immediately trigger the action. Instead, a menu overlay is displayed, allowing users to select the exact action to be performed. For example, use a label and an icon on the right when the action is "Create" and options are to create from a template or a blank file.
Icon onlyWhen space is an issue or when the icon is highly and instantly recognizable, an icon alone may suffice. For instance, the "Settings" button is commonly presented using a cog icon. However, you should never use an icon-only button for primary actions.
Append and prepend separatorAdding a separator is an aesthetic choice typically made when multiple buttons are stacked vertically. Use a separator to align the icon to the right or left of the button. All buttons must have the same width when vertically stacked.

Feedback and Validation

When the label is hidden, add a tooltip displaying the action.

Related Components

If your use case doesn't match the guidelines above, consider using one of the following components instead:

  • Link - When you need to redirect users to another section or website.
  • Actionable items - When you need to group several less important actions together.
Edit guidelines