TextArea
Text Area is the space where longer text is inputted by users. It renders a <textarea>
by default.
Examples
Tone of Voice
The TextArea
tone of voice is either neutral
(default) or critical
, and is adjustable using the tone
prop.
<Stack space="$l">
<TextArea
label="Neutral"
value="Neutral text area"
helperText="Helpful text"
/>
<TextArea
tone="critical"
label="Critical"
value="Critical text area"
helperText="Helpful text"
criticalText="Something is wrong"
/>
</Stack>
Helpers
You can add a helper text to indicate the proper way to fill in the text area, and also, can add a character count to indicate the text maximum length and the current quantity of characters in the text area. To use these variations, the helperText
and charLimit
properties should have a value defined.
function Example() {
const [value, setValue] = React.useState('')
return (
<Box csx={{ width: 300 }}>
<TextArea
value={value}
onChange={(e) => {
setValue(e.target.value)
}}
id="Helpers-textarea"
label="Helpers"
helperText="This TextArea is disabled"
charLimit={120}
/>
</Box>
)
}
Disabled
You can disable the input by defining the disabled
property.
function Example() {
const [value, setValue] = React.useState('')
return (
<Box width={300}>
<TextArea
value={value}
onChange={(e) => {
setValue(e.target.value)
}}
id="disabled-textarea"
label="Disabled"
helperText="This TextArea is disabled"
disabled
charLimit={120}
/>
</Box>
)
}
Alternatives
- Input - For text fields.
- InputPassword - For password fields.