Textarea
A multi-line text field that grows to fit its content.
Put it in a Field for a label and a description, like any input. It sizes to its content
with field-sizing: content, between its minimum height and whatever limit you set.
Dependencies
What it's built from and what's built from it in Mocha, read from the imports in its source.
| Uses | Inputform itemTextprimitive |
|---|---|
| Used by | Nothing yet. |
| Packages | @ui-sdk/core@0.1.0-beta.20@ui-sdk/react@0.1.0-beta.20 |
Installation
Set the project up for Mocha once first, as Getting started shows. Then add it with the CLI, or by hand.
With the CLI
Manually
Install its packages:
Add the components it uses first, listed under Dependencies.
Then copy the source:
API reference
Generated from Mocha's types. Props marked ours are added here; the rest come from the ui-sdk part it wraps. Every part also accepts its element's native attributes.
Textarea
A multi-line text field, outlined like the system's inputs, that grows to fit its content.
- autoResize
Grows and shrinks with the text. Bound it with CSS
min-heightandmax-height; past the maximum, it scrolls.Type boolean · Default false
- children
Content, or a function of the part's state that returns it.
Type ReactNode | ((state: InputState) => ReactNode)
- className
Class names, or a function of the part's state that returns them.
Type string | ((state: InputState) => string)
- controller
Reads and writes the field from anywhere. Create one with
createInputController().Type { getValue: () => string; setValue: (value: string, options?: ChangeOptions<InputValueChangeReason>) => boolean; clear: (options?: ChangeOptions<...>) => boolean; focus: () => void; }
- debug
Logs every state change with its reason to the console, in development builds.
Type boolean
- defaultValue
The value it starts with. A form reset returns here.
Type string
- disabled
Stops presses. The button is natively disabled, so it leaves the tab order and its form doesn't submit through it, unless
focusableWhenDisabledis set.Type boolean · Default false
- onSubmit
Runs on the submit shortcut, unless an input method is composing. Without it, the shortcut submits the form the textarea is in. With neither, the key is left alone, so Enter adds a line.
Type (value: string, details: TextareaSubmitDetails) => void
- onValueChange
Called when the user changes the value: typing (
"input-change"), a Clear part ("clear-press"), a form reset ("reset") or a controller ("imperative").details.cancel()keeps the value as it was.Type (value: string, details: ChangeDetails<InputValueChangeReason>) => void
- render
Renders your own element: one that receives the part's props, or a function of the props and the state.
Type RenderProp<InputState>
- style
Styles, or a function of the part's state that returns them.
Type CSSProperties | ((state: InputState) => CSSProperties)
- submitShortcut
Which keys submit:
"enter", with Shift+Enter for a new line, or"mod+enter", with Enter for a new line. Without it, Enter always starts a new line.Type "enter" | "mod+enter"
- value
The value, for a controlled field.
Type string