Text Input
import {TextInputModule} from "@qualcomm-ui/angular/text-input"Examples
Simple
The simple API bundles all subcomponents together into a single component.
<q-text-input
class="w-72"
hint="Optional hint"
label="Label"
placeholder="Placeholder text"
/>Icons
Add icons using icon props at the root.
<q-text-input
class="w-72"
defaultValue="Both icons"
endIcon="Calendar"
label="Both icons"
startIcon="AArrowDown"
/>Child Directives
Provide child directives to customize specific elements while keeping the simple API's default structure.
Composite
Build with the composite API for granular control. This API requires you to provide each subcomponent, but gives you full control over the structure and layout.
<div class="w-72" q-text-input-root>
<label q-text-input-label>Label</label>
<div q-text-input-input-group>
<input placeholder="Placeholder text" q-text-input-input />
<button q-text-input-clear-trigger></button>
<span q-text-input-error-indicator></span>
</div>
<div q-text-input-hint>Optional hint</div>
<div q-text-input-error-text>Error text</div>
</div>Icons (Composite)
The q-text-input-input-group directive provides icon properties for the composite API.
<div
class="w-72"
defaultValue="Both icons with clear button"
q-text-input-root
>
<label q-text-input-label>Start + End icons</label>
<div endIcon="Calendar" q-text-input-input-group startIcon="AArrowDown">
<input placeholder="Placeholder text" q-text-input-input />
<button q-text-input-clear-trigger></button>
</div>
</div>Composite Layout
The composite API is useful for alternative layouts and styles.
<div q-text-input-root size="sm">
<div class="flex items-center gap-4">
<label class="font-body-sm-bold w-48" q-text-input-label>
Project Name
</label>
<div q-text-input-input-group>
<input class="w-full" placeholder="QVSCE" q-text-input-input />
</div>
</div>
</div>
<div q-text-input-root size="sm">
<div class="flex items-center gap-4">
<label class="font-body-sm-bold w-48" q-text-input-label>
Project Version
</label>
<div q-text-input-input-group>
<input class="w-full" placeholder="v1.2.3" q-text-input-input />
</div>
</div>
</div>Clear Trigger
- When using the simple API, the clear button renders automatically. Change this by setting the clearable prop to false.
- When using the composite API, you render the
q-text-input-clear-triggerdeclaratively within the input group. - The clear button only shows when the input field has text.
<q-text-input defaultValue="Simple" />
<div defaultValue="Composite" q-text-input-root>
<div q-text-input-input-group>
<input q-text-input-input />
<button q-text-input-clear-trigger></button>
</div>
</div>Sizes
Customize size using the size prop. The default size is md.
<q-text-input
class="w-56"
defaultValue="sm"
size="sm"
startIcon="Search"
/>
<q-text-input
class="w-60"
defaultValue="md"
size="md"
startIcon="Search"
/>
<q-text-input
class="w-64"
defaultValue="lg"
size="lg"
startIcon="Search"
/>Error Text and Indicator
Error messages are displayed using two props:
The error text and indicator will only render when invalid is true.
<q-text-input
#textInput
class="w-64"
errorText="You must enter a value"
label="Label"
placeholder="Enter a value"
required
[invalid]="!value()"
[(ngModel)]="value"
/>Forms
Control and validate the input value using Angular form control bindings.
Template Forms
When using template-driven forms with ngModel, perform validation manually in your component and pass the result to the invalid property.
TIP
Form validation timing is controlled by the updateOn property on the form control.
<q-text-input
class="w-72"
errorText="Must be at least 3 characters long"
label="Label"
placeholder="Enter a value"
[invalid]="value().length < 2"
[(ngModel)]="value"
/>States
When using template forms, the disabled, readOnly, and invalid properties govern the interactive state of the control.
<q-text-input disabled label="Disabled" placeholder="Disabled" />
<q-text-input label="Read only" placeholder="Read only" readOnly />
<q-text-input
errorText="Invalid"
invalid
label="Invalid"
placeholder="Invalid"
/>Required
When using template forms, pass the required property to apply the RequiredValidator to the form control.
<q-text-input
class="w-72"
label="Required"
placeholder="Enter a value"
required
[(ngModel)]="value"
/>Reactive Forms
Use Reactive Forms for better control of form state and validation.
State Guidelines
The disabled, invalid, and required properties have no effect when using Reactive Forms. Use the equivalent Reactive Form bindings instead:
disabledField = new FormControl("")
invalidField = new FormControl("invalid-email", {
validators: [Validators.required, Validators.email],
})
requiredField = new FormControl("", {validators: [Validators.required]})
ngOnInit() {
this.disabledField.disable()
this.invalidField.markAsDirty()
}Composite API & Forms
When using the composite API with Angular Forms, always apply form control bindings to the q-text-input-root directive.
<div
class="w-72"
q-text-input-root
[invalid]="isInvalid()"
[(ngModel)]="value"
>
<label q-text-input-label>Composite Forms</label>
<div q-text-input-input-group>
<input placeholder="Enter a value" q-text-input-input />
<button q-text-input-clear-trigger></button>
<span q-text-input-error-indicator></span>
</div>
<div q-text-input-error-text>Must be at least three characters long</div>
</div>API
<q-text-input>
The <q-text-input> component extends the q-text-input-root directive with the following properties:
| Prop | Type | Default |
|---|---|---|
When true, renders a clear button that resets the input value on click.
The button only appears when the input has a value. | boolean | true |
string | ||
To customize the element, provide it using the directive instead: <div q-text-input-error-text>...</div> | ||
Optional hint describing the element. This element is automatically
associated with the component's input element for accessibility. | string | |
To customize the element, provide it using the directive instead: <div q-text-input-hint>...</div> | ||
Optional label describing the element. Recommended. This element is
automatically associated with the component's input element for
accessibility. | string | |
To customize the element, provide it using the directive instead: <div q-text-input-label>...</div> | ||
HTML placeholder attribute,
passed to the internal input element. | string | |
booleantrue, renders a clear button that resets the input value on click.
The button only appears when the input has a value.string<div q-text-input-error-text>...</div>
string<div q-text-input-hint>...</div>
string<div q-text-input-label>...</div>
stringComposite API
q-text-input-root
| Prop | Type | Default |
|---|---|---|
The initial state of the input when rendered. Use when you don't
need to control the checked state of the input. This property will be
ignored if you opt into controlled state via form control bindings. | string | |
The document's text/writing direction. | 'ltr' | 'rtl' | "ltr" |
Controls whether the input is disabled in template-driven forms. When true,
prevents user interaction and applies visual styling to indicate the disabled
state. | boolean | |
lucide-angular icon, positioned after
the input. | | string | |
To customize the element, provide it using the directive instead: <div q-text-input-input-group> | ||
A root node to correctly resolve the Document in custom environments. i.e.,
Iframes, Electron. | () => | |
Controls the visual error state of the input. When true, applies semantic error
styling to indicate validation failure. | boolean | |
The name of the input field. Useful for form submission. | string | |
Whether the input is read-only. When true, prevents user interaction while
keeping the input focusable and visible. | boolean | |
Controls whether the input is required in template-driven forms. When
true, the input must have a value for form validation to pass. | boolean | |
The size of the input field and its elements. Governs properties like font
size, item padding, and icon sizes. | | 'sm' | 'md' |
lucide-angular icon, positioned before
the input. | | string | |
To customize the element, provide it using the directive instead: <div q-text-input-input-group> | ||
Event emitted when the input value changes. This is only emitted on
interaction. It doesn't emit in response to programmatic form control changes. | string | |
string'ltr' | 'rtl'
boolean| string
| LucideIconData
<div q-text-input-input-group>
<div q-input-end-icon [icon]="..."></div>
</div>
() =>
| Node
| ShadowRoot
| Document
booleanstringbooleanboolean| 'sm'
| 'md'
| 'lg'
| string
| LucideIconData
<div q-text-input-input-group>
<div q-input-start-icon [icon]="..."></div>
</div>
string| Attribute / Property | Value |
|---|---|
class | 'qui-input__root' |
data-disabled | |
data-focus | |
data-invalid | |
data-part | 'root' |
data-scope | 'text-input' |
data-size | | 'sm' |
class'qui-input__root'data-disableddata-focusdata-invaliddata-part'root'data-scope'text-input'data-size| 'sm'
| 'md'
| 'lg'
q-text-input-input-group
| Attribute / Property | Value |
|---|---|
class | 'qui-input__input-group' |
data-disabled | |
data-focus | |
data-invalid | |
data-part | 'input-group' |
data-readonly | |
data-scope | 'text-input' |
data-size | | 'sm' |
class'qui-input__input-group'data-disableddata-focusdata-invaliddata-part'input-group'data-readonlydata-scope'text-input'data-size| 'sm'
| 'md'
| 'lg'
q-text-input-label
| Attribute / Property | Value |
|---|---|
class | 'qui-input__label' |
data-disabled | |
data-focus | |
data-invalid | |
data-part | 'label' |
data-scope | 'text-input' |
data-size | | 'sm' |
class'qui-input__label'data-disableddata-focusdata-invaliddata-part'label'data-scope'text-input'data-size| 'sm'
| 'md'
| 'lg'
q-text-input-hint
| Attribute / Property | Value |
|---|---|
class | 'qui-input__hint' |
data-disabled | |
data-part | 'hint' |
data-scope | 'text-input' |
class'qui-input__hint'data-disableddata-part'hint'data-scope'text-input'q-text-input-clear-trigger
| Attribute / Property | Value |
|---|---|
class | 'qui-input__clear-trigger' |
data-disabled | |
data-part | 'clear-trigger' |
data-scope | 'text-input' |
data-size | | 'sm' |
class'qui-input__clear-trigger'data-disableddata-part'clear-trigger'data-scope'text-input'data-size| 'sm'
| 'md'
| 'lg'
q-text-input-input
ngModel
or formControl to this element. Apply them to the root element instead.| Prop | Type |
|---|---|
string |
string| Attribute / Property | Value |
|---|---|
class | 'qui-input__input' |
data-empty | |
data-focus | |
data-invalid | |
data-part | 'input' |
data-readonly | |
data-scope | 'text-input' |
data-size | | 'sm' |
class'qui-input__input'data-emptydata-focusdata-invaliddata-part'input'data-readonlydata-scope'text-input'data-size| 'sm'
| 'md'
| 'lg'
q-text-input-error-text
| Attribute / Property | Value |
|---|---|
class | 'qui-input__error-text' |
data-part | 'error-text' |
data-scope | 'text-input' |
hidden | boolean |
class'qui-input__error-text'data-part'error-text'data-scope'text-input'hiddenbooleanq-text-input-error-indicator
| Prop | Type | Default |
|---|---|---|
lucide-angular icon | | LucideIconData | CircleAlert |
| LucideIconData
| string
| Attribute / Property | Value |
|---|---|
class | 'qui-input__error-indicator' |
data-part | 'error-indicator' |
data-scope | 'text-input' |
data-size | | 'sm' |
hidden | boolean |
class'qui-input__error-indicator'data-part'error-indicator'data-scope'text-input'data-size| 'sm'
| 'md'
| 'lg'
hiddenboolean