Button Variants
interlace-ui/button-variantsFreeComponent
The cva variant map that `button.tsx` imports — variant × size class strings and nothing else. Pure CVA: no React, no client APIs, so a server component can style a plain `<a>` with `buttonVariants({ variant, size })`.
Install it
npx shadcn@latest add https://ds.interlace.tools/r/button-variants.jsonSource
1import { cva, type VariantProps } from 'class-variance-authority';23// @interlace/button-variants v1.3.0 — Interlace design system.4// Docs, props and live preview: https://ds.interlace.tools/c/button-variants5// What changed since: https://ds.interlace.tools/c/button-variants#history6// Generated banner — keep it, the upgrade diff reads this version.78/**9 * @interlace/ui — buttonVariants10 *11 * The cva variant map that `button.tsx` imports — variant × size class strings12 * and nothing else. Pure CVA: no React, no client APIs, so a server component13 * can style a plain `<a>` with `buttonVariants({ variant, size })`.14 *15 * This is not a component. It exports a function and a type, renders nothing,16 * and has no props, no slots and no DOM — which is exactly why it is a17 * separate module from the `'use client'` Button that consumes it.18 *19 * ## Anatomy20 *21 * buttonVariants({ variant, size })22 * ├─ variant default | destructive | outline | secondary | ghost | link23 * └─ size default | xs | sm | lg | icon | icon-xs | icon-sm | icon-lg24 *25 * Defaults are `variant: 'default'`, `size: 'default'`. `pagination.tsx` is26 * the in-repo example of styling an element rather than nesting a Button: its27 * `<a>` takes `buttonVariants({ variant, size })` directly. (It reaches the28 * function through `button.js`, which re-exports it — that path is29 * `'use client'`; import from this module to keep a server tree server-side.)30 *31 * ## Why half this file is comments32 *33 * Four of the six variants carry a long note recording a measured contrast34 * failure and the rule it produced: a variant that declares its own foreground35 * must paint an opaque surface in the same state, because a button is dropped36 * onto surfaces the design system does not control. `outline` inheriting the37 * page text into a `bg-primary` section measured 1.05:1; `link` with38 * `text-primary` on the same section measured 1.00:1. `composite-contrast-lock`39 * composites every variant over every brandable backdrop, so those notes are40 * checkable rather than folklore.41 *42 * | Rule | Concept | Where in this file |43 * | ---- | -------------------------------- | ----------------------------------------------------------- |44 * | R8 | Enums, no booleans | `variant` and `size` are closed string enums |45// … truncated
More from interlace-ui
All 140 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| A11y Startera11y-starter | interlace-ui | Components | Free | no deps | |
| Accordionaccordion | interlace-ui | Components | Free | no deps | |
| Alertalert | interlace-ui | Components | Free | no deps | |
| Alert Dialogalert-dialog | interlace-ui | Components | Free | no deps | |
| Animated Gradient Textanimated-gradient-text | interlace-ui | Components | Free | no deps | |
| Animated Grid Patternanimated-grid-pattern | interlace-ui | Components | Free | no deps | |
| Animated Listanimated-list | interlace-ui | Components | Free | no deps | |
| Article Cardarticle-card | interlace-ui | Components | Free | no deps |
