An implementation of a generic input for textual values as a form-connected web-component.
Used anywhere an author might otherwise use:
- input[type="text"]
- input[type="email"]
- input[type="password"]
- input[type="tel"]
- input[type="url"]
- Focus Delegation
We want general feature-parity between this component and the typical corresponding inputs. Most of these concerns are addressed by microsoft#2723, but some stateful nuance will need to be handled by this component.
- FAST Text Field (React)
- Material UI
- Lightning Design
- Carbon Design
- Ant Design
- Atlassian
- Office Fabric
- Windows (UWP)
Extends FAST Element
Component Name
fast-text-field
Attrs - Adapted from MDN
autofocus
- automatically focuses the controlreadonly
- the text field should be submitted with the form but should not be editable.placeholder
- an exemplar value to display in the input field whenever it is emptyrequired
- boolean value that sets the field as requiredvalue
- string value of the text field, can be an empty stringdisabled
- disables the controllist
- the id of the<datalist>
element that contains the optional pre-defined autocomplete optionsmaxlength
- the maximum number of characters the input should acceptminlength
- the minimum number of characters long the input can be and still be considered validname
- the name of the controlpattern
- a regular expression the input's contents must match in order to be validsize
- a number indicating how many characters wide the input field should bespellcheck
- controls whether or not to enable spell checking for the input field, or if the default spell checking configuration should be usedtype
- enum- text
- password
- tel
- url
appearance
- enum- outline (default)
- filled
Events
change: CustomEvent
- no custom data
- bubbles
<!-- shadow root -->
<label part="label"><slot></slot></label>
<div part="root">
<slot name="before-content" part="before-content"></slot>
<input type="${x => x.type}" part="control" />
<slot name="after-content" part="after-content"></slot>
</div>
<!-- end shadow root -->
Screenshots below are of the basic appearance of the component and are not exhaustive.
State | Image |
---|---|
default | |
focus | |
placeholder | |
password (filled) | |
filled |
Slot Names
- default - the label content
- before-content - often times a glyph, icon, or button precedes input
- after-content - often times a glyph, icon, or button follows the input
Host Classes
- disabled
- required
- readonly
CSS Parts
- label
- root
- before-content
- after-content
- control
disabled: true
or false
- when disabled, the value will not be changeable through user interaction. It should also not expose it's value to a form submission.
readonly: true
or false
- when readonly, the value will not be changeable through user interaction. The value will still be exposed to forms on submission.
The input element inside the shadow-dom of the checkbox will be a focusable element. With this in mind, so long as the text field recieves focus, assistive technology should treat it as such.
Before and after content should swap in LTR presentations.
While testing is still TBD for our web components, I would expect this to align with the testing strategy and not require any additional test support.
Adding mechanisms, slots, and data for surfacing validation error messages.