Field

A control with its label, description and errors; fields in groups and fieldsets. In the look of the app's style.

FormsExperimental

Usage

import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScButton,  ScCheckbox,  ScField,  ScFieldDescription,  ScFieldGroup,  ScFieldSeparator,  ScFieldset,  ScInput,  ScLabel,  ScLegend,  ScSelect,  ScSelectIcon,  ScSelectItem,  ScSelectItemIndicator,  ScSelectItemText,  ScSelectList,  ScSelectPopup,  ScSelectPortal,  ScSelectTrigger,  ScSelectValue,  ScTextarea,} from '@semantic-components/ui';import { SiCheckIcon, SiChevronDownIcon } from '@semantic-icons/lucide-icons';
@Component({  selector: 'app-field-usage-demo',  imports: [    ScButton,    ScCheckbox,    ScField,    ScFieldDescription,    ScFieldGroup,    ScFieldSeparator,    ScFieldset,    ScInput,    ScLabel,    ScLegend,    ScSelect,    ScSelectIcon,    ScSelectItem,    ScSelectItemIndicator,    ScSelectItemText,    ScSelectList,    ScSelectPopup,    ScSelectPortal,    ScSelectTrigger,    ScSelectValue,    ScTextarea,    SiCheckIcon,    SiChevronDownIcon,  ],  template: `    <div class="w-full max-w-md">      <div scFieldGroup>        <fieldset scFieldset>          <legend scLegend>Payment Method</legend>          <p scFieldDescription>All transactions are secure and encrypted</p>          <div scFieldGroup>            <div scField>              <label scLabel>Name on Card</label>              <input scInput placeholder="Evil Rabbit" />            </div>            <div scField>              <label scLabel>Card Number</label>              <input scInput placeholder="1234 5678 9012 3456" />              <p scFieldDescription>Enter your 16-digit card number</p>            </div>            <div class="grid grid-cols-3 gap-4">              <div scField>                <label scLabel>Month</label>                <div scSelect [(value)]="month" [items]="months">                  <button scSelectTrigger>                    <span scSelectValue placeholder="MM"></span>                    <svg scSelectIcon siChevronDownIcon></svg>                  </button>                  <ng-template scSelectPortal>                    <div scSelectPopup>                      <div scSelectList>                        @for (item of months; track item.value) {                          <div scSelectItem [value]="item.value">                            <span scSelectItemText>{{ item.label }}</span>                            <span scSelectItemIndicator                              ><svg siCheckIcon></svg                            ></span>                          </div>                        }                      </div>                    </div>                  </ng-template>                </div>              </div>              <div scField>                <label scLabel>Year</label>                <div scSelect [(value)]="year" [items]="years">                  <button scSelectTrigger>                    <span scSelectValue placeholder="YYYY"></span>                    <svg scSelectIcon siChevronDownIcon></svg>                  </button>                  <ng-template scSelectPortal>                    <div scSelectPopup>                      <div scSelectList>                        @for (item of years; track item.value) {                          <div scSelectItem [value]="item.value">                            <span scSelectItemText>{{ item.label }}</span>                            <span scSelectItemIndicator                              ><svg siCheckIcon></svg                            ></span>                          </div>                        }                      </div>                    </div>                  </ng-template>                </div>              </div>              <div scField>                <label scLabel>CVV</label>                <input scInput placeholder="123" />              </div>            </div>          </div>        </fieldset>        <div scFieldSeparator></div>        <fieldset scFieldset>          <legend scLegend>Billing Address</legend>          <p scFieldDescription>            The billing address associated with your payment method          </p>          <div scFieldGroup>            <div scField orientation="horizontal">              <input scCheckbox [(checked)]="sameAsShipping" />              <label scLabel class="font-normal"                >Same as shipping address</label              >            </div>          </div>        </fieldset>        <fieldset scFieldset>          <div scFieldGroup>            <div scField>              <label scLabel>Comments</label>              <textarea                scTextarea                placeholder="Add any additional comments"                class="resize-none"              ></textarea>            </div>          </div>        </fieldset>        <div scField orientation="horizontal">          <button scButton type="button">Submit</button>          <button scButton type="button" variant="outline">Cancel</button>        </div>      </div>    </div>  `,  host: { class: 'flex w-full justify-center' },  encapsulation: ViewEncapsulation.None,})export class FieldUsageDemo {  private readonly months = [    '01',    '02',    '03',    '04',    '05',    '06',    '07',    '08',    '09',    '10',    '11',    '12',  ].map((value) => ({    value,    label: value,  }));  private readonly years = Array.from({ length: 10 }, (_, i) => ({    value: String(2026 + i),    label: String(2026 + i),  }));  private readonly month = signal('');  private readonly year = signal('');  private readonly sameAsShipping = signal(true);}

Anatomy

Every part is a directive on your element. A field links its label, its description and its errors to its control by itself. Horizontal, around a checkbox, a radio or a switch, it lays them out itself: the control at the start (written first) or the end (written last), the description under the label. A label can be the field (the whole line clicks) or hold one (a choice card).

import {  ScFieldset, ScLegend, ScFieldGroup, ScField, ScFieldContentWrapper, ScFieldTitle,  ScFieldDescription, ScFieldErrors, ScFieldSeparator, ScLabel,} from '@semantic-components/ui';
<fieldset scFieldset>  <legend scLegend>…</legend>  <p scFieldDescription>…</p>  <div scFieldGroup>    <div scField orientation="…">      <label scLabel>…</label>      <input scInput … />      <p scFieldDescription>…</p>      <div scFieldErrors></div>    </div>    <div scFieldSeparator>…</div>  </div></fieldset>

