Input

A native text field, in the look of the app's style. In a Field it takes the field's label and description; with Signal Forms it shows itself invalid once touched. For a longer text, use a Textarea; for a choice among options, a Select.

FormsExperimental

Usage

import { Component, ViewEncapsulation } from '@angular/core';import { ScField, ScInput, ScLabel } from '@semantic-components/ui';
@Component({  selector: 'app-input-usage-demo',  imports: [ScField, ScInput, ScLabel],  template: `    <div scField class="w-full max-w-xs">      <label scLabel>Name</label>      <input scInput placeholder="Jordan Lee" />    </div>  `,  host: { class: 'flex w-full justify-center' },  encapsulation: ViewEncapsulation.None,})export class InputUsageDemo {}

Anatomy

One part, on a native input. It needs a name: a label — in a Field, the field links them — or aria-label; in development it warns without one. A placeholder is not a name.

import { ScInput } from '@semantic-components/ui';
<div scField>  <label scLabel>Label</label>  <input scInput />  <p scFieldDescription>Description</p></div>

Forms

With [formField], the form owns its state: its constraints ( required, disabled, email…) are declared in the form's schema, not on the input, and the input is marked invalid ( aria-invalid) once the field is touched — the Invalid and Required examples.

Examples

Basic

import { Component, ViewEncapsulation } from '@angular/core';import { ScInput } from '@semantic-components/ui';
@Component({  selector: 'app-basic-input-demo',  imports: [ScInput],  template: `    <input      scInput      placeholder="Enter text"

Field

Choose a unique username for your account.

import { Component, ViewEncapsulation } from '@angular/core';import {  ScField,  ScFieldDescription,  ScInput,  ScLabel,} from '@semantic-components/ui';
@Component({  selector: 'app-field-input-demo',

Field Group

We'll send updates to this address.

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

Disabled

This field is currently disabled.

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

Invalid

import { Component, ViewEncapsulation, signal } from '@angular/core';import { FormField, email, form } from '@angular/forms/signals';import {  ScField,  ScFieldErrors,  ScInput,  ScLabel,} from '@semantic-components/ui';
/** Invalid once touched: the form says so, not the markup. */

File

Select a picture to upload.

import { Component, ViewEncapsulation } from '@angular/core';import {  ScField,  ScFieldDescription,  ScInput,  ScLabel,} from '@semantic-components/ui';
@Component({  selector: 'app-file-input-demo',

Inline

import { Component, ViewEncapsulation } from '@angular/core';import { ScButton, ScField, ScInput } from '@semantic-components/ui';
@Component({  selector: 'app-inline-input-demo',  imports: [ScButton, ScField, ScInput],  template: `    <div scField orientation="horizontal" class="w-full max-w-sm">      <input        scInput

Grid

import { Component, ViewEncapsulation } from '@angular/core';import {  ScField,  ScFieldGroup,  ScInput,  ScLabel,} from '@semantic-components/ui';
@Component({  selector: 'app-grid-input-demo',

Required

This field must be filled out.

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

Badge

import { Component, ViewEncapsulation } from '@angular/core';import { ScBadge, ScField, ScInput, ScLabel } from '@semantic-components/ui';
@Component({  selector: 'app-badge-input-demo',  imports: [ScBadge, ScField, ScInput, ScLabel],  template: `    <div scField class="w-full max-w-sm">      <label scLabel>        Webhook URL

Input Group

https://
import { Component, ViewEncapsulation } from '@angular/core';import {  ScField,  ScInput,  ScInputGroup,  ScInputGroupAddon,  ScInputGroupText,  ScLabel,} from '@semantic-components/ui';import { SiInfoIcon } from '@semantic-icons/lucide-icons';

Control Group

import { Component, ViewEncapsulation } from '@angular/core';import {  ScButton,  ScControlGroup,  ScField,  ScInput,  ScLabel,} from '@semantic-components/ui';
@Component({

Form

We'll never share your email with anyone.

import { Component, ViewEncapsulation, signal } from '@angular/core';import {  FormField,  FormRoot,  email,  form,  required,} from '@angular/forms/signals';import {  ScButton,

RTL

سنرسل التحديثات إلى هذا العنوان.

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

API reference

ScInput is a directive on a native input[scInput]: its classes are the app's style's ( provideSemanticComponents({ style }), nova by default). Every native attribute ( type, placeholder, autocomplete…) is the input's own.

InputTypeDefaultDescription
idstringthe field’s, or generated In a field, the field’s id: its label points to it.
aria-describedbystringthe field’s description In a field, its description and errors.
disabledbooleanfalse Without a form. With [formField], declare disabled() in the schema.
classstring'' Classes merged over the style (cn: a later class wins).