TextArea
Use TextArea to create an input field for multiple lines of text.
To add the TextArea
component to your app:
import {TextArea} from '@stripe/ui-extension-sdk/ui';
<TextArea label="Description" placeholder="Acme Inc was founded in…" defaultValue="Stripe Apps lets you embed custom…" onChange={(e) => { console.log(e.target.value); }} />
TextArea props
Property | Type |
---|---|
| Optional
Specifies one of the possible autocomplete behaviors. |
| Optional
If |
| Optional
|
| Optional
Related types: CSS. |
| Optional
Specifies the initial value that a user can change. |
| Optional
Descriptive text that will be rendered adjacent to the control’s label. |
| Optional
Sets whether or not the element should be disabled. Prevents selection. |
| Optional
Error text that will be rendered below the control. |
| Optional
Specifies the |
| Optional
Visually hides the specified elements. The hidden elements will still be present and visible to screen readers. |
| Optional
Sets whether or not the element is in an invalid state. This is a display-only prop, and will not prevent form submission. |
| Optional
Text that describes the control. Will be both visible and clickable. |
| Optional
Specifies the maximum length of text. |
| Optional
Specifies the minimum length of text. |
| Optional
Specifies the name for this input that’s submitted with the form. |
| Optional
Required for controlled inputs. Fires immediately when the input’s value is changed by the user (for example, it fires on every keystroke). Behaves like the browser input event. |
| Optional
Fires when a key is pressed. |
| Optional
Fires when a key is released. |
| Optional
Displayed in a dimmed color when the input value is empty. |
| Optional
If |
| Optional
If |
| Optional
|
| Optional
|
| Optional
The size of the component. |
| Optional
If explicitly set to |
| Optional
Overrides the default Tab button behavior. Avoid using values other than |
| Optional
Controls the input’s text. When you pass this prop, you must also pass an |
| Optional
|
| OptionalDeprecated
|
CSS
Property | Type |
---|---|
| Optional
The width of the component. See Sizing for details. |
Invalid
You can mark a TextArea
as invalid by setting the invalid
prop on the element. This is purely visual. It defaults to false
.
<TextArea label="Favorite word" defaultValue="Stripe Apps lets you embed custom…" invalid />
Resizeable
By default, TextArea
is vertically resizable. Users who need more space typically prefer this. If you need to prevent the element from resizing, set resizeable
to false
.
<TextArea label="Resizable bio" defaultValue="Stripe Apps lets you embed custom…" /> <TextArea label="Unresizable bio" resizeable={false} defaultValue="Stripe Apps lets you embed custom…" />
Size
Changing the size
allows you to choose variants with slightly more or slightly less room than the default. In general you don’t want to mix and match different sizes within the same form. The default is medium
.
<TextArea label="Description (large)" size="large" defaultValue="Stripe Apps lets you embed custom…" /> <TextArea label="Description (medium, default)" size="medium" defaultValue="Stripe Apps lets you embed custom…" /> <TextArea label="Description (small)" size="small" defaultValue="Stripe Apps lets you embed custom…" />
Disable and read only
You can mark a field as disabled
, which prevents any interaction and changes the styling. Disabled means that no data from that form element is submitted when the form is submitted.
You can also make a field as readOnly
. Read-only means any data from within the element is submitted, but the user can’t change it.
<TextArea label="Disabled" defaultValue="Stripe Apps lets you embed custom…" disabled /> <TextArea label="Readonly" defaultValue="Stripe Apps lets you embed custom…" readOnly />
Rows
A TextArea
uses rows to control its height rather than using a traditional height in pixels, just like a regular <TextArea />
. This allows the element to size itself based on multiples of the font size, rather than a raw pixel value. It prevents text from being partially obscured by default.
The vertical height of your TextArea
component also changes depending on what size value you set, because that changes the line height of the text inside the input.
<TextArea label="Description (3 rows, default)" defaultValue="Stripe Apps lets you embed custom…" /> <TextArea label="Description (6 rows)" rows={6} defaultValue="Stripe Apps lets you embed custom…" />
State management
Use the TextArea
component as an uncontrolled input:
<TextArea onChange={(e) => { console.log(e); }} label="About your business" placeholder="Our business is…" />
Width
Set the width of a TexaArea
component using the available values with the css
prop:
<TextArea label="App feedback" defaultValue="Stripe Apps lets you embed custom…" css={{width: 'fill'}} />