Skip to contentKino
Skip to Content

Button

A button that animates what changes inside it: the label, the icon and the spinner.

npx shadcn add https://kinoui.com/r/button.json
Share on

Examples

Changing the label

Render a new label and the button animates to it. Letters both labels share stay in place, and a new icon rolls in.

Variants

The six variants of the shadcn Button.

Sizes

Four sizes. Each has an icon-only twin, such as icon-sm.

Icons

Mark an icon with data-icon and it gets its own place beside the label.

Loading

loading shows a spinner and blocks presses. The button keeps focus.

Icon only

Use an icon size and give the button an aria-label.

Disabled

A disabled button fades and ignores presses.

Installation

npx shadcn@latest add https://kinoui.com/r/button.json
Files
lib/refs.tslib/reduce-motion.tslib/resize.tslib/swap.tsxcomponents/kino/spinner.tsxcomponents/kino/button.tsx
Packages
@base-ui/reactclass-variance-authority

New to Kino? Installation covers what your project needs first and the @kino namespace.

API reference

Props

PropTypeDefaultDescription
variant'default''outline''secondary''ghost''destructive''link''default'How much the button stands out.
size'default''xs''sm''lg''icon''icon-xs''icon-sm''icon-lg''default'The height and padding. An icon size makes a square button.
loadingbooleanfalseShows a spinner and blocks presses. The spinner waits 200ms, so a fast request never flashes one.
disabledbooleanfalseFades the button and blocks presses.
childrenReactNodeNoneThe label and icons. The button animates when they change. To animate between two icons of the same component, give each a different key.
renderReactElementfunctionNoneRenders another element or component in place of the <button>.
...propsButton.PropsNoneEvery other prop goes to Base UI's Button (opens in a new tab).

Data attributes

AttributeOnDescription
data-icon='inline-start'An iconPuts the icon before the label. The spinner takes this place.
data-icon='inline-end'An iconPuts the icon after the label.
data-loadingButtonPresent while loading is set.
data-disabledButtonPresent while the button is disabled or loading.

CSS variables

VariableSet it onDefaultDescription
--swap-rollButton, or <body>55% of its heightHow far an icon that changes rolls: the old one leaves up, the new one rises.
--swap-scaleButton, or <body>0.8 for an icon, 1 for a text labelHow far what changes shrinks as it fades.
--swap-blurButton, or <body>2pxHow far what changes blurs as it fades.

Accessibility

  • A loading button stays focusable, so a keyboard user keeps their place.
  • A screen reader hears that the button is busy, not the result. Say the result in a role='status' region.
  • A label too long for its button truncates, and the full label becomes its title, or inside a CutTooltip its tooltip.