Primitives
Button
cva-driven button with the library's standardized hover-lift and tap-scale presets.
Motioninteraction.tap (press) on spring.snappy; color hover only — no position shift
Install
Install Kineto and follow the theme setup once in your app.
bash
npm install kinetotsx
import { Button, buttonVariants } from "kineto/button";Preview
tsx
"use client";
import * as React from "react";
import { Slot } from "@radix-ui/react-slot";
import { cva, type VariantProps } from "class-variance-authority";
import { motion } from "motion/react";
import { cn } from "@/lib/cn";
import { interaction, spring } from "@/lib/motion-presets";
const buttonVariants = cva(
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-lg text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
{
variants: {
variant: {
default: "bg-primary text-primary-foreground shadow-soft hover:bg-primary/90",
brand: "bg-brand text-brand-foreground shadow-soft hover:bg-brand/90",
/* A gradient can't be dimmed with an alpha modifier the way `bg-brand/90` is, so the
hover state lifts the whole ramp with a filter instead. */
gradient:
"bg-gradient-brand text-brand-foreground shadow-soft transition-[filter,box-shadow] hover:brightness-110 hover:shadow-lift",
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
outline:
"border border-input bg-card hover:bg-accent hover:text-accent-foreground",
ghost: "hover:bg-accent hover:text-accent-foreground",
destructive:
"bg-destructive text-destructive-foreground shadow-soft hover:bg-destructive/90",
link: "text-primary underline-offset-4 hover:underline",
},
size: {
sm: "h-9 px-3.5",
default: "h-10 px-5 py-2",
lg: "h-12 px-7 text-base",
pill: "h-11 rounded-full px-7",
icon: "size-10",
},
},
defaultVariants: {
variant: "default",
size: "default",
},
}
);
/* Drag/animation handlers are omitted because Motion redefines them and they would
otherwise collide with React's native DOM event types. */
type NativeButtonProps = Omit<
React.ButtonHTMLAttributes<HTMLButtonElement>,
| "onAnimationStart"
| "onAnimationEnd"
| "onAnimationIteration"
| "onDrag"
| "onDragStart"
| "onDragEnd"
| "onDragEnter"
| "onDragLeave"
| "onDragOver"
| "onDrop"
>;
export interface ButtonProps
extends NativeButtonProps,
VariantProps<typeof buttonVariants> {
/** Render as the child element (e.g. an `<a>`) instead of a `<button>`. Motion presets are omitted in this mode. */
asChild?: boolean;
}
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
if (asChild) {
return (
<Slot
ref={ref}
className={cn(
buttonVariants({ variant, size }),
// asChild has no Motion presets — give it CSS press feedback so links feel responsive too.
"transition-[transform,color,background-color,border-color,box-shadow] duration-150 ease-out active:scale-[0.98]",
className
)}
{...props}
/>
);
}
return (
<motion.button
ref={ref}
className={cn(buttonVariants({ variant, size, className }))}
whileTap={interaction.tap}
transition={spring.snappy}
{...props}
/>
);
}
);
Button.displayName = "Button";
export { Button, buttonVariants };src/components/ui/button.tsx
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "default" | "brand" | "gradient" | "secondary" | "outline" | "ghost" | "destructive" | "link" | "default" | Visual style. |
| size | "sm" | "default" | "lg" | "pill" | "icon" | "default" | Control sizing. |
| asChild | boolean | false | Render as the child element (motion presets omitted). |