button
pane/buttonFreeComponent
pane publishes no description for this item.
Install it
npx shadcn@latest add https://pane.theui.company/r/button.jsonSource
1import { cva, type VariantProps } from "class-variance-authority";2import { Slot } from "radix-ui";3import type * as React from "react";4import { Pane } from "@/components/ui/pane";5import { cn } from "@/lib/utils";67const wrapperVariants = cva("inline-flex shrink-0", {8 variants: {9 size: {10 default: "",11 sm: "",12 lg: "",13 icon: "",14 },15 },16 defaultVariants: { size: "default" },17});1819const radiusBySize: Record<string, number> = {20 default: 16,21 sm: 13,22 lg: 20,23 icon: 16,24};2526const buttonVariants = cva(27 "inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap text-sm font-medium outline-none transition-colors disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",28 {29 variants: {30 variant: {31 default: "text-foreground",32 destructive: "text-red-600 dark:text-red-400",33 },34 size: {35 default: "h-9 px-4",36 sm: "h-8 px-3 text-xs",37 lg: "h-11 px-6 text-base",38 icon: "size-9 px-0",39 },40 },41 defaultVariants: { variant: "default", size: "default" },42 },43);4445export interface ButtonProps46 extends React.ComponentProps<"button">,47 VariantProps<typeof buttonVariants> {48 asChild?: boolean;49}5051function Button({52 className,53 variant = "default",54 size = "default",55 asChild = false,56 ...props57}: ButtonProps) {58 const Comp = asChild ? Slot.Root : "button";5960 return (61 <Pane62 variant="clear"63 interactive64 radius={radiusBySize[size ?? "default"]}65 className={cn(66 wrapperVariants({ size }),67 // keyboard only: `focus-within` leaves the ring painted around the pane68 // after every mouse click69 "has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-[var(--pane-highlight)] has-[:focus-visible]:ring-offset-0",70 )}71 >72 <Comp73 data-slot="button"74 data-variant={variant}75 data-size={size}76 className={cn(77 buttonVariants({ variant, size, className }),78 "bg-transparent",79 )}80 {...props}81 />82 </Pane>83 );84}8586export { Button, buttonVariants };
What it pulls in
npm packages
Other registry items
Files it writes
More from pane
All 25 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| badgebadge | pane | Components | Free | 2 deps | |
| cardcard | pane | Components | Free | no deps | |
| dialogdialog | pane | Components | Free | 2 deps | |
| inputinput | pane | Components | Free | no deps | |
| panepane | pane | Components | Free | 1 dep | |
| sheetsheet | pane | Components | Free | 3 deps | |
| switchswitch | pane | Components | Free | 2 deps | |
| tabstabs | pane | Components | Free | 2 deps |
