<sessions-text-field>
A single-line (or multiline) text input.
Preact & React
<TextField>GroupFormsDrawn asTextFieldPreview
Drawn by the same renderers Sessions uses for your extension, from the DOM example beside it, without its event handlers.
When to use it
Controlled by you: set value, listen for input (every keystroke) or change (the committed value), and set error to show a validation message under it.
In Preact and React, import the component of the same name from @sessions/apps/preact or @sessions/apps/react. Attributes become camelCase props, a boolean attribute is a boolean prop, and an event is an on prop that receives the event’s detail.
Attributes
Attribute
labelThe field label.Prop
labellabel-visibilityhidden keeps the label for screen readers but draws none.visiblehiddenProp labelVisibilityvalueThe current value.Prop
valueplaceholderHint text when empty.Prop
placeholdertypeThe HTML input type.
textemailurlnumbertelProp typehelp-textGuidance under the field.Prop
helpTexterrorA validation message; the field turns critical.Prop
errordisabledbooleanNon-interactive.Prop
disabledmultilinebooleanA textarea instead of an input.Prop
multilineselect-on-pastebooleanSelects the whole value after a paste, so a wrong link is one keystroke from replaced.Prop
selectOnPasteEvents
inputdetail: string — the new valueEvery keystroke.Prop
onInputchangedetail: string — the new valueThe committed value.Prop
onChangefocusdetail: undefinedThe field gained focus.Prop
onFocusblurdetail: undefinedThe field lost focus.Prop
onBlurSlots
slot="accessory"Inside the field at its end — a small
sessions-button, such as a Save that appears once the value changes.Example
import {TextField} from '@sessions/apps/preact';
<TextField
label="Playlist link"
placeholder="https://open.spotify.com/playlist/…"
value={model.draft}
onInput={(value) => model.setDraft(value)}
/>