Fancy Button V2

FancyButtonV2 is a styled button built on Base UI's Button primitive, with a primary-colored, glossy look and a subtle press animation. It offers eight size variants (including icon-only sizes) and can render as another element through Base UI's render prop.

Fancy Button V2
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 @diarmuradi/fancy-button-v2

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

Usage

usage.tsx
import { FancyButtonV2 } from "@/components/ui/fancy-button-v2"export function Example() {  return <FancyButtonV2>Get started</FancyButtonV2>}
  • Primary call-to-action buttons such as sign up, checkout, or submit where a more polished, glossy look is desired
  • Icon-only actions using the icon, icon-xs, icon-sm, or icon-lg sizes
  • Buttons that should navigate as links while keeping button styling, using the render prop
  • Form submit or action buttons that need built-in destructive styling when aria-invalid is set

Examples

Primary call to action

Default size button used as a primary CTA.

primary-call-to-action.tsx
import { FancyButtonV2 } from "@/components/ui/fancy-button-v2"export function HeroCta() {  return (    <FancyButtonV2 size="lg" onClick={() => console.log("clicked")}>      Start free trial    </FancyButtonV2>  )}

Icon-only button

Uses the icon size with an accessible label since there is no visible text.

icon-only-button.tsx
import { FancyButtonV2 } from "@/components/ui/fancy-button-v2"export function CloseButton() {  return (    <FancyButtonV2 size="icon" aria-label="Close dialog">      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} aria-hidden="true">        <path d="M18 6 6 18M6 6l12 12" />      </svg>    </FancyButtonV2>  )}

Rendered as a link

The render prop swaps the underlying element to an anchor while keeping the button styling.

rendered-as-a-link.tsx
import { FancyButtonV2 } from "@/components/ui/fancy-button-v2"export function DocsLink() {  return (    <FancyButtonV2 size="sm" render={<a href="/docs" />}>      Read the docs    </FancyButtonV2>  )}

Small button with inline icon

Small size with an icon; the icon is automatically sized to size-3.5 and given pointer-events-none.

small-button-with-inline-icon.tsx
import { FancyButtonV2 } from "@/components/ui/fancy-button-v2"export function DownloadButton() {  return (    <FancyButtonV2 size="sm" data-icon="inline-start">      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} aria-hidden="true">        <path d="M12 3v12m0 0-4-4m4 4 4-4M5 21h14" />      </svg>      Download    </FancyButtonV2>  )}

API reference

PropTypeDefaultDescription
size"default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined"default"Controls height, padding, gap, and radius via class-variance-authority. Also written to the data-size attribute.
classNamestring—Additional classes merged with the variant classes using cn (tailwind-merge aware).
renderButtonPrimitive.Props["render"] (Base UI render prop)—Replaces the rendered element (for example an anchor). When provided, nativeButton is forced to false.
nativeButtonboolean—Passed to the Base UI Button. Ignored and set to false when render is provided. Pass through to indicate whether the rendered element is a native button.
...propsButtonPrimitive.Props—All other Base UI Button props and standard button attributes (for example onClick, disabled, type, aria-label) are forwarded. The component also sets data-slot="fancy-button-v2".

Accessibility

  • Icon-only sizes (icon, icon-xs, icon-sm, icon-lg) have no visible text, so always provide an aria-label or visually hidden text.
  • Keyboard focus shows a 2px primary ring with a 1px offset via focus-visible, so the focus indicator only appears for keyboard users.
  • When aria-invalid is set, the button uses destructive colors and a destructive focus ring to signal an error state.
  • Disabled buttons use disabled:pointer-events-none and muted colors; use the disabled prop rather than only visual styling so assistive technology announces the state.
  • When using render with a non-button element, nativeButton is set to false, so the rendered element must provide appropriate semantics (for example an anchor with href).
  • The press scale effect is skipped for elements with aria-haspopup, so menu triggers are not visually shifted on activation.
  • Inline SVG icons are marked pointer-events-none and receive size classes automatically; add aria-hidden="true" to decorative icons.

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 "Fancy Button V2" component (diarmuradi/fancy-button-v2) from its shadcn registry.1. Install it with: npx shadcn@latest add @diarmuradi/fancy-button-v22. 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: size, className, render, nativeButton, ...props.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { FancyButtonV2 } from "@/components/ui/fancy-button-v2"export function Example() {  return <FancyButtonV2>Get started</FancyButtonV2>}```

Files & dependencies

  • fancy-button-v2.tsx→ components/ui/fancy-button-v2.tsx
dependencies@base-ui/reactclass-variance-authoritycn

Looks similar, elsewhere