GUILD OF GLEKS UIv21.4.4

gog-checkbox

Checkbox

A form-ready checkbox with five sizes, an indeterminate state, and full ControlValueAccessor support for Angular Forms.

Overview

Import the component and drop it into a template.

typescript
import { CheckboxComponent } from '@guildofgleks/ui';

@Component({
  // ...
  imports: [CheckboxComponent],
})

Basic usage — a labeled checkbox bound with [(checked)]:

<gog-checkbox label="I agree" [(checked)]="agreed" />

Examples

Sizes

Five size steps, from xsm to slg.

@for (sizeOption of sizes; track sizeOption) {
  <gog-checkbox [size]="sizeOption" [label]="sizeOption" [checked]="true" />
}

Indeterminate — select all

indeterminate is purely presentational: a dash instead of the checkmark, plus aria-checked="mixed". Drive it yourself from the state of a group, as a "select all" checkbox does here.

<gog-checkbox
  label="Select all"
  [checked]="allChecked()"
  [indeterminate]="someChecked() && !allChecked()"
  (checkedChange)="setAll($event)"
/>

@for (item of subscriptions(); track item.id) {
  <gog-checkbox
    [label]="item.label"
    [checked]="item.checked"
    (checkedChange)="setOne(item.id, $event)"
  />
}

Disabled

Disabled blocks toggling in every check state.

<gog-checkbox label="Disabled, unchecked" [disabled]="true" />
<gog-checkbox label="Disabled, checked" [checked]="true" [disabled]="true" />
<gog-checkbox label="Disabled, indeterminate" [indeterminate]="true" [disabled]="true" />

No visible label

Without label, set ariaLabel so the checkbox still has an accessible name — for example a row-selection checkbox in a table.

<gog-checkbox ariaLabel="Select row" [(checked)]="agreed" />

Full width

Stretches the row to fill its container; wrapped here in a narrower box to show it.

<gog-checkbox label="Full width row" [fullWidth]="true" />

Reactive Forms

Works as a ControlValueAccessor — wire it to a FormControl with [formControl] or formControlName instead of [(checked)]. Don't bind both to the same instance.

Control value: false

<gog-checkbox label="Subscribe" [formControl]="control" />

Custom check icon

Project an <ng-template gogCheckboxIcon> to replace the checkmark drawn inside the box. This replaces the checkIconTemplate input, deprecated in 21.3.0 and removed in 21.5.0 — both work meanwhile, and the projected slot wins when a call site has both.

<gog-checkbox label="Custom mark" [checked]="true">
  <ng-template gogCheckboxIcon>
    <gog-icon name="close" />
  </ng-template>
</gog-checkbox>

API Reference

Inputs

NameTypeDefaultDescription
checkedboolean (model)falseTwo-way bindable checked state via [(checked)]. Also the state Angular Forms drives through writeValue/registerOnChange when used with formControlName/[formControl]/ngModel — don't wire both to the same instance.
labelstring''Visible label rendered next to the box. Takes priority over ariaLabel when present.
ariaLabelstring''Accessible name used only when label is empty — falls back onto the native input.
size'xsm' | 'sm' | 'md' | 'lg' | 'slg'GOG_CONFIG.control.size ?? 'md'Box, label, and check-icon size.
indeterminatebooleanfalseRenders a dash instead of the checkmark and sets aria-checked="mixed", regardless of checked. Purely presentational — does not affect the underlying checked value.
disabledbooleanfalseSets the native disabled attribute and blocks toggling. A FormControl.disable() has the same effect via setDisabledState.
fullWidthbooleanfalseStretches the checkbox row to fill its container.
checkIconTemplateTemplateRef<unknown> | nullnullDeprecated since 21.3.0, removed in 21.5.0 — project an <ng-template gogCheckboxIcon> instead. Still works, and the projected slot wins when both are present.

Content slots

SlotDescription
<ng-template gogCheckboxIcon> Replaces the checkmark drawn inside the box when checked. Wins over the deprecated checkIconTemplate input.

Styling Tokens

Every CSS custom property the checkbox paints with. Override any of them — on a single instance, a subtree, or a theme — to restyle it. See the Theming guide for the full token-layering model, or the Theme Generator to tweak these live.

TokenDescription
--gog-checkbox-gapGap between box and label.
--gog-checkbox-radiusBox corner radius.
--gog-checkbox-border-width / -style / -colorBox border.
--gog-checkbox-bg / -checked-bg / -checked-borderBox background, unchecked and checked.
--gog-checkbox-icon-colorCheckmark color.
--gog-checkbox-label-colorLabel text color.
--gog-checkbox-focus-ring / -focus-ring-width / -focus-ring-offsetKeyboard focus ring.