Button
Buttons allow users to perform an action or to navigate to another page. They have multiple styles for various needs, and are ideal for calling attention to where a user needs to do something in order to move forward in a flow.
Props (Recommended)
The Button component now supports a flexible variant system with appearance, size, and color props for maximum customization.
Button Appearances
Control visual emphasis with three appearance types:
Filled (High Emphasis)
Solid background for primary actions.
Primary Action
<Button appearance="filled" color="blue"> Primary Action</Button>Outlined (Medium Emphasis)
Border-only style for secondary actions.
Secondary Action
<Button appearance="outlined" color="blue"> Secondary Action</Button>Linked (Low Emphasis)
Text-only style for tertiary actions.
Tertiary Action
<Button appearance="linked" color="blue"> Tertiary Action</Button>Button Sizes
Seven size variants from compact to prominent:
xxs
xs
sm
md
lg
xl
xxl
<Button size="xxs">Extra Extra Small</Button><Button size="xs">Extra Small</Button><Button size="sm">Small</Button><Button size="md">Medium (default)</Button><Button size="lg">Large</Button><Button size="xl">Extra Large</Button><Button size="xxl">Extra Extra Large</Button>Button Colors
Three semantic color schemes:
Blue
Red
Grey
<Button color="blue">Primary Actions</Button><Button color="red">Destructive Actions</Button><Button color="grey">Neutral Actions</Button>Legacy Props (Backward Compatible)
The legacy variant prop is fully supported for backward compatibility:
Primary
Primary buttons should be used sparingly, one per screen, as they are used to guide the user towards taking a primary action.
Create user
<Button variant="primary">Create user</Button>Maps to: appearance="filled" color="blue"
Secondary
Secondary buttons add less emphasis and often accompany primary buttons in button groups, like the side panel footer. This is the default button style.
Sync profile
<Button variant="secondary">Sync profile</Button>Maps to: appearance="outlined" color="grey" (default)
Tertiary
Tertiary buttons are used for actions requiring less emphasis.
Cancel
<Button variant="tertiary">Cancel</Button>Maps to: appearance="linked" color="blue"
Critical
Critical buttons are used for actions that require the most emphasis, as they are used to guide the user towards taking a destructive or potentially dangerous action.
Delete user
<Button variant="critical">Delete user</Button>Maps to: appearance="filled" color="red"
Interaction States
Buttons automatically handle five interaction states:
- Default: Base styling
- Hover: Activated on mouse hover
- Focus: Visible focus ring for keyboard navigation
- Pressed: Active state during click/key press
- Disabled: Non-interactive state
Default
Disabled
<Button appearance="filled" color="blue">Active Button</Button><Button appearance="filled" color="blue" isDisabled>Disabled Button</Button>Accessibility
The Button component meets WCAG 2.2 Level AAA standards:
- ✅ Full keyboard navigation (Enter/Space keys)
- ✅ Visible focus indicators with 7:1 contrast ratio
- ✅ Screen reader compatible
- ✅ Minimum 20x20px touch targets (via padding)
- ✅ Respects
prefers-reduced-motion
Keyboard Navigation
<Button onPress={() => console.log("Activated")}>Press Enter or Space</Button>Accessible Labels
{ /* Icon-only button with accessible label */}<Button aria-label="Close dialog"> <CloseIcon /></Button>;Migration Guide
From Legacy to New API
Before (Legacy):
<Button variant="primary">Submit</Button><Button variant="secondary">Cancel</Button><Button variant="tertiary">Skip</Button><Button variant="critical">Delete</Button>After (New API):
<Button appearance="filled" color="blue">Submit</Button><Button appearance="outlined" color="grey">Cancel</Button><Button appearance="linked" color="blue">Skip</Button><Button appearance="filled" color="red">Delete</Button>Gradual Migration
You can mix legacy and new props for gradual migration:
{ /* Override just the color while keeping variant behavior */}<Button variant="secondary" color="red"> Cancel Subscription</Button>;
{ /* Result: appearance="outlined" (from variant), color="red" (override) */}TypeScript Support
Full type safety with exported types:
import { Button, type ButtonProps, type ButtonAppearance, type ButtonSize, type ButtonColor,} from "@helpscout/ui-kit-react";
const MyButton: React.FC<ButtonProps> = (props) => { return <Button {...props} />;};Customization with CSS Variables
The Button component uses CSS variables for all colors, making it easy to customize without modifying the source code.
Custom Brand Colors
Override CSS variables to match your brand:
Custom Purple
<Button appearance="filled" color="blue" style={{ "--ui-kit-button-filled-blue-bg": "#7C3AED", "--ui-kit-button-filled-blue-bg-hover": "#6D28D9", "--ui-kit-button-filled-blue-bg-pressed": "#5B21B6", } as React.CSSProperties}> Custom Purple</Button>Available CSS Variables
All button CSS variables follow the pattern:
--ui-kit-button-[appearance]-[color]-[property]
Common variables:
--ui-kit-button-[appearance]-[color]-bg- Background color--ui-kit-button-[appearance]-[color]-bg-hover- Hover background--ui-kit-button-[appearance]-[color]-bg-pressed- Pressed background--ui-kit-button-[appearance]-[color]-text- Text color--ui-kit-button-[appearance]-[color]-border- Border color
Replace [appearance] with filled, outlined, or linked
Replace [color] with blue, red, or grey
Global Theme Override
For app-wide customization, override variables in your global CSS:
:root { /* Override blue filled buttons globally */ --ui-kit-button-filled-blue-bg: #7c3aed; --ui-kit-button-filled-blue-bg-hover: #6d28d9; --ui-kit-button-filled-blue-bg-pressed: #5b21b6;}Props
Whether the button is in a pending state. This disables press and hover events while retaining focusability, and announces the pending state to screen readers.
Whether the button is disabled.
Handler that is called when the press is released over the target.
Handler that is called when a press interaction starts.
Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target.
Handler that is called when the press state changes.
Handler that is called when a press is released over the target, regardless of whether it started on the target or not.
Not recommended – use onPress instead. onClick is an alias for onPress
provided for compatibility with other libraries. onPress provides
additional event details for non-mouse interactions.
Whether the element should receive focus on render.
Handler that is called when the element receives focus.
Handler that is called when the element loses focus.
Handler that is called when the element's focus status changes.
Handler that is called when a key is pressed.
Handler that is called when a key is released.
The behavior of the button when used in an HTML form.
Whether to prevent focus from moving to the button when pressing it.
Caution, this can make the button inaccessible and should only be used when alternative keyboard interaction is provided, such as ComboBox's MenuTrigger or a NumberField's increment/decrement control.
The <form> element to associate the button with.
The value of this attribute must be the id of a <form> in the same document.
See MDN.
The URL that processes the information submitted by the button. Overrides the action attribute of the button's form owner.
Indicates how to encode the form data that is submitted.
Indicates the HTTP method used to submit the form.
Indicates that the form is not to be validated when it is submitted.
Overrides the target attribute of the button's form owner.
Submitted as a pair with the button's value as part of the form data.
The value associated with the button's name when it's submitted with the form data.
Whether to exclude the element from the sequential tab order. If true, the element will not be focusable via the keyboard by tabbing. This should be avoided except in rare scenarios where an alternative means of accessing the element or its functionality via the keyboard is available.
The element's unique identifier. See MDN.
Handler that is called when a hover interaction starts.
Handler that is called when a hover interaction ends.
Handler that is called when the hover state changes.
A slot name for the component. Slots allow the component to receive props from a parent component.
An explicit null value indicates that the local props completely override all props received from a parent.
The children of the component. A function may be provided to alter the children based on component state.
The CSS className for the element. A function may be provided to compute the class based on component state.
The inline style for the element. A function may be provided to compute the style based on component state.
Legacy button variant (DEPRECATED).
@remarks Maintained for backward compatibility only. New code should use
type, size, and color props instead.
@deprecated Use type, size, and color props instead.
Related Components
- ButtonGroup - Group multiple buttons together
- ComboBox - Uses Button for trigger
- Modal - Uses Button in footer