The most common use case is a plain text input with validation:
You typed, ""
<FormInput
@label="First Name"
@value={{this.value}}
@onInput={{this.setValue}}
@errors={{this.validationErrors}}
/>
<p class="mt-4">
You typed, "{{this.value}}"
</p>
If you don't want the label then simply leave it out of the component tag:
You typed, ""
<FormInput
@value={{this.value}}
@onInput={{this.setValue}}
placeholder="I have no label"
/>
<p class="mt-4">
You typed, "{{this.value}}"
</p>
You can pass @hint
to the component to add hint content.
You typed, ""
<FormInput
@label="I have Hint"
@hint="InputText support optional hints"
@value={{this.value}}
@onInput={{this.setValue}}
/>
<p class="mt-4">
You typed, "{{this.value}}"
</p>
Element: HTMLInputElement
Name | Type | Default | Description |
---|---|---|---|
value
*
|
string
|
- | The value to be used in the input. You must also pass `onChange` or `onInput` to update its value. |
containerClass
|
string
|
- | CSS classes to be added in the container element |
errors
|
enum
|
- | A list of errors or a single text describing the error |
hasError
|
boolean
|
- | If has errors |
hasSubmitted
|
boolean
|
- | If the form has been submitted, used to force displaying errors |
hint
|
string
|
- | A help text to be displayed |
inputClass
|
string
|
- | CSS classes to be added in the input element |
label
|
string
|
- | The group label |
onChange
|
function
|
- | Callback when onchange is triggered |
onFocusIn
|
function
|
- | Callback when onfocus is triggered |
onFocusOut
|
function
|
- | Callback when onblur is triggered |
onInput
|
function
|
- | Callback when oninput is triggered |
showError
|
boolean
|
- | Force displaying errors |
size
|
enum
|
- | The size |
type
|
string
|
'text'
|
The input type |
Name | Type | Default | Description |
---|---|---|---|
default
*
|
Array
|
- |