docs/documentation/components/textarea.mdx
Similar to text inputs, Evergreen exports two components to create text areas:
textarea element.<Textarea name="textarea-1" placeholder="Textarea placeholder..." />
<Pane>
<Label htmlFor="textarea-2" marginBottom={4} display="block">
Label
</Label>
<Textarea id="textarea-2" placeholder="Textarea placeholder..." />
</Pane>
The Textarea component works the same as using textarea directly.
Use e.target.value to get the value of the component on change.
function ControlledTextareaExample() {
const [value, setValue] = React.useState('')
return <Textarea onChange={(e) => setValue(e.target.value)} value={value} />
}
The TextareaField component combines a Textarea with a label and optional description, validationMessage and hint. The example below shows how each of these fields is rendered on the text field. Try opening the code example and changing some of the fields.
<TextareaField
isInvalid={true}
label="Default textarea field"
description="This is a description."
hint="This is a hint. It's rendered under the textarea"
required
validationMessage="This field is required. It's only rendered when isInvalid is true."
placeholder="Placeholder text"
/>
The TextareaField component works the same as using textarea directly.
Use e.target.value to get the value of the component on change.
function ControlledTextareaExample() {
const [value, setValue] = React.useState('')
return (
<TextareaField
label="A controlled text input field"
required
description="This is a description."
value={value}
onChange={(e) => setValue(e.target.value)}
/>
)
}