Button
Trigger an action or event, such as submitting a form or displaying a dialog.
Best Practices
- Use
Buttonfor actions that mutate state (deploy, save, delete); useButtonLinkfor navigation that changes the URL. Switch to a Menu or Split Button when more than one related action shares a row. - Default
Buttonis primary. Passtype="secondary"for the supporting action andtype="error"for destructive confirmations.primary,success,ghost, andvioletare not validtypevalues. - For form submits, use
typeName="submit". The HTMLtypeattribute lives ontypeName, not ontype, which controls the visual variant. - Pass
loadinginstead of swapping in a spinner so the button stays focusable and announces the busy state to assistive tech. - Disable a button only when the action is impossible right now (missing input, insufficient permission); pair with a Tooltip that explains why.
- Title Case the label and name what happens:
Deploy Project,Invite Member,Rotate Key. Avoid bare verbs (Submit) and generic confirms (OK,Confirm). - Destructive buttons follow
Verb + Nounand pair 1:1 with their toast:Delete ProjectthenProject deleted. Mode-switch buttons appendInstead:Use a Recovery Code Instead. - Icon-only buttons require both
svgOnlyandaria-label; the validator throws without them. Thearia-labelnames the action and the target (Copy deployment URL), not the icon (Copy). - Don’t set
aria-labelon a button that already has visible text; it overrides the label and creates a screen-reader mismatch.
Was this helpful?