Textarea
NewOverview
Textarea component for multi-line text fields.
It renders a native
textarea
element.
<.form for={@form}>
<Textarea.textarea
field={@form[:message]}
label="Message"
placeholder="Describe what happened..."
/>
</.form>
Description and sublabel
Use description
for supporting text beneath the field and sublabel
for short text beside the label.
Summarize the changes that affect people using the product.
<.form for={@form}>
<Textarea.textarea
field={@form[:release_notes]}
label="Release notes"
sublabel="(optional)"
description="Summarize the changes that affect people using the product."
placeholder="Describe what changed..."
/>
</.form>
Disabled
Set disabled when the value cannot be edited or submitted.
<Textarea.textarea
id="locked-notes"
name="locked_notes"
label="Notes"
value="This field cannot be edited."
disabled
/>
Required
Set required
to apply native validation and show the default (required)
sublabel. An explicit sublabel
takes precedence.
<Textarea.textarea
id="required-summary"
name="summary"
label="Summary"
placeholder="Write one or two sentences..."
required
/>
Rows
Set rows to control the field's initial visible line count.
<Textarea.textarea
id="biography"
name="biography"
label="Biography"
rows={8}
placeholder="Tell us about yourself..."
/>
Auto-grow
Set autogrow
to apply
field-sizing: content
. The field grows and shrinks with its content without a JavaScript hook.
<Textarea.textarea
id="growing-message"
name="growing_message"
label="Message"
rows={2}
autogrow
placeholder="Type to expand the field..."
/>
Errors
When bound with field, validation errors render beneath the
textarea
.
<.form for={@form}>
<Textarea.textarea
field={@form[:message]}
label="Message"
placeholder="Describe what happened..."
/>
</.form>
Add this module
mix dizzy.add textarea
Component API
Textarea.textarea
Attributes
| Name | Type | Default | Values |
|---|---|---|---|
autogrow |
:boolean
| false | โ |
class |
:any
| nil | โ |
description |
:string
| nil | โ |
disabled |
:boolean
| false | โ |
errors |
:list
| [] | โ |
field |
{:struct, Phoenix.HTML.FormField}
| nil | โ |
id |
:string
| nil | โ |
label |
:string
| nil | โ |
name |
:string
| nil | โ |
required |
:boolean
| false | โ |
rest |
:global
| nil | โ |
rows |
:integer
| 4 | โ |
sublabel |
:string
| nil | โ |
value |
:any
| nil | โ |