Accessibility

  • A field names its control by its label (for) and describes it by its description and errors (aria-describedby); invalid, the control is aria-invalid.
  • A fieldset groups fields under its legend; a field of several controls is a group (role="group"), named by its label.
  • Errors are shown once the control is touched, read as they appear (role="alert").

Examples

Input

Choose a unique username for your account.

Must be at least 8 characters long.

import { Component, ViewEncapsulation } from '@angular/core';import {  ScField,  ScFieldDescription,  ScFieldGroup,  ScFieldset,  ScInput,  ScLabel,} from '@semantic-components/ui';

Textarea

Share your thoughts about our service.

import { Component, ViewEncapsulation } from '@angular/core';import {  ScField,  ScFieldDescription,  ScFieldGroup,  ScFieldset,  ScLabel,  ScTextarea,} from '@semantic-components/ui';

Select

Select your department or area of work.

import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScField,  ScFieldDescription,  ScLabel,  ScSelect,  ScSelectIcon,  ScSelectItem,  ScSelectItemIndicator,  ScSelectItemText,

Slider

Price limit

Set your budget ($500).

import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScField,  ScFieldDescription,  ScFieldTitle,  ScSlider,} from '@semantic-components/ui';
/** A slider under a title and a description that shows its value. */@Component({

Fieldset

Address Information

We need your address to deliver your order.

import { Component, ViewEncapsulation } from '@angular/core';import {  ScField,  ScFieldDescription,  ScFieldGroup,  ScFieldset,  ScInput,  ScLabel,  ScLegend,} from '@semantic-components/ui';

Checkbox

Show these items on the desktop

Select the items you want to show on the desktop.

Your Desktop & Documents folders are being synced with iCloud Drive. You can access them from other devices.

import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScCheckbox,  ScField,  ScFieldDescription,  ScFieldGroup,  ScFieldSeparator,  ScFieldset,  ScLabel,  ScLegend,

Radio

Subscription Plan

Yearly and lifetime plans offer significant savings.

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

Switch

import { Component, ViewEncapsulation } from '@angular/core';import { ScField, ScLabelText, ScSwitch } from '@semantic-components/ui';
/** A switch after its text: the whole row toggles it. */@Component({  selector: 'app-switch-field-demo',  imports: [ScLabelText, ScSwitch, ScField],  template: `    <label scField orientation="horizontal" class="w-fit">      <p scLabelText>Multi-factor authentication</p>

Choice card

Compute Environment

Select the compute environment for your cluster.

import { Component, ViewEncapsulation, signal } from '@angular/core';import { FormField, form } from '@angular/forms/signals';import {  ScField,  ScFieldContentWrapper,  ScFieldDescription,  ScFieldGroup,  ScFieldTitle,  ScFieldset,  ScLabel,

Field group

Responses

Get notified when ChatGPT responds to requests that take time, like research or image generation.

Tasks

Get notified when tasks you've created have updates. Manage tasks

import { Component, ViewEncapsulation, signal } from '@angular/core';import { RouterLink } from '@angular/router';import {  ScCheckbox,  ScField,  ScFieldDescription,  ScFieldGroup,  ScFieldSeparator,  ScFieldset,  ScLabel,

Responsive

Profile

Fill in your profile information.

Provide your full name for identification

import { Component, ViewEncapsulation } from '@angular/core';import {  ScButton,  ScField,  ScFieldContentWrapper,  ScFieldDescription,  ScFieldGroup,  ScFieldset,  ScInput,  ScLabel,

With Errors

Must be at least 8 characters.

import { Component, ViewEncapsulation, signal } from '@angular/core';import { FormField, form, minLength, required } from '@angular/forms/signals';import {  ScField,  ScFieldDescription,  ScFieldErrors,  ScLabel,} from '@semantic-components/ui';import { ScInput } from '@semantic-components/ui';

Field Separator

or
import { Component, ViewEncapsulation } from '@angular/core';import {  ScField,  ScFieldGroup,  ScFieldSeparator,  ScInput,  ScLabel,  ScSeparator,} from '@semantic-components/ui';

RTL

طريقة الدفع

جميع المعاملات آمنة ومشفرة

أدخل رقم البطاقة المكون من 16 رقمًا

عنوان الفوترة

عنوان الفوترة المرتبط بطريقة الدفع الخاصة بك

import { Dir } from '@angular/cdk/bidi';import { Component, LOCALE_ID, ViewEncapsulation, signal } from '@angular/core';import {  ScButton,  ScCheckbox,  ScField,  ScFieldDescription,  ScFieldGroup,  ScFieldSeparator,  ScFieldset,

API reference

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

PartSelectorDescription
ScFieldset, ScLegendfieldset[scFieldset], legend[scLegend] Fields under a legend; variant ('legend', 'label').
ScFieldGroup[scFieldGroup] Fields stacked; the container a responsive field reads.
ScFielddiv[scField], label[scField] A control with its label, description and errors, linked; orientation ('vertical', 'horizontal', 'responsive'; horizontal around a checkbox, radio or switch, a grid: the control at the start or the end, the description under the label); on a label, the label's text, dimmed with a disabled control; data-invalid, data-disabled.
ScFieldContentWrapper, ScFieldTitle[scFieldContentWrapper], [scFieldTitle] A label (or title) and its description together, beside a control.
ScFieldDescription, ScFieldErrors[scFieldDescription], [scFieldErrors] Read with the control (aria-describedby); its errors once it is touched, from Signal Forms.
ScFieldSeparator[scFieldSeparator] A line between fields, with optional text on it.