Checkbox
Components for capturing boolean or multiple-choice selections from a user. Use `RzCheckbox` for a single true/false input and `RzCheckboxGroup` for selecting multiple options from a list. A standalone checkbox for a single boolean value, composed with `Field` and `FieldLabel` for proper form structure and accessibility. Add a `FieldDescription` to provide more context for the checkbox. Use `RzCheckboxGroup` within an `Field` to bind multiple options to a collection. This example binds to the `TaskNotifications` list on the model. Create large, clickable "choice cards" by placing rich content inside an `RzCheckboxGroupItem`. The entire item acts as a label for the checkbox.<EditForm Model="@_model">
<Field Orientation="FieldOrientation.Horizontal">
<RzCheckbox For="@(() => _model.AcceptTerms)" />
<FieldLabel For="@(() => _model.AcceptTerms)" class="font-normal">Accept terms and conditions</FieldLabel>
</Field>
</EditForm><Field Orientation="FieldOrientation.Horizontal" class="items-start">
<RzInputCheckbox For="@(() => _model.AcceptTerms)" />
<RzFieldGroup>
<Field>
<FieldLabel For="@(() => _model.AcceptTerms)" class="font-normal">Accept terms and conditions</FieldLabel>
<FieldDescription>
By clicking this checkbox, you agree to the terms and conditions.
</FieldDescription>
</Field>
</RzFieldGroup>
</Field><Field>
<FieldLabel For="@(() => _model.TaskNotifications)">Tasks</FieldLabel>
<FieldDescription>
Get notified when tasks you've created have updates.
<RzLink Href="#">Manage tasks</RzLink>
</FieldDescription>
<RzCheckboxGroup For="@(() => _model.TaskNotifications)" class="mt-2">
<RzCheckboxGroupItem TValue="string" Value="@("push")">
<span class="text-sm">Push notifications</span>
</RzCheckboxGroupItem>
<RzCheckboxGroupItem TValue="string" Value="@("email")">
<span class="text-sm">Email notifications</span>
</RzCheckboxGroupItem>
</RzCheckboxGroup>
</Field><RzCheckboxGroup For="@(() => _model.NotificationPreferences)">
<RzCheckboxGroupItem TValue="string" Value="@("enable-notifications")">
<div class="flex w-full cursor-pointer items-start gap-3 rounded-lg border p-3 has-[[aria-checked=true]]:border-primary has-[[aria-checked=true]]:bg-accent/50 hover:bg-accent/50">
<div class="grid gap-1.5 font-normal">
<p class="text-sm font-medium leading-none">
Enable notifications
</p>
<p class="text-sm text-muted-foreground">
You can enable or disable notifications at any time.
</p>
</div>
</div>
</RzCheckboxGroupItem>
</RzCheckboxGroup>