Badge
docs/badgeFreeComponent
badge component for SolidJS
Live preview
live · rendered by the registry
Rendered by docs on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://solidcn.dev/r/badge.jsonSource
1import { type VariantProps, cva } from "class-variance-authority";2import type { Component, JSX } from "solid-js";3import { splitProps } from "solid-js";4import { cn } from "~/lib/utils";56export const badgeVariants = cva(7 "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",8 {9 variants: {10 variant: {11 default: "border-transparent bg-primary text-primary-foreground hover:bg-primary/80",12 secondary:13 "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",14 destructive:15 "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",16 outline: "text-foreground",17 },18 },19 defaultVariants: {20 variant: "default",21 },22 },23);2425export type BadgeProps = JSX.HTMLAttributes<HTMLDivElement> & VariantProps<typeof badgeVariants>;2627export const Badge: Component<BadgeProps> = (props) => {28 const [local, variants, rest] = splitProps(props, ["class"], ["variant"]);2930 return <div class={cn(badgeVariants(variants), local.class)} {...rest} />;31};
More from docs
All 44 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | docs | Components | Free | no deps | |
| Alert Dialogalert-dialog | docs | Components | Free | no deps | |
| Avataravatar | docs | Components | Free | no deps | |
| Breadcrumbbreadcrumb | docs | Components | Free | no deps | |
| Buttonbutton | docs | Components | Free | no deps | |
| Calendarcalendar | docs | Components | Free | no deps | |
| Cardcard | docs | Components | Free | no deps | |
| Carouselcarousel | docs | Components | Free | no deps |
