oakoss/ui
Components

Button

A pressable button built on React Aria.

SourceReact Aria

Installation

npx shadcn@latest add @oakoss/button

Usage

import { Button } from '#/components/ui/inputs/button';

<Button intent="success" variant="soft">
  Save
</Button>;

Examples

Variants and intents

variant sets the look (solid, soft, outline, ghost, link) and intent sets the color (primary, neutral, destructive, success, warning, info). Every look works with every intent.

Custom colors

className can set the --btn-* variables that every look reads. Set them rather than overriding bg-*, which hover and press would replace. See CSS variables for each one.

Icon-only

size="icon" (or icon-sm, icon-lg) requires an aria-label or aria-labelledby, since there's no text to name the button.

Pending

isPending keeps the button's width and focus, blocks presses, and shows a Spinner. Set pendingLabel to translate the spinner's name (see Localization).

buttonStyles styles a link as a button; it stays a link. Here it styles a TanStack Router link wrapped with createLink.

Accessibility

React Aria renders a native <button> and handles:

  • Press: one event for mouse, touch, pen and keyboard, so onPress fires once however the button is used.
  • Focus: the focus outline shows for keyboard focus only (data-focus-visible).
  • Pending: the button stays focusable but ignores presses, and screen readers announce the change while it has focus.

This component adds a 44×44 pointer target around every size, and keeps a visible border in Windows High Contrast, where a disabled button, or a link styled with buttonStyles, takes the system's disabled color like a native one. Icon-only sizes require a name in the type.

A pressed button shrinks slightly. React Aria holds a dialog, popover, menu or select trigger pressed while it's open, so a button with aria-expanded stays full size then, and its popup stays where it was placed. A trigger you build yourself sets aria-expanded to get the same.

KeyAction
SpacePresses the button
EnterPresses the button

Follows the WAI-ARIA button pattern.

API

Button

Extends React Aria's Button.

Props

Prop

Type

Also accepts all React Aria Button props.

Data attributes

AttributePresent when
data-slotbutton, unless a wrapper passes its own
data-variantAlways; the look
data-intentAlways; the color
data-sizeAlways; the size
data-hoveredA pointer hovers it
data-pressedIt's being pressed, or its popup is open
data-focusedIt has focus
data-focus-visibleIt has keyboard focus
data-disabledisDisabled is set
data-pendingisPending is set

CSS variables

VariableSets
--btn-bgThe solid fill
--btn-hoverThe solid fill on hover and press
--btn-fgText on the solid fill
--btn-subtleThe soft fill
--btn-borderThe outline border
--btn-textText, and the hover and press tint, for other looks