Button
- Stable
- WCAG 2.2 evidence
- RTL
- Web · iOS · Android
Triggers an action such as Save, Submit, Approve or Delete.
Built on React Aria Button: Enter and Space activate, disabled buttons leave the tab order, and keyboard focus shows
the focus ring (WCAG 2.1.1, 2.4.7, 4.1.2).
import { Button } from "@nexera-ui/react";- 6
- examples
- 25
- props
- 6
- live controls
- 3
- platforms
- 11
- WCAG criteria
- 86
- blocks use it
Try every prop. Copy the code.
Change the props and the code updates. Check light and dark, LTR and RTL, and phone width.
import { Button } from "@nexera-ui/react";
<Button />Examples 5
The same examples as Storybook, rendered live. Open Code to copy one.
Variants and sizes
Every Figma Variant and Size on the web platform. Hover, press and focus the buttons to see the other states.
import { Button } from "@nexera-ui/react";
const variants = ["primary", "secondary", "ghost", "destructive"] as const;
const sizes = ["sm", "md", "lg"] as const;
export function VariantsAndSizes() {
return (
<div className="flex flex-col gap-4">
{variants.map((variant) => (
<div key={variant} className="flex flex-wrap items-center gap-4">
{sizes.map((size) => (
<Button key={size} variant={variant} size={size}>
{variant} {size}
</Button>
))}
</div>
))}
</div>
);
}
Disabled and loading
Figma Disabled state (isDisabled) and Loading state (isLoading).
import { Button } from "@nexera-ui/react";
const variants = ["primary", "secondary", "ghost", "destructive"] as const;
export function DisabledAndLoading() {
return (
<div className="flex flex-col gap-4">
{variants.map((variant) => (
<div key={variant} className="flex flex-wrap items-center gap-4">
<Button variant={variant} isDisabled>
Disabled
</Button>
<Button variant={variant} isLoading>
Saving
</Button>
</div>
))}
</div>
);
}
With icons
leadingIcon and trailingIcon slots.
import { Button } from "@nexera-ui/react";
import { LuArrowRight, LuPlus } from "react-icons/lu";
export function WithIcons() {
return (
<div className="flex flex-wrap items-center gap-4">
<Button leadingIcon={<LuPlus />}>Add employee</Button>
<Button variant="secondary" trailingIcon={<LuArrowRight />}>
Continue
</Button>
<Button size="lg" leadingIcon={<LuPlus />} trailingIcon={<LuArrowRight />}>
Both
</Button>
</div>
);
}
Platforms
Figma Button Mobile: platform="ios" and platform="android" raise the heights to 44/50/56 pt and 48/52/56 dp.
import { Button } from "@nexera-ui/react";
const sizes = ["sm", "md", "lg"] as const;
const platforms = ["web", "ios", "android"] as const;
export function Platforms() {
return (
<div className="flex flex-col gap-6">
{platforms.map((platform) => (
<div key={platform} className="flex flex-wrap items-center gap-4">
<span className="text-body-caption text-secondary w-16">{platform}</span>
{sizes.map((size) => (
<Button key={size} platform={platform} size={size} variant="primary">
{size}
</Button>
))}
<Button platform={platform} variant="ghost" size="md">
Ghost
</Button>
</div>
))}
</div>
);
}
Long label and full width
Labels wrap instead of truncating (translation can add 30 to 40%); give the button width with className="w-full".
import { Button } from "@nexera-ui/react";
export function LongLabelAndFullWidth() {
return (
<div className="flex max-w-xs flex-col gap-4">
<Button className="w-full">Request leave for the whole of next quarter</Button>
<Button variant="secondary">
Request leave for the whole of next quarter, including bank holidays
</Button>
</div>
);
}
Props 25
Press "Try it" on a card to load that prop into the playground.
25 props shown
children*NexeraReactNodeVisible label. Use a verb that names the outcome ("Send invite"); never truncated.
Icon-only buttons use IconButton instead, so the accessible name is always the label.
variantNexera"primary" | "secondary" | "ghost" | "destructive"Visual emphasis. destructive is reserved for irreversible actions.
sizeNexera"sm" | "md" | "lg"Height and padding. Heights follow the platform control tokens: 32 / 40 / 48 px on web, 44 / 50 / 56 pt on iOS, 48 / 52 / 56 dp on Android.
platformNexera"web" | "ios" | "android"Platform look. Defaults to the NexeraProvider platform.
leadingIconNexeraReactNodeIcon before the label. Shown when provided; replaced by the spinner while loading.
trailingIconNexeraReactNodeIcon after the label. Hidden while loading.
isLoadingNexerabooleanLoading state. Shows a spinner, stops presses and form submission, keeps focus, and announces the state to assistive technology.
loadingLabelNexerastringText announced to assistive technology while isLoading is true (appended to the label). Translate it for your locale.
classNameNexerastringExtra classes, merged last so they win over the defaults.
styleNexeraCSSPropertiesInline style.
isDisabledReact AriabooleanWhether the button is disabled.
onPressReact Aria(e: PressEvent) => voidHandler that is called when the press is released over the target.
onPressStartReact Aria(e: PressEvent) => voidHandler that is called when a press interaction starts.
onPressEndReact Aria(e: PressEvent) => voidHandler that is called when a press interaction ends, either over the target or when the pointer leaves the target.
onPressChangeReact Aria(isPressed: boolean) => voidHandler that is called when the press state changes.
onPressUpReact Aria(e: PressEvent) => voidHandler that is called when a press is released over the target, regardless of whether it started on the target or not.
autoFocusReact AriabooleanWhether the element should receive focus on render.
typeReact Aria"button" | "submit" | "reset"The behavior of the button when used in an HTML form.
formReact AriastringThe <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](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#form).
nameReact AriastringSubmitted as a pair with the button's value as part of the form data.
valueReact AriastringThe value associated with the button's name when it's submitted with the form data.
idReact AriastringThe element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id).
aria-labelReact AriastringDefines a string value that labels the current element.
aria-labelledbyReact AriastringIdentifies the element (or elements) that labels the current element.
aria-describedbyReact AriastringIdentifies the element (or elements) that describes the object.
* Required. React Aria props shown are the ones most apps use; the component accepts the rest of its React Aria props too.
Accessible by default.
Built on React Aria, and covered by the WCAG 2.2 evidence generated on every build.
| Key | Action |
|---|---|
| Space | Activates the button |
| Enter | Activates the button |
| Tab | Moves focus to the button. Disabled buttons are skipped. |
| Shift + Tab | Moves focus to the previous element |
- The visible label is the accessible name. Use IconButton for icon-only buttons so a name is always required.
- While loading, the button stays focusable, ignores presses and announces the loading label.
- The focus ring only shows for keyboard focus, never for mouse clicks.
- Touch targets meet WCAG 2.5.8: 32 px on web, 44 pt or more on mobile.
WCAG 2.2 evidence
6 direct · 5 supporting- 1.1.1Non-text ContentLevel A · tested directly
- 1.3.1Info and RelationshipsLevel A · tested directly
- 1.4.1Use of ColorLevel A · supporting test
- 1.4.4Resize TextLevel AA · supporting test
- 1.4.11Non-text ContrastLevel AA · supporting test
- 1.4.12Text SpacingLevel AA · supporting test
- 2.1.1KeyboardLevel A · tested directly
- 2.4.7Focus VisibleLevel AA · tested directly
- 2.5.8Target Size (Minimum)Level AA · supporting test
- 4.1.2Name, Role, ValueLevel A · tested directly
- 4.1.3Status MessagesLevel AA · tested directly
Fits any width.
Nexera components respond to the space they are given. Drag the corner of the frame, or pick a width.
| size | Web | iOS | Android |
|---|---|---|---|
sm | 32 px | 44 pt | 48 dp |
md | 40 px | 50 pt | 52 dp |
lg | 48 px | 56 pt | 56 dp |
Styling hooks
Pass className to add Tailwind classes (merged last). State is exposed as data attributes, so you can style it with variants like data-pressed:.
data-disableddata-focus-visibledata-hovereddata-pendingdata-pressed
<Button className="data-disabled:opacity-90 shadow-sm" />Do and don't
DoName the outcome: "Send invite", "Approve leave".
Don'tUse vague labels like "OK", "Submit" or "Click here".
DoUse one primary button per view.
Don'tPut several primary buttons side by side.
DoUse destructive only for actions that cannot be undone.
Don'tMake every delete or remove action red.
DoLet long labels wrap, and go full width on phones.
Don'tTruncate labels with an ellipsis.
DoUse IconButton when there is no visible text.
Don'tLeave a Button with only an icon inside it.
Used in blocks
- Sign inSign in and account
- Create accountSign in and account
- Two-step verificationSign in and account
- Forgot passwordSign in and account
- Set a new passwordSign in and account
- Check your emailSign in and account
- Session expiredSign in and account
- Product tourOnboarding
- Onboarding stepsOnboarding
- Profile setupOnboarding
- Invite your teamOnboarding
- Choose a planOnboarding
- Sidebar app shellApp shells and navigation
- Top bar with tabsApp shells and navigation
- Settings layoutApp shells and navigation
- Command paletteApp shells and navigation
- Page headerApp shells and navigation
- Workspace switcherApp shells and navigation
- Chart statesDashboards and analytics
- Data tableLists, tables and records
- Bulk actionsLists, tables and records
- Filter barLists, tables and records
- Filters drawerLists, tables and records
- People directoryLists, tables and records
- Record details drawerLists, tables and records
- Activity feedLists, tables and records
- Keyboard shortcutsLists, tables and records
- Contact formForms and data entry
- Add a personForms and data entry
- Multi-step formForms and data entry
- Address and phoneForms and data entry
- Date range pickerForms and data entry
- Terms and consentForms and data entry
- Choose an optionForms and data entry
- Pick a colourForms and data entry
- AppearanceSettings and preferences
- SecuritySettings and preferences
- Team members and rolesSettings and preferences
- Billing and planSettings and preferences
- Delete accountSettings and preferences
- Helpdesk assistantMessaging and collaboration
- Comment threadMessaging and collaboration
- Notification centreMessaging and collaboration
- AnnouncementMessaging and collaboration
- Document editorMessaging and collaboration
- Month calendarScheduling and calendar
- Week calendarScheduling and calendar
- Team availabilityScheduling and calendar
- Book a meetingScheduling and calendar
- Event detailsScheduling and calendar
- Leave requestScheduling and calendar
- Leave approvalScheduling and calendar
- Shift pickerScheduling and calendar
- Pricing plansCommerce and payments
- CheckoutCommerce and payments
- Saved payment methodsCommerce and payments
- Order summaryCommerce and payments
- PayslipCommerce and payments
- Product galleryCommerce and payments
- Order trackingCommerce and payments
- Candidate shortlistWork and projects
- Org chartWork and projects
- Approvals inboxWork and projects
- Team mapMaps and places
- Office finderMaps and places
- People nearbyMaps and places
- Check in hereMaps and places
- Video lessonMedia and content
- Photo galleryMedia and content
- Document previewMedia and content
- NPS surveyFeedback and surveys
- Mood check-inFeedback and surveys
- Rate thisFeedback and surveys
- Was this helpful?Feedback and surveys
- Short surveyFeedback and surveys
- Empty statesStates and system messages
- Error pagesStates and system messages
- Success confirmationStates and system messages
- ToastsStates and system messages
- Confirm a destructive actionStates and system messages
- Maintenance and offlineStates and system messages
- Long-running jobStates and system messages
- Action sheetMobile patterns
- Bottom sheet pickerMobile patterns
- Colour sheetMobile patterns
- Pull to refresh feedMobile patterns
Related components
- BoardCardA Kanban card: avatar, name, role, drag handle and a detail line.
- ButtonGroupItemOne toggle in a joined row of buttons, for example a List / Grid view switch or a set of filters.
- ContextMenuThe menu of actions for an element, opened where the user asks for it: right-click, long-press on touch screens, and from the keyboard with Shift+F10 or the ContextMenu key (the browser reports both as a `contextmenu` event on the focused element; on macOS, Control+Enter).
- DragHandleGrip that starts a drag of the collection item it sits in.
- DropIndicatorInsertion line shown between two items while something is dragged over a `GridList` or `ListBox`.
- IconButtonA square, icon-only button for compact actions such as Settings, Close or Delete row.
- MenuA list of actions or options that opens from a trigger.
- MenuDividerSeparates groups of items in a `Menu` or `ContextMenu`.