Badge
weekendsuperhero-io-sistine/badgeFreeComponent
Displays a badge or a component that looks like a badge, with the glass material system.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/Weekendsuperhero-io/sistine/main/public/r/badge.jsonSource
1import { cva, type VariantProps } from "class-variance-authority";2import { Slot as SlotPrimitive } from "radix-ui";3import type * as React from "react";45import { type MaterialAxisProps, type MaterialProps, materialSurface, splitAxisProps } from "@/lib/material";6import { cn } from "@/lib/utils";78/* Variant classes carry BEHAVIOR only (text, hover, destructive chrome); the SURFACE comes from9 materialSurface (the material system) — see SURFACE_ROLE below for how semantic variants ride it. */10const badgeVariants = cva(11 "inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border px-2.5 py-0.5 text-xs font-semibold whitespace-nowrap transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3",12 {13 variants: {14 variant: {15 default: "border-transparent bg-primary text-primary-foreground shadow [a&]:hover:bg-primary/80",16 glass: "text-foreground",17 secondary: "text-muted-foreground",18 destructive: "border border-destructive/50 text-destructive",19 outline: "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",20 ghost: "border-transparent [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",21 link: "border-transparent text-primary underline-offset-4 [a&]:hover:underline",22 },23 },24 defaultVariants: {25 variant: "glass",26 },27 },28);2930/* Each semantic variant's surface role (null = no glass surface — the variant styles itself, e.g.31 default/outline/ghost/link; destructive rides a borderless glass surface, its red border its own). */32const SURFACE_ROLE: Record<string, MaterialProps | null> = {33 glass: {34 border: true,35 },36 secondary: {37 border: true,38 },39 destructive: {40 size: "sm",41 },42 default: null,43 outline: null,44 ghost: null,45 link: null,46};4748export interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement>, VariantProps<typeof badgeVariants>, MaterialAxisProps {49 asChild?: boolean;50}5152function Badge({ className, variant, asChild = false, ...props }: BadgeProps) {53 const Comp = asChild ? SlotPrimitive.Slot : "span";5455 const [axes, rest] = splitAxisProps(props);56 const m = materialSurface(SURFACE_ROLE[variant ?? "glass"] ?? null, axes);5758 return (59 <Comp60 data-slot="badge"61// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from weekendsuperhero-io/sistine
All 71 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | weekendsuperhero-io/sistine | Components | Free | 5 deps · 4 files | |
| Alertalert | weekendsuperhero-io/sistine | Components | Free | 3 deps · 4 files | |
| Alert Dialogalert-dialog | weekendsuperhero-io/sistine | Components | Free | 4 deps · 4 files | |
| Auto Foregroundauto-foreground | weekendsuperhero-io/sistine | Components | Free | no deps | |
| Avataravatar | weekendsuperhero-io/sistine | Components | Free | 4 deps · 4 files | |
| Breadcrumbbreadcrumb | weekendsuperhero-io/sistine | Components | Free | 5 deps · 4 files | |
| Buttonbutton | weekendsuperhero-io/sistine | Components | Free | 4 deps · 4 files | |
| Button Groupbutton-group | weekendsuperhero-io/sistine | Components | Free | 4 deps · 4 files |
