button
adrianub/buttonFreeComponent
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/button.jsonSource
1import type { VariantProps } from 'class-variance-authority'23import { computed, Directive, input } from '@angular/core'45import { cva } from 'class-variance-authority'6import { cn } from '~/lib/utils'78export const buttonVariants = cva(9 'inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50',10 {11 variants: {12 variant: {13 default:14 'bg-primary text-primary-foreground shadow hover:bg-primary/90',15 destructive:16 'bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90',17 outline:18 'border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground',19 secondary:20 'bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80',21 ghost: 'hover:bg-accent hover:text-accent-foreground',22 link: 'text-primary underline-offset-4 hover:underline',23 },24 size: {25 default: 'h-9 px-4 py-2',26 sm: 'h-8 rounded-md px-3 text-xs',27 lg: 'h-10 rounded-md px-8',28 icon: 'h-9 w-9',29 },30 },31 defaultVariants: {32 variant: 'default',33 size: 'default',34 },35 },36)3738type ButtonProps = VariantProps<typeof buttonVariants>3940export type UbButtonSize = NonNullable<ButtonProps['size']>41export type UbButtonVariant = NonNullable<ButtonProps['variant']>4243@Directive({44 selector: '[ubButton]',45 standalone: true,46 host: {47 '[class]': 'computedClass()',48 },49})50export class UbButtonDirective {51 readonly class = input<string>()5253 readonly variant = input<UbButtonVariant>('default')5455 readonly size = input<UbButtonSize>('default')5657 protected computedClass = computed(() =>58 cn(59 buttonVariants({60 variant: this.variant(),61 size: this.size(),62 class: this.class(),63 }),64 ),65 )66}
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 | |
| cardcard | adrianub | Components | Free | no deps | |
| collapsiblecollapsible | adrianub | Components | Free | 1 dep |
