Button

An accessible animated button from the reactframe registry with primary, secondary, outline, and ghost variants, a spinning loading state, an optional icon, and a motion-driven focus ring. Colors, sizes, radius, and timing are all exposed as props.

Button
LIVE · running in a sandboxed iframe
Installed with plain shadcn add · no workarounds · theme neutral (none shipped)
See how it was built

Installation

pnpm dlx shadcn@latest add @reactframe/button

Requires @reactframe in the registries of your components.json (shadcn adds official directory namespaces automatically).

Usage

usage.tsx
import { Button } from "@/components/button";export function Example() {  return <Button label="Save changes" variant="primary" onClick={() => console.log("saved")} />;}
  • Primary call-to-action or form submit buttons that need a branded, animated feel
  • Actions that must show an in-progress state with a built-in spinner while an async request runs
  • Toolbars or secondary actions where a ghost or outline variant is needed without extra styling
  • Interfaces where every color, size, radius, and motion timing must be tuned through props rather than Tailwind classes

Examples

Primary button with icon

A primary button with a leading icon placed on the left.

primary-button-with-icon.tsx
import * as React from "react";import { Button } from "@/components/button";const PlusIcon = (  <svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round">    <path d="M8 3v10M3 8h10" />  </svg>);export function CreateProjectButton() {  return <Button label="New project" variant="primary" icon={PlusIcon} iconPosition="left" />;}

Loading state during submit

A submit button that shows the spinner and disables clicks while a request is pending.

loading-state-during-submit.tsx
import * as React from "react";import { Button } from "@/components/button";export function SubmitButton() {  const [loading, setLoading] = React.useState(false);  return (    <Button      label="Sign in"      type="submit"      variant="primary"      loading={loading}      onClick={async () => {        setLoading(true);        await new Promise((r) => setTimeout(r, 1500));        setLoading(false);      }}    />  );}

Outline and ghost variants with custom colors

Outline and ghost variants recolored through accentColor and sized with height and fullWidth.

outline-and-ghost-variants-with-custom-colors.tsx
import { Button } from "@/components/button";export function ActionRow() {  return (    <div className="flex flex-col gap-3 p-4">      <Button label="Cancel" variant="outline" accentColor="#2563eb" fullWidth />      <Button label="Learn more" variant="ghost" accentColor="#2563eb" height={36} />    </div>  );}

API reference

PropTypeDefaultDescription
labelstring"Button"Text content rendered inside the button.
onClick() => void—Click handler. Not attached while the button is disabled or loading.
type"button" | "submit" | "reset""button"Native button type attribute.
variantButtonVariant ("primary" | "secondary" | "outline" | "ghost")"primary"Visual style variant.
disabledbooleanfalseDisables the button, removes the click handler, shows a not-allowed cursor, and sets opacity to 0.5. Also disables hover and tap animations.
loadingbooleanfalseShows a rotating spinner in place of the left icon, sets aria-busy, disables the button, and sets opacity to 0.85.
fullWidthbooleanfalseMakes the button w-full instead of w-fit.
iconReact.ReactNode—Optional icon node rendered on the side set by iconPosition. Hidden while loading (the spinner replaces the left icon).
iconPosition"left" | "right""left"Side on which the icon is rendered.
fontFamilystring"Inter, system-ui, sans-serif"CSS font-family applied to the button.
heightnumber40Button height in pixels. Padding, font size, radius, and gap default to ratios of this value.
paddingXnumberheight * 0.55Horizontal padding in pixels.
fontSizenumberheight * 0.35Font size in pixels.
radiusnumberheight * 0.28Border radius in pixels.
gapnumberheight * 0.2Gap in pixels between spinner or icon and label.
accentColorstring"#f59e0b"Primary accent color used by primary background, outline border and text, and ghost text.
accentTextColorstring"#ffffff"Text and icon color on the primary variant.
secondaryColorstring"#f3f4f6"Background color of the secondary variant.
secondaryTextColorstring"#111827"Text and icon color of the secondary variant.
borderWidthnumber1.5Border width in pixels for the outline variant.
ringColorstring"rgba(245,158,11,0.25)"Color of the focus halo ring.
ringWidthnumber3Spread of the focus halo ring in pixels.
durationnumber0.18Transition duration in seconds for the focus ring animation.
classNamestring—Additional Tailwind or CSS classes merged onto the button via tailwind-merge.

Accessibility

  • Renders a native button element, so keyboard activation with Enter and Space works by default.
  • While loading, aria-busy is set to true so assistive technology announces the pending state.
  • Disabled and loading states set the native disabled attribute, removing the button from the tab order.
  • A visible focus indicator is provided by an animated box-shadow ring; ensure ringColor has sufficient contrast against the page background.
  • Icon-only usage is not supported by the label prop being required for text; if using icon alone, pass an empty or visually hidden label and add an aria-label via className workaround is not available, so prefer a text label.
  • Ensure accentTextColor on accentColor and secondaryTextColor on secondaryColor meet WCAG AA contrast (4.5:1 for normal text).

Docs written by anthropic:claude-haiku-5-5 from the registry source.

Use with Coding Agent

Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.

prompt.md
Use the "Button" component (reactframe/button) from its shadcn registry.1. Install it with: npx shadcn@latest add @reactframe/button2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: label, onClick, type, variant, disabled, loading, fullWidth, icon, iconPosition, fontFamily, height, paddingX, fontSize, radius, gap, accentColor, accentTextColor, secondaryColor, secondaryTextColor, borderWidth, ringColor, ringWidth, duration, className.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { Button } from "@/components/button";export function Example() {  return <Button label="Save changes" variant="primary" onClick={() => console.log("saved")} />;}```

Files & dependencies

  • registry/new-york/button/button.tsx
dependenciesmotionclsxtailwind-merge

Looks similar, elsewhere