Text field
Text field
Component demo
Interactive example
<ic-text-fieldlabel="What is your favourite coffee?"placeholder="Please enter…"helper-text="Such as Arabica, Robusta or Liberica"></ic-text-field>
<IcTextFieldlabel="What is your favourite coffee?"placeholder="Please enter…"helperText="Such as Arabica, Robusta or Liberica"onIcChange={(ev)=>console.log(ev.detail.value)}/>
Text field details
Props
All components also accept native properties supported by the DOM, such asclassName
and
style
.
|
|
|
---|---|---|
|
The label for the input. |
|
|
If |
|
|
The automatic capitalisation of the text value as it is entered/edited by the user. Available options: "off", "none", "on", "sentences", "words", "characters". |
|
|
The state of autocompletion the browser can apply on the text value. |
|
|
The state of autocorrection the browser can apply when the user is entering/editing the text value. |
|
|
The amount of time, in milliseconds, to wait to trigger the |
|
|
If |
|
|
Specify whether the text field fills the full width of the container.
If |
|
|
The helper text that will be displayed for additional field guidance. |
|
|
If |
|
|
The ID for the input. |
|
|
A hint to the browser for which keyboard to display.
Possible values: |
|
|
The maximum number that can be accepted as a value, when |
|
|
The maximum number of characters that can be entered in the field. Will display an error if too many characters are entered. |
|
|
The count of characters in the field. Will display a warning if the bound is reached. |
|
|
The text to display as the validation message when the maximum length is exceeded. |
|
|
The minimum number that can be accepted as a value, when |
|
|
The minimum number of characters that can be entered in the field. |
|
|
The name of the control, which is submitted with the form data. |
|
|
The placeholder value to be displayed. |
|
|
If |
|
|
If |
|
|
If |
|
|
The number of rows to transform the text field into a text area with a specific height. |
|
|
The size of the text field component. |
|
|
|
|
|
If |
|
|
The type of control to display. The default type is text. |
|
|
If |
|
|
The validation state - e.g. 'error' | 'warning' | 'success'. |
|
|
The validation state - e.g. 'error' | 'warning' | 'success'. |
|
|
The value of the text field. |
|
The label for the input. |
If |
The automatic capitalisation of the text value as it is entered/edited by the user. Available options: "off", "none", "on", "sentences", "words", "characters". |
The state of autocompletion the browser can apply on the text value. |
The state of autocorrection the browser can apply when the user is entering/editing the text value. |
The amount of time, in milliseconds, to wait to trigger the |
If |
Specify whether the text field fills the full width of the container.
If |
The helper text that will be displayed for additional field guidance. |
If |
The ID for the input. |
A hint to the browser for which keyboard to display.
Possible values: |
The maximum number that can be accepted as a value, when |
The maximum number of characters that can be entered in the field. Will display an error if too many characters are entered. |
The count of characters in the field. Will display a warning if the bound is reached. |
The text to display as the validation message when the maximum length is exceeded. |
The minimum number that can be accepted as a value, when |
The minimum number of characters that can be entered in the field. |
The name of the control, which is submitted with the form data. |
The placeholder value to be displayed. |
If |
If |
If |
The number of rows to transform the text field into a text area with a specific height. |
The size of the text field component. |
|
If |
The type of control to display. The default type is text. |
If |
The validation state - e.g. 'error' | 'warning' | 'success'. |
The validation state - e.g. 'error' | 'warning' | 'success'. |
The value of the text field. |
Slots
A slot allows for any type of element or markup to be passed into and rendered within a web component. This creates more flexibility than using a prop which must take a specific type of data.
Content can be slotted into a component by adding it as a top-level child of the component.
Slots can have a name to identify them. These specify which slot the content will be inserted into, and therefore where it will be rendered and how it will be used within the component. The name of the slot to be used can be specified by passing it via a
slot
attribute on the slotted content.
|
|
---|---|
|
|
|
CSS Custom Properties
|
|
---|---|
|
|
|
Events
All components also accept native events supported by the DOM, such as
onClick
and
onKeyDown
.
|
|
|
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Methods
|
|
|
---|---|---|
|
|
|
|
Variants
With icon, value and max length
Interactive example
<ic-text-fieldmax-length="25"value="Arabica"label="What is your favourite coffee?"required="true"placeholder="Please enter…"helper-text="Such as Arabica, Robusta or Liberica"><svgslot="icon"xmlns="http://www.w3.org/2000/svg"width="24"height="24"viewBox="0 0 24 24"fill="#000000"><pathd="M2,21H20V19H2M20,8H18V5H20M20,3H4V13A4,4 0 0,0 8,17H14A4,4 0 0,0 18,13V10H20A2,2 0 0,0 22,8V5C22,3.89 21.1,3 20,3Z"/></svg></ic-text-field>
<IcTextFieldmaxLength={25}value="Arabica"label="What is your favourite coffee?"requiredplaceholder="Please enter…"helperText="Such as Arabica, Robusta or Liberica"><SlottedSVGslot="icon"xmlns="http://www.w3.org/2000/svg"width="24"height="24"viewBox="0 0 24 24"fill="#000000"><pathd="M2,21H20V19H2M20,8H18V5H20M20,3H4V13A4,4 0 0,0 8,17H14A4,4 0 0,0 18,13V10H20A2,2 0 0,0 22,8V5C22,3.89 21.1,3 20,3Z"/></SlottedSVG></IcTextField>
Disabled
Interactive example
<ic-text-fieldlabel="What is your favourite coffee?"required="true"placeholder="Please enter…"disabled="true"><svgslot="icon"xmlns="http://www.w3.org/2000/svg"width="24"height="24"viewBox="0 0 24 24"fill="#000000"><pathd="M0 0h24v24H0z"fill="none"/><pathd="M17 3H7c-1.1 0-1.99.9-1.99 2L5 21l7-3 7 3V5c0-1.1-.9-2-2-2z"/></svg></ic-text-field>
<IcTextFieldlabel="What is your favourite coffee?"requiredplaceholder="Please enter…"disabled><SlottedSVGslot="icon"xmlns="http://www.w3.org/2000/svg"width="24"height="24"viewBox="0 0 24 24"fill="#000000"><pathd="M0 0h24v24H0z"fill="none"/><pathd="M17 3H7c-1.1 0-1.99.9-1.99 2L5 21l7-3 7 3V5c0-1.1-.9-2-2-2z"/></SlottedSVG></IcTextField>
Size small
Interactive example
<ic-text-fieldlabel="What is your favourite coffee?"placeholder="Please enter…"size="small"></ic-text-field>
<IcTextFieldlabel="What is your favourite coffee?"placeholder="Please enter…"size="small"onIcChange={(ev)=>console.log(ev.detail.value)}/>
Validation
Interactive example
<ic-text-fieldvalidation-status="success"validation-text="Good choice!"value="Arabica"max-length="25"label="What is your favourite coffee?"required="true"placeholder="Please enter…"helper-text="Such as Arabica, Robusta or Liberica"></ic-text-field><ic-text-fieldvalidation-status="success"validation-text="Good choice!"validation-inline="true"value="Arabica"max-length="25"label="What is your favourite coffee?"required="true"placeholder="Please enter…"helper-text="Such as Arabica, Robusta or Liberica"></ic-text-field><ic-text-fieldvalidation-status="warning"validation-text="There’s only a few left! Order now to avoid missing out."value="Arabica"max-length="25"label="What is your favourite coffee?"required="true"placeholder="Please enter…"helper-text="Such as Arabica, Robusta or Liberica"></ic-text-field><ic-text-fieldvalidation-status="error"validation-text="now it has really gone to (coffee) pot"value="Tea"max-length="25"label="What is your favourite coffee?"required="true"placeholder="Please enter…"helper-text="Such as Arabica, Robusta or Liberica"></ic-text-field>
<IcTextFieldmaxLength={25}value="Arabica"label="What is your favourite coffee?"requiredplaceholder="Please enter…"helperText="Such as Arabica, Robusta or Liberica"validationStatus="success"validationText="Good choice!"/><IcTextFieldmaxLength={25}value="Arabica"label="What is your favourite coffee?"requiredplaceholder="Please enter…"helperText="Such as Arabica, Robusta or Liberica"validationStatus="success"validationText="Good choice!"validationInline/><IcTextFieldmaxLength={25}value="Arabica"label="What is your favourite coffee?"requiredplaceholder="Please enter…"helperText="Such as Arabica, Robusta or Liberica"validationStatus="warning"validationText="There’s only a few left! Order now to avoid missing out."/><IcTextFieldmaxLength={25}value="Tea"label="What is your favourite coffee?"requiredplaceholder="Please enter…"helperText="Such as Arabica, Robusta or Liberica"validationStatus="error"validationText="Now it has really gone to (coffee) pot"/>
With min and max values
In this example, an error message will display when the input is either below the min value or above the max value. This only affects numeric input fields.
Interactive example
<ic-text-fieldlabel="How many coffees do you want?"helper-text="Our coffee machines have a maximum capacity of 4 coffees at a time."placeholder="Please enter…"type="number"inputmode="numeric"min="1"max="4"value="6"></ic-text-field>
<IcTextFieldlabel="How many coffees do you want?"helperText="Our coffee machines have a maximum capacity of 4 coffees at a time."placeholder="Please enter…"type="number"inputmode="numeric"min={1}max={4}value="6"/>
Text area with resize
Interactive example
<ic-text-fieldrows="6"resize="true"label="What is your favourite coffee?"placeholder="Please enter…"helper-text="Such as Arabica, Robusta or Liberica"></ic-text-field>
<IcTextFieldrows={6}resizelabel="What is your favourite coffee?"placeholder="Please enter…"helperText="Such as Arabica, Robusta or Liberica"/>