badge
adrianub/badgeFreeComponent
adrianub publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by adrianub on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://ui.adrianub.dev/r/styles/new-york/badge.jsonSource
1import type { VariantProps } from 'class-variance-authority'2import { computed, Directive, input } from '@angular/core'34import { cva } from 'class-variance-authority'5import { cn } from '~/lib/utils'67export const badgeVariants = cva(8 'inline-flex items-center rounded-md 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',9 {10 variants: {11 variant: {12 default:13 'border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80',14 secondary:15 'border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80',16 destructive:17 'border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80',18 outline: 'text-foreground',19 },20 },21 defaultVariants: {22 variant: 'default',23 },24 },25)2627type BadgeProps = VariantProps<typeof badgeVariants>2829export type UbBadgeVariant = NonNullable<BadgeProps['variant']>3031@Directive({32 selector: '[ubBadge]',33 standalone: true,34 host: {35 '[class]': 'computedClass()',36 },37})38export class UbBadgeDirective {39 readonly class = input<string>()40 readonly variant = input<UbBadgeVariant>('default')4142 protected computedClass = computed(() =>43 cn(badgeVariants({ variant: this.variant(), class: this.class() })),44 )45}
Files it writes
More from adrianub
All 23 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | adrianub | Components | Free | 1 dep | |
| alertalert | adrianub | Components | Free | no deps | |
| aspect-ratioaspect-ratio | adrianub | Components | Free | 1 dep | |
| avataravatar | adrianub | Components | Free | 1 dep | |
| breadcrumbbreadcrumb | adrianub | Components | Free | no deps | |
| buttonbutton | adrianub | Components | Free | no deps | |
| cardcard | adrianub | Components | Free | no deps | |
| collapsiblecollapsible | adrianub | Components | Free | 1 dep |
