button-group
zard/button-groupFreeComponent
@zard publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by @zard on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.zardui.com/r/button-group.jsonSource
1import {2 ChangeDetectionStrategy,3 Component,4 computed,5 Directive,6 inject,7 input,8 ViewEncapsulation,9} from '@angular/core';1011import { type ClassValue } from 'clsx';1213import { mergeClasses } from '@/shared/utils/merge-classes';1415import {16 buttonGroupDividerVariants,17 buttonGroupTextVariants,18 buttonGroupVariants,19 type ZardButtonGroupVariants,20} from './button-group.variants';21import { ZardSeparatorComponent } from '../separator/separator.component';22import { type ZardSeparatorVariants } from '../separator/separator.variants';2324@Component({25 selector: 'z-button-group',26 template: `27 <ng-content />28 `,29 changeDetection: ChangeDetectionStrategy.OnPush,30 encapsulation: ViewEncapsulation.None,31 host: {32 role: 'group',33 'data-slot': 'button-group',34 '[class]': 'classes()',35 '[attr.data-orientation]': 'zOrientation()',36 '[attr.aria-orientation]': 'zOrientation()',37 },38 exportAs: 'zButtonGroup',39})40export class ZardButtonGroupComponent {41 readonly zOrientation = input<Required<ZardButtonGroupVariants>['zOrientation']>('horizontal');42 readonly class = input<ClassValue>('');4344 protected readonly classes = computed(() =>45 mergeClasses(46 buttonGroupVariants({47 zOrientation: this.zOrientation(),48 }),49 this.class(),50 ),51 );52}5354@Component({55 selector: 'z-button-group-divider',56 imports: [ZardSeparatorComponent],57 template: `58 <z-separator [class]="classes()" aria-hidden="true" [zOrientation]="orientation()" />59 `,60 changeDetection: ChangeDetectionStrategy.OnPush,61 encapsulation: ViewEncapsulation.None,62 host: {63 class: 'contents',64 'data-slot': 'button-group-separator',65 },66 exportAs: 'zButtonGroupDivider',67})68export class ZardButtonGroupDividerComponent {69 readonly zOrientation = input<ZardSeparatorVariants['zOrientation']>(null);70 readonly class = input<ClassValue>('');7172 private readonly parent = inject(ZardButtonGroupComponent, {73 optional: true,74 host: true,75 });7677 protected readonly orientation = computed(() => {78 if (!this.parent || typeof this.zOrientation() === 'string') {79 return this.zOrientation();80 }8182 return this.parent.zOrientation() === 'vertical' ? 'horizontal' : 'vertical';83 });8485 protected readonly classes = computed(() =>86 mergeClasses(87 buttonGroupDividerVariants({88 zOrientation: this.orientation(),89 }),90 this.class(),91 ),92 );93}9495@Directive({96 selector: '[z-button-group-text]',97 host: {98// … truncated
What it pulls in
Other registry items
Files it writes
More from @zard
All 49 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | @zard | Components | Free | no deps · 5 files | |
| alertalert | @zard | Components | Free | no deps · 3 files | |
| alert-dialogalert-dialog | @zard | Components | Free | no deps · 5 files | |
| avataravatar | @zard | Components | Free | no deps · 4 files | |
| badgebadge | @zard | Components | Free | no deps · 3 files | |
| breadcrumbbreadcrumb | @zard | Components | Free | no deps · 4 files | |
| buttonbutton | @zard | Components | Free | no deps · 3 files | |
| calendarcalendar | @zard | Components | Free | no deps · 7 files |
