Skip to content
Myr

button.tsx

This file

Path

apps/web/src/components/ui/button.tsx

55 lines · 2.8 KiB · TypeScript

Last changed by

Draw text, controls, prose and code from one set of tokensoscabrielbefore adoption60f862e

History of this file

Take it

The walk stopped after 200 commits: lines older than 678c8b8 point at it.

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 1–5why, one step back
1import { Button as ButtonPrimitive } from "@base-ui/react/button";
2import { cva, type VariantProps } from "class-variance-authority";3import { cn } from "cn";45const buttonVariants = cva(

Draw text, controls, prose and code from one set of tokensoscabrielbefore adoption60f862e

line 6why, one step back
6 "group/button focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 text-ui inline-flex shrink-0 items-center justify-center rounded-none border border-transparent bg-clip-padding font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:ring-1 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:ring-1 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 7–11why, one step back
7 {
8 variants: {9 variant: {10 default: "bg-primary text-primary-foreground hover:bg-primary/80",11 outline:

Draw text, controls, prose and code from one set of tokensoscabrielbefore adoption60f862e

line 12why, one step back
12 "border-input bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground",

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 13–23why, one step back
13 secondary:
14 "bg-secondary text-secondary-foreground aria-expanded:bg-secondary aria-expanded:text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)]",15 ghost:16 "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",17 destructive:18 "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",19 link: "text-primary underline-offset-4 hover:underline",20 },21 size: {22 default:23 "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",

Draw text, controls, prose and code from one set of tokensoscabrielbefore adoption60f862e

line 24why, one step back
24 xs: "text-label h-6 gap-1 rounded-none px-2 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 25–55why, one step back
25 sm: "h-7 gap-1 rounded-none px-2.5 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
26 lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",27 icon: "size-8",28 "icon-xs": "size-6 rounded-none [&_svg:not([class*='size-'])]:size-3",29 "icon-sm": "size-7 rounded-none",30 "icon-lg": "size-9",31 },32 },33 defaultVariants: {34 variant: "default",35 size: "default",36 },37 }38);3940function Button({41 className,42 variant = "default",43 size = "default",44 ...props45}: ButtonPrimitive.Props & VariantProps<typeof buttonVariants>) {46 return (47 <ButtonPrimitive48 data-slot="button"49 className={cn(buttonVariants({ variant, size, className }))}50 {...props}51 />52 );53}5455export { Button, buttonVariants };