Button
cubby-ui/buttonFreeComponent
A simple button component.
Live preview
live · rendered by the registry
Rendered by cubby-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://cubby-ui.dev/r/button.jsonSource
1"use client";23import * as React from "react";4import { cva, type VariantProps } from "class-variance-authority";5import { Button as BaseButton } from "@base-ui/react/button";6import { HugeiconsIcon } from "@hugeicons/react";7import { Loading03Icon } from "@hugeicons/core-free-icons";8import { cn } from "@/lib/utils";910// The button's fill and border render on a ::before pseudo-element that11// scales down on press (the pill shrinks, the label stays put). Because the12// pseudo travels with the classes, every consumer of the recipe — <Button>13// and flat elements styled via `buttonVariants` (pagination links, calendar14// nav, toolbar buttons) — gets identical paint and press behavior with no15// extra DOM. ButtonGroup collapses borders between segments with `before:`16// rules, inert on children that don't carry the recipe.17//18// Paint: variants set per-state tokens (--btn-bg, --btn-bg-hover,19// --btn-bg-active, --btn-border), the state machine below resolves them into20// --btn-paint, and buttonPaint renders it on the pseudo (custom properties21// inherit into pseudo-elements). Consumers recolor by overriding the tokens22// (className="[--btn-bg:...]") and restyle the border via `before:` classes23// (className="before:border-dashed").24const buttonBase = cn(25 "relative isolate inline-flex items-center cursor-pointer justify-center whitespace-nowrap rounded-lg font-medium data-disabled:pointer-events-none data-disabled:opacity-60 data-disabled:focus-visible:outline-ring [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 focus-visible:outline-ring/50 outline-0 outline-offset-0 outline-transparent transition-[outline-width,outline-offset,outline-color,scale,opacity,background-color,color] duration-100 ease-out outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 aria-invalid:outline-destructive/50 aria-invalid:outline-2 aria-invalid:outline-offset-2 aria-invalid:outline-solid",26 // State machine: unset tokens fall through to transparent. Pressing shows27 // the active paint — except on popup triggers (aria-haspopup), which skip28 // pressed feedback entirely (mirroring the press-scale guard) and simply29 // hold their hover paint while open (data-popup-open, stamped by Base UI).30// … truncated
What it pulls in
npm packages
Files it writes
More from cubby-ui
All 79 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | cubby-ui | Components | Free | 2 deps | |
| Alertalert | cubby-ui | Components | Free | 1 dep | |
| Alert-dialogalert-dialog | cubby-ui | Components | Free | 2 deps | |
| Aspect-ratioaspect-ratio | cubby-ui | Components | Free | no deps | |
| Autocompleteautocomplete | cubby-ui | Components | Free | 2 deps | |
| Avataravatar | cubby-ui | Components | Free | 1 dep | |
| Badgebadge | cubby-ui | Components | Free | 1 dep | |
| Base Drawerbase-drawer | cubby-ui | Components | Free | 2 deps |
