Skip to main content

Button

A lightweight animated button with optional ripple, magnetic, shimmer, and async variants.

Effects:

Customize

Sizemd

Installation

Add the base button with the registry command:

npx shadcn@latest add @kinetic/button

Install an effect separately when you need it. Each command also installs the shared files it requires.

npx shadcn@latest add @kinetic/ripple-button
npx shadcn@latest add @kinetic/magnetic-button
npx shadcn@latest add @kinetic/shimmer-button
npx shadcn@latest add @kinetic/async-button

Usage

Import the button from your project and use it for an action:

import { Button } from "@/components/kinetic/ui/button";

export function SaveButton() {
  return <Button>Save changes</Button>;
}

Variants and sizes

Choose a variant to set the visual emphasis and a size (xs, sm, default, md, lg, icon-xs, icon-sm, icon, or icon-lg) to fit the context. default maps to md dimensions. For an icon-only button, provide an accessible label.

<Button variant="outline" size="xs">Cancel</Button>
<Button variant="destructive" size="sm">Delete</Button>
<Button size="icon-sm" aria-label="Add item">+</Button>

Use asChild to merge button classes, refs, press handlers, and width morphing onto a child link or custom element. Use buttonVariants when styling an anchor directly without a wrapper component.

import Link from "next/link";
import { Button, buttonVariants } from "@/components/kinetic/ui/button";

interface ActionLinksProps {
  readonly docsHref: string;
  readonly guideHref: string;
}

export function ActionLinks({ docsHref, guideHref }: ActionLinksProps) {
  return (
    <div className="flex items-center gap-2">
      <Button asChild variant="outline" size="sm">
        <Link href={docsHref}>Read docs</Link>
      </Button>
      <a href={guideHref} className={buttonVariants({ variant: "secondary", size: "xs" })}>
        Guide
      </a>
    </div>
  );
}

Ripple

Use RippleButton to show a ripple at the pointer position when pressed.

import { RippleButton } from "@/components/kinetic/ui/ripple-button";

<RippleButton>Continue</RippleButton>

Magnetic

Use MagneticButton for a subtle pointer-following effect on mouse input.

import { MagneticButton } from "@/components/kinetic/ui/magnetic-button";

<MagneticButton variant="outline">Explore</MagneticButton>

Shimmer

Use ShimmerButton for a sweep of light when a mouse pointer enters the button.

import { ShimmerButton } from "@/components/kinetic/ui/shimmer-button";

<ShimmerButton>Get started</ShimmerButton>

Async state

Use AsyncButton with a controlled status of idle, loading, success, or error. While loading, the button is disabled and exposes aria-busy. Set the labels to match the action and language of your application.

import { AsyncButton } from "@/components/kinetic/ui/async-button";

<AsyncButton status="loading" loadingLabel="Saving...">
  Save changes
</AsyncButton>

Motion preferences

The base Button animates its width when its content changes and provides press feedback. Press feedback respects the browser's reduced-motion preference. Optional effects also respect the Kinetic reduced-motion setting; time-based effects use the current tempo.

API Reference

Button

Zero-dependency animated button with visual variants, size presets, ResizeObserver width morphing, press feedback, and asChild slot composition.

PropTypeDefaultDescription
variant"default" | "secondary" | "outline" | "ghost" | "destructive" | "link""default"Visual style.
size"xs" | "sm" | "default" | "md" | "lg" | "icon-xs" | "icon-sm" | "icon" | "icon-lg""md"Button size preset; "default" maps to "md".
asChildbooleanfalseMerges button styles, refs, handlers, and width-morph spans onto the single child element.
...propsReact.ButtonHTMLAttributes<HTMLButtonElement>-Native button attributes.

buttonVariants

Zero-dependency class helper for applying Kinetic button variant and size styles to custom elements or links.

PropTypeDefaultDescription
variant"default" | "secondary" | "outline" | "ghost" | "destructive" | "link""default"Visual variant token.
size"xs" | "sm" | "default" | "md" | "lg" | "icon-xs" | "icon-sm" | "icon" | "icon-lg""md"Dimension preset token.
classNamestring-Optional additional utility classes merged via cn().