Checkbox
vig-checkbox
import { Checkbox } from '@vigdx/ui/checkbox';Basic
[(value)] to a boolean signal. The whole label is clickable; hint adds help text below it.
One email every Monday, unsubscribe at any time.
Remember: true · Digest: false
States
disabled greys out box and label. readonly keeps the box focusable but ignores clicks and Space. required adds an asterisk to the label.
Error
touched and invalid ; the box turns red and the message appears below. errorMessages replaces the built-in text for each error kind.
Hidden label
hideLabel hides the label text but keeps it as the accessible name. Make each label unique, for example by including the row name.
| Event | Push | |
|---|---|---|
| New comment | ||
| Mention | ||
| Weekly report |
Reactive Forms
VigValueAccessor next to the component to use formControlName , [formControl] or ngModel . Use Validators.requiredTrue for a box that must be checked.
Signal Forms
vig-checkbox implements FormValueControl<boolean> . Signal Forms' required() treats false as empty, so it makes the box mandatory.
Valid: no
Styling hooks
Internal elements carry a stable data-part and the component's data-scope; both are public API, so removing one is a breaking change. Select a part by both, e.g. [data-scope="checkbox"][data-part="root"] { … }: the pair stays within this component when kit components nest, and also reaches parts in overlay panels, which render outside the host. State is exposed through aria-* and, where listed, a data-state; literal values are checked by the API gate, values computed from the component's state follow its documented types. Other data-* attributes listed below (such as data-opening while an overlay animates) are API too. See Customizing.
Scope: [data-scope="checkbox"]
| Part | Element | data-state |
|---|---|---|
root | <label> wrapping box and text. | checked, unchecked, indeterminate |
control | — | |
input | — | |
indicator | — | |
label | — | |
hint | vig-hint (a display: contents host; style its text part). | — |
disabled-reason | vig-hint with the disabled reason ( display: contents ). | — |
error | vig-field-error (a display: contents host; style its message part). | — |
Accessibility
- A native
<input type="checkbox">inside its<label>: Space toggles it and the label text is its accessible name. labelis required. WithhideLabelthe text is visually hidden but still read out, so keep it descriptive.- Hint, disabled reason and error are linked through
aria-describedby; a touched, invalid box setsaria-invalid="true". - Native checkboxes have no read-only state, so
readonlyreverts each change and setsaria-readonly="true"; tell users why the box cannot be changed, for example in thehint. indeterminatesets the native mixed state, announced as "mixed" or "partially checked"; the next click clears it.- The box scales with the font size (1.25em) and shows a focus ring on keyboard focus.
API
Checkbox
vig-checkbox| Name | Type | Default | Description |
|---|---|---|---|
dirty | boolean | false | — |
disabled | boolean | false | — |
disabledReasons | readonly WithOptionalFieldTree<DisabledReason>[] | [] | — |
errorMessages | Record<string, string> | — | — |
errors | readonly ValidationError.WithOptionalFieldTree[] | [] | — |
hidden | boolean | false | — |
hideLabel | boolean | false | Keeps the label for assistive tech only, e.g. inside a table cell or a matrix. |
hint | string | undefined | undefined | — |
indeterminate | boolean | false | Mixed state, e.g. a "select all" whose items are partly selected. Sets
the native |
invalid | boolean | false | — |
label | string | — | — |
name | string | '' | — |
pending | boolean | false | — |
readonly | boolean | false | — |
required | boolean | false | — |
touched | boolean | false | — |
value | boolean | false | — |
| Name | Payload | Description |
|---|---|---|
indeterminateChange | boolean | Mixed state, e.g. a "select all" whose items are partly selected. Sets
the native |
touch | void | — |
valueChange | boolean | — |
| Signature | Description |
|---|---|
focus(options?: FocusOptions): void | Moves focus to the control's interactive element (the input, or the
trigger of a popup control). Signal Forms calls it through
|
reset(): void | Returns the control to its pristine look: drops in-progress text, closes
an open popup, clears errors the component raised itself and the
submitted state of |
VigValueAccessor
Bridges the vigdx form fields to Reactive Forms (formControl,
formControlName) and template-driven forms (ngModel). Import it next to
the component; Signal Forms ([formField]) need no accessor.
| Signature | Description |
|---|---|
registerOnChange(fn: (value: unknown) => void): void | — |
registerOnTouched(fn: () => void): void | — |
setDisabledState(disabled: boolean): void | — |
writeValue(value: unknown): void | — |