Checkbox
Native checkbox styling with field ARIA wiring and invalid state integration.
Use the directive on native checkbox inputs and pair it with kui-field for label, hint, and error wiring.
import { KuiCheckbox, KuiField } from '@kikita-labs/ui';Keep a native label around the checkbox for option text.
<kui-field label="Notifications" hint="Control product and release emails">
<label class="checkbox-option">
<input kuiCheckbox type="checkbox" [checked]="receiveUpdates()" />
<span>Receive updates</span>
</label>
</kui-field>Match checkbox size to surrounding field density and text scale; disabled and invalid follow native and field-driven state.
<div class="checkbox-size-example">
<label class="checkbox-option">
<input kuiCheckbox type="checkbox" size="xs" />
<span>Extra small</span>
</label>
<label class="checkbox-option">
<input kuiCheckbox type="checkbox" size="sm" checked />
<span>Small</span>
</label>
<label class="checkbox-option">
<input kuiCheckbox type="checkbox" size="md" checked />
<span>Medium</span>
</label>
<label class="checkbox-option">
<input kuiCheckbox type="checkbox" size="lg" />
<span>Large</span>
</label>
<label class="checkbox-option">
<input kuiCheckbox type="checkbox" disabled />
<span>Disabled</span>
</label>
<label class="checkbox-option">
<input kuiCheckbox type="checkbox" disabled checked />
<span>Disabled and checked</span>
</label>
<label class="checkbox-option">
<input kuiCheckbox type="checkbox" invalid />
<span>Invalid</span>
</label>
</div>Bind Angular Signal Forms with [formField] on the same native checkbox; the field gates the invalid state until the control is touched and exposes aria-required.
<kui-field label="Notifications" hint="Control product and release emails">
<label>
<input kuiCheckbox type="checkbox" [formField]="settingsForm.receiveUpdates" />
Receive updates
</label>
</kui-field> For custom checkbox-like components prefer the Angular Signal Forms FormCheckboxControl contract over a ControlValueAccessor.
Set defaults.checkbox once for the application or for a subtree. Each option resolves as local input > defaults.checkbox.<option> > built-in default.
import { provideKikitaUi } from '@kikita-labs/ui';
export const appConfig: ApplicationConfig = {
providers: [
provideKikitaUi({
defaults: {
checkbox: {
/* options below */
},
},
}),
],
};| Name | Type | Default | Description |
|---|---|---|---|
| size | 'xs' | 'sm' | 'md' | 'lg' | — | Component size. Takes precedence over the global defaults.size. |
Inputs verified against @kikita-labs/ui v2.0.0 public typings.
| Name | Type | Default | Description |
|---|---|---|---|
| size | 'xs' | 'sm' | 'md' | 'lg' | 'md' | Checkbox size mapped to Kikita checkbox tokens. |
| invalid | boolean | false | Marks the checkbox invalid outside a field error state. |
| id | string | undefined | - | Explicit id override. Inside kui-field, the field id is used when omitted. |
| checked | boolean | false | Native checked state. Not a directive input; bind it directly on the input element. |
| disabled | boolean | false | Native disabled state. Not a directive input; bind it directly on the input element. |
| indeterminate | boolean | false | Native DOM property, not an HTML attribute or directive input. Set it imperatively on the element to show the dash-mark state; .kui-checkbox styles :indeterminate. |
Checkbox keeps native input semantics and adds field-described state when used inside kui-field.
- Use a native
labelfor the checkbox option text. - Use
kui-fieldfor group label, hint, error, and described-by wiring. - Use native checked and disabled states; do not replace the input with a custom role.
- Use
invalidonly when the checkbox is outside a field error state. - Inside
kui-fieldthe control receives the field id andaria-describedby, and an explicitrequiredon the field or a Signal Formsrequired(...)validator is exposed asaria-required. - Focus is a solid 2px outline in
--kui-color-focus. Disabled checkboxes dim to the shared 0.5 opacity, and checked and indeterminate states keep system colours in forced colors mode. .kui-checkboxstyles the native:indeterminatepseudo-class (a dash mark instead of a checkmark).indeterminateis a DOM property, not an HTML attribute, so set it imperatively on the element.
Consumer-visible changes of @kikita-labs/ui 2.0 for Checkbox.
- The class is
KuiCheckbox(it wasKuiCheckboxDirective); the selector and inputs are unchanged.ng update @kikita-labs/uirenames the import. - The size comes from the parent field, then
defaults.checkbox.size, then the globaldefaults.size. - The control reads its host id, invalid state and
aria-describedbyfrom one internal helper and, insidekui-field, no longer pulls the whole field into your bundle. - The focus ring is a 2px outline, disabled controls dim to the shared 0.5 opacity, and checked and indeterminate states have forced-colors styling.