Button
launchui/buttonFreeComponent
A customizable button component with multiple variants and sizes.
Live preview
live · rendered by the registry
Rendered by launchui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.launchuicomponents.com/r/button.jsonSource
1import { Slot } from "@radix-ui/react-slot";2import { cva, type VariantProps } from "class-variance-authority";3import * as React from "react";45import { cn } from "@/lib/utils";67const buttonVariants = cva(8 "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",9 {10 variants: {11 variant: {12 default:13 "text-primary-foreground shadow-sm dark:hover:from-primary/80 hover:from-primary/70 dark:hover:to-primary/70 hover:to-primary/90 bg-linear-to-b from-primary/60 to-primary/100 dark:from-primary/100 dark:to-primary/70 border-t-primary",14 destructive:15 "bg-destructive/30 text-destructive-foreground shadow-xs hover:bg-destructive/90",16 outline:17 "border border-input bg-background shadow-xs hover:bg-accent hover:text-accent-foreground",18 glow: "glass-4 hover:glass-5 shadow-md",19 secondary:20 "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",21 ghost: "hover:bg-accent hover:text-accent-foreground",22 link: "text-foreground underline-offset-4 hover:underline",23 },24 size: {25 default: "h-9 px-4 py-2",26 xs: "h-7 rounded-md px-2",27 sm: "h-8 rounded-md px-3 text-xs",28 lg: "h-10 rounded-md px-5",29 icon: "size-9",30 },31 },32 defaultVariants: {33 variant: "default",34 size: "default",35 },36 },37);3839function Button({40 className,41 variant,42 size,43 asChild = false,44 ...props45}: React.ComponentProps<"button"> &46 VariantProps<typeof buttonVariants> & {47 asChild?: boolean;48 }) {49 const Comp = asChild ? Slot : "button";5051 return (52 <Comp53 data-slot="button"54 className={cn(buttonVariants({ variant, size, className }))}55 {...props}56 />57 );58}5960export { Button, buttonVariants };
What it pulls in
npm packages
Files it writes
More from launchui
All 24 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Badgebadge | launchui | Components | Free | 2 deps | |
| Cardcard | launchui | Components | Free | 1 dep | |
| Glowglow | launchui | Components | Free | 1 dep | |
| Launch UI Baselaunchui | launchui | Components | Free | no deps · 10 files | |
| Mockupmockup | launchui | Components | Free | 1 dep | |
| Pro Dependenciespro | launchui | Components | Free | 14 deps | |
| Screenshotscreenshot | launchui | Components | Free | 1 dep |
