Button
React controlThe primary clickable primitive — six variants (default, destructive, outline, secondary, ghost, link), seven sizes (default, sm, lg, xs, icon, icon-sm, icon-lg), and an as-child mode that lets you render a Link or anchor with full button styling.
Also available for Vue ->Installation
$ pnpm dlx shadcn@latest add https://react.uipkge.dev/r/react/button.json$ npx shadcn@latest add https://react.uipkge.dev/r/react/button.json$ yarn dlx shadcn@latest add https://react.uipkge.dev/r/react/button.json$ bunx shadcn@latest add https://react.uipkge.dev/r/react/button.json
Or with the named registry:
npx shadcn@latest add @uipkge-react/button
Examples
Props
| Name | Type / Values | Default | Required |
|---|---|---|---|
variant | 'default''destructive''outline''secondary''ghost''link' | default | optional |
size | 'default''sm''lg''xs''icon''icon-sm''icon-lg' | default | optional |
asChild emitting a <button> — the React equivalent of reka-ui's as-child. Use it to give a Next.js <Link> or <a> full button styling. | boolean | false | optional |
Dependencies
Used by
ai-llm-chatalert-modalauth-mfaauth-password-resetauth-sign-inauth-sign-upcalendarcarouselchat-threadchat-two-panecheckout-flowcode-blockcontact-01contact-uscta-01dashboard-layoutdata-tabledate-pickerdialogevent-calendarfooter-01header-01hero-01inboxkanban-boardlogin-01login-02notifications-popoverpayment-formpricing-01range-calendarregister-01saved-cards-listsidebartheme-customizetime-pickertourtransfer
Files (3)
-
components/ui/button/Button.tsx 1 kB
import * as React from 'react' import { Slot } from '@radix-ui/react-slot' import { cn } from '@/lib/utils' import { buttonVariants, type ButtonVariants } from './button.variants' export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, ButtonVariants { /** Render the child element as the button (merging props/styles) instead of * emitting a <button> — the React equivalent of reka-ui's as-child. Use it * to give a Next.js <Link> or <a> full button styling. */ asChild?: boolean } const Button = React.forwardRef<HTMLButtonElement, ButtonProps>( ({ className, variant, size, asChild = false, ...props }, ref) => { const Comp = asChild ? Slot : 'button' return ( <Comp data-uipkge="" data-slot="button" data-variant={variant ?? undefined} data-size={size ?? undefined} className={cn(buttonVariants({ variant, size }), className)} ref={ref} {...props} /> ) }, ) Button.displayName = 'Button' export { Button } -
components/ui/button/button.variants.ts 2.2 kB
import type { VariantProps } from 'class-variance-authority' import { cva } from 'class-variance-authority' /** * Variant definitions live in their own file (rather than the package * `index.ts`) so `Button.vue` can `import { buttonVariants } from * './button.variants'` without creating a circular dependency through the * index. See card.variants.ts for the same pattern + the SSR symptom that * motivated the split. */ export const buttonVariants = cva( "inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-[color,background-color,border-color,box-shadow,opacity,transform] duration-150 active:scale-[0.97] active:duration-100 touch-manipulation disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", { variants: { variant: { default: 'bg-primary text-primary-foreground hover:bg-primary/90', destructive: 'bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60', outline: 'border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50', secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80', ghost: 'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50', link: 'text-primary underline-offset-4 hover:underline', }, size: { default: 'h-9 px-4 py-2 has-[>svg]:px-3', sm: 'h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5', lg: 'h-10 rounded-md px-6 has-[>svg]:px-4', xs: 'h-7 rounded-md gap-1 px-2 has-[>svg]:px-1.5 text-xs', icon: 'size-9', 'icon-sm': 'size-8', 'icon-lg': 'size-10', }, }, defaultVariants: { variant: 'default', size: 'default', }, }, ) export type ButtonVariants = VariantProps<typeof buttonVariants> -
components/ui/button/index.ts 0.1 kB
export { Button, type ButtonProps } from './Button' export { buttonVariants, type ButtonVariants } from './button.variants'
Raw manifest: https://react.uipkge.dev/r/react/button.json