Run the CLI
Use the CLI to add the component to your project.
A radio button component for selecting a single option from a list.
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { ZardRadioComponent } from '../radio.component';
@Component({
selector: 'z-demo-radio-default',
imports: [ZardRadioComponent, FormsModule],
standalone: true,
template: `
<div class="flex flex-col gap-3">
<span z-radio name="option" [(ngModel)]="selected" value="default">Default</span>
<span z-radio name="option" [(ngModel)]="selected" value="comfortable">Comfortable</span>
<span z-radio name="option" [(ngModel)]="selected" value="compact">Compact</span>
</div>
`,
})
export class ZardDemoRadioDefaultComponent {
selected = 'default';
}
Use the CLI to add the component to your project.
Create the component directory structure and add the following files to your project.
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { ZardRadioComponent } from '../radio.component';
@Component({
selector: 'z-demo-radio-default',
imports: [ZardRadioComponent, FormsModule],
standalone: true,
template: `
<div class="flex flex-col gap-3">
<span z-radio name="option" [(ngModel)]="selected" value="default">Default</span>
<span z-radio name="option" [(ngModel)]="selected" value="comfortable">Comfortable</span>
<span z-radio name="option" [(ngModel)]="selected" value="compact">Compact</span>
</div>
`,
})
export class ZardDemoRadioDefaultComponent {
selected = 'default';
}
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { ZardRadioComponent } from '../radio.component';
@Component({
selector: 'z-demo-radio-disabled',
imports: [ZardRadioComponent, FormsModule],
standalone: true,
template: `
<span z-radio name="radio" [(ngModel)]="val" value="a" [disabled]="true">Disabled</span>
<span z-radio name="radio" [(ngModel)]="val" value="b" [disabled]="true">Disabled</span>
`,
})
export class ZardDemoRadioDisabledComponent {
val = 'a';
}