toggle
adrianub/toggleFreeComponent
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/toggle.jsonSource
1import type { VariantProps } from 'class-variance-authority'2import { computed, Directive, input } from '@angular/core'3import { RdxToggleDirective } from '@radix-ng/primitives/toggle'4import { cva } from 'class-variance-authority'5import { cn } from '~/lib/utils'67const toggleVariants = cva(8 'inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',9 {10 variants: {11 variant: {12 default: 'bg-transparent',13 outline:14 'border border-input bg-transparent shadow-sm hover:bg-accent hover:text-accent-foreground',15 },16 size: {17 default: 'h-9 px-2 min-w-9',18 sm: 'h-8 px-1.5 min-w-8',19 lg: 'h-10 px-2.5 min-w-10',20 },21 },22 defaultVariants: {23 variant: 'default',24 size: 'default',25 },26 },27)2829@Directive({30 standalone: true,31 selector: 'button[ubToggle]',32 host: {33 '[class]': 'computedClass()',34 },35 hostDirectives: [RdxToggleDirective],36})37export class UbToggleDirective {38 variant = input<VariantProps<typeof toggleVariants>['variant']>()39 size = input<VariantProps<typeof toggleVariants>['size']>()40 class = input<string>()41 computedClass = computed(() => cn(42 toggleVariants({43 variant: this.variant(),44 size: this.size(),45 className: this.class(),46 }),47 ))48}
What it pulls in
npm packages
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 | |
| badgebadge | adrianub | Components | Free | no deps | |
| breadcrumbbreadcrumb | adrianub | Components | Free | no deps | |
| buttonbutton | adrianub | Components | Free | no deps | |
| cardcard | adrianub | Components | Free | no deps |
