Back to Tuist

TextInput

noora/docs/components/textinput.md

4.204.03.9 KB
Original Source
<!-- Generated by scripts/generate-web-components.js. Do not edit directly. -->

TextInput

Collects single-line text with Noora labels, hints, prefixes, and suffixes.

html
<noora-text-input label="Email" type="email" name="email"></noora-text-input>

Attributes

AttributeType or allowed valuesDefaultDescription
typebasic, email, card_number, search, password"basic"Controls the semantic field presentation.
input-typestring"text"Sets the native input type for basic fields.
labelstringNoneSets the field label.
sublabelstringNoneSets secondary label text.
hintstringNoneSets supporting text.
hint-variantdefault, destructive, disabled"default"Controls hint semantics.
errorstringNoneSets the validation error.
namestring""Sets the submitted field name.
valuestring""Gets or sets the field value.
placeholderstringNoneSets placeholder text.
requiredbooleanfalseMarks the field as required.
show-requiredbooleanfalseShows the required indicator.
minstringNoneSets the native minimum value.
maxstringNoneSets the native maximum value.
stepstringNoneSets the native step value.
disabledbooleanfalseDisables the field.

Read-only properties

PropertyTypeDescription
controlHTMLInputElement | nullThe native input.
formHTMLFormElement | nullThe associated form.

Events

EventTypeDescription
inputInputEventEmitted while the input value changes.
changeEventEmitted after the input value is committed.

Slots

SlotDescription
prefixA custom prefix for basic fields.
suffixA custom suffix.

Styling parts

PartDescription
inputThe native input.
wrapperThe input wrapper.

The component emits standard input and change events.

Input types

Use basic, email, card-number, search, and password presentations.

html
<noora-text-input name="basic" placeholder="Placeholder text..."><noora-icon slot="prefix" name="user"></noora-icon></noora-text-input>
<noora-text-input type="email" name="email" placeholder="[email protected]"></noora-text-input>
<noora-text-input type="card_number" name="card" placeholder="0000 0000 0000 0000"></noora-text-input>
<noora-text-input type="search" name="search" placeholder="Search..."></noora-text-input>
<noora-text-input type="password" name="password"></noora-text-input>

With hint

Give supporting guidance below the input.

html
<noora-text-input name="username" placeholder="Username" hint="Use letters, numbers, and underscores"></noora-text-input>

Error

Communicate validation failures.

html
<noora-text-input name="email" placeholder="[email protected]" error="Enter a valid email address"></noora-text-input>

Custom suffix

Provide a custom element after the native input.

html
<noora-text-input name="assignee" placeholder="Assignee"><noora-icon slot="suffix" name="user"></noora-icon></noora-text-input>

Labels

Show required and secondary label content.

html
<noora-text-input type="email" name="email" label="Email" required show-required></noora-text-input>
<noora-text-input type="password" name="password" label="Password" sublabel="Be safe!"></noora-text-input>

Disabled

Compare empty and filled disabled fields.

html
<noora-text-input type="email" name="empty-email" label="Email" placeholder="[email protected]" hint="Use a tuist.dev address" disabled></noora-text-input>
<noora-text-input type="email" name="filled-email" value="[email protected]" hint="Use a tuist.dev address" disabled></noora-text-input>