Checkbox

A native checkbox that draws itself, in the look of the app's style.

FormsExperimental

Usage

import { Component, ViewEncapsulation, signal } from '@angular/core';import { FormField, form } from '@angular/forms/signals';import {  ScCheckbox,  ScField,  ScFieldContentWrapper,  ScFieldDescription,  ScFieldGroup,  ScFieldTitle,  ScLabel,} from '@semantic-components/ui';
/** A checkbox beside its label, with a description, disabled, and in a card label. */@Component({  selector: 'app-checkbox-usage-demo',  imports: [    FormField,    ScCheckbox,    ScField,    ScFieldContentWrapper,    ScFieldDescription,    ScFieldGroup,    ScFieldTitle,    ScLabel,  ],  template: `    <div scFieldGroup class="max-w-sm">      <div scField orientation="horizontal">        <input scCheckbox [formField]="termsForm.terms" />        <label scLabel>Accept terms and conditions</label>      </div>      <div scField orientation="horizontal">        <input scCheckbox [formField]="termsForm.agreed" />        <label scLabel>Accept terms and conditions</label>        <p scFieldDescription>          By clicking this checkbox, you agree to the terms.        </p>      </div>      <div scField orientation="horizontal">        <input scCheckbox disabled />        <label scLabel>Enable notifications</label>      </div>      <label scLabel>        <div scField orientation="horizontal">          <input scCheckbox [formField]="termsForm.notifications" />          <div scFieldContentWrapper>            <div scFieldTitle>Enable notifications</div>            <p scFieldDescription>              You can enable or disable notifications at any time.            </p>          </div>        </div>      </label>    </div>  `,  host: { class: 'flex w-full justify-center' },  encapsulation: ViewEncapsulation.None,})export class CheckboxUsageDemo {  private readonly termsForm = form(    signal({ terms: false, agreed: true, notifications: false }),  );}

Anatomy

A native checkbox input that draws its own box and mark: alone (a table row), or in a horizontal field beside its text — the field is the label, a label is inside the field, or the field is inside a label (a choice card: the whole card clicks). A [formField] or [(checked)] binds it.

import { ScCheckbox, ScField, ScFieldContentWrapper, ScFieldDescription, ScFieldTitle, ScLabel } from '@semantic-components/ui';
<!-- The field is the label: the control and its text --><label scField orientation="horizontal">  <input scCheckbox [formField]="…" />  …</label>
<!-- A label inside the field, with a description --><div scField orientation="horizontal">  <input scCheckbox [formField]="…" />  <label scLabel>…</label>  <p scFieldDescription>…</p></div>
<!-- The field inside a label: a choice card, the whole card clicks --><label scLabel>  <div scField orientation="horizontal">    <input scCheckbox [formField]="…" />    <div scFieldContentWrapper>      <div scFieldTitle>…</div>      <p scFieldDescription>…</p>    </div>  </div></label>

Accessibility

  • A native checkbox: Tab reaches it, Space toggles it; its box and mark are its own (CSS), nothing extra for screen readers.
  • Name it by its text: a label round both (label scField orientation="horizontal"), or a scLabel in a div field; a checkbox with no text (a table row) by aria-label, alone — no field around it: a field is a label, and a label with no text is an empty form label to checkers such as WAVE.
  • Indeterminate is announced as mixed; a description is read with its checkbox; invalid once touched (aria-invalid, from Signal Forms).

Examples

Description

By clicking this checkbox, you agree to the terms and conditions.

import { Component, ViewEncapsulation, signal } from '@angular/core';import { FormField, form } from '@angular/forms/signals';import {  ScCheckbox,  ScField,  ScFieldDescription,  ScLabel,} from '@semantic-components/ui';
/** A description under the label, read with the checkbox. */

Group

Show these items on the desktop:

Select the items you want to show on the desktop.

import { Component, ViewEncapsulation, signal } from '@angular/core';import { FormField, form } from '@angular/forms/signals';import {  ScCheckbox,  ScField,  ScFieldDescription,  ScFieldGroup,  ScFieldset,  ScLegend,} from '@semantic-components/ui';

Disabled

import { Component, ViewEncapsulation } from '@angular/core';import {  ScCheckbox,  ScField,  ScFieldGroup,  ScLabel,} from '@semantic-components/ui';
/** Disabled, unchecked and checked: dimmed, out of the Tab order. */@Component({

Invalid

import { Component, ViewEncapsulation, signal } from '@angular/core';import { FormField, form, required } from '@angular/forms/signals';import { ScCheckbox, ScField, ScLabel } from '@semantic-components/ui';
/** A required checkbox, touched and not checked: marked invalid (Signal Forms). */@Component({  selector: 'app-invalid-checkbox-demo',  imports: [FormField, ScCheckbox, ScLabel, ScField],  template: `    <div scField orientation="horizontal" class="w-56">

Table

NameEmailRole
Sarah Chen[email protected]Admin
Marcus Rodriguez[email protected]User
Priya Patel[email protected]User
David Kim[email protected]Editor
import { Component, ViewEncapsulation, computed, signal } from '@angular/core';import {  ScCheckbox,  ScTable,  ScTableBody,  ScTableCell,  ScTableContainer,  ScTableHeader,  ScTableHeaderCell,  ScTableRow,

Indeterminate

import { Component, ViewEncapsulation, computed, signal } from '@angular/core';import { ScCheckbox, ScField, ScFieldGroup } from '@semantic-components/ui';
/** A "select all" over a few items: a minus when only some are checked. */@Component({  selector: 'app-indeterminate-checkbox-demo',  imports: [ScCheckbox, ScFieldGroup, ScField],  template: `    <div scFieldGroup class="w-56 gap-3">      <label scField orientation="horizontal">

Signal Forms

{
  "newsletter": true,
  "marketing": false
}
import { JsonPipe } from '@angular/common';import { Component, ViewEncapsulation, signal } from '@angular/core';import { FormField, form } from '@angular/forms/signals';import {  ScCheckbox,  ScField,  ScFieldGroup,  ScFrame,  ScLabel,} from '@semantic-components/ui';

Form

Notification Preferences

import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScCard,  ScCardBody,  ScCardHeader,  ScCardTitle,  ScCheckbox,  ScField,  ScFieldGroup,  ScLabel,

Custom theme

import { Component, ViewEncapsulation, signal } from '@angular/core';import { FormField, form } from '@angular/forms/signals';import { ScCheckbox, ScField, ScLabel } from '@semantic-components/ui';
/** The app's colours, changed on a part of the page: --primary and --primary-foreground. */@Component({  selector: 'app-custom-theme-checkbox-demo',  imports: [FormField, ScCheckbox, ScLabel, ScField],  template: `    <div

Custom mark

Favorite colors
import { Component, ViewEncapsulation, signal } from '@angular/core';import { FormField, form } from '@angular/forms/signals';import {  ScCheckbox,  ScField,  ScFieldGroup,  ScFieldset,  ScLegend,} from '@semantic-components/ui';

RTL

بالنقر على هذا المربع، فإنك توافق على الشروط.

import { Dir } from '@angular/cdk/bidi';import { Component, LOCALE_ID, ViewEncapsulation, signal } from '@angular/core';import { FormField, form } from '@angular/forms/signals';import {  ScCheckbox,  ScField,  ScFieldContentWrapper,  ScFieldDescription,  ScFieldGroup,  ScFieldTitle,

API reference

Each part takes class, merged over the style (cn: a later class wins).

PartSelectorDescription
ScCheckboxinput[scCheckbox] A native checkbox in the style's look, its check or minus drawn by itself: checked (two-way, or a [formField]); indeterminate; invalid once touched.