Components
Textarea
Several lines of text, such as a note to the hiring manager.
import { Textarea } from '@dex/shared/components/textarea'
export function TextareaDefault() {
return (
<div className="w-full max-w-md">
<Textarea
aria-label="Note to the hiring manager"
placeholder="What should the hiring manager know about you?"
/>
</div>
)
}
Shown with your application.
import { Field, FieldControl, FieldLabel, FieldMessage } from '@dex/shared/components/field'
import { Textarea } from '@dex/shared/components/textarea'
export function TextareaInAField() {
return (
<Field className="max-w-md">
<FieldLabel optional>Note to the hiring manager</FieldLabel>
<FieldControl>
<Textarea placeholder="What should the hiring manager know about you?" />
</FieldControl>
<FieldMessage description="Shown with your application." />
</Field>
)
}
Shown with your application.128 / 500
'use client'
import { useState } from 'react'
import { Field, FieldControl, FieldLabel, FieldMessage } from '@dex/shared/components/field'
import { Textarea } from '@dex/shared/components/textarea'
const NOTE_LIMIT = 500
export function TextareaCharacterCount() {
const [note, setNote] = useState(
'I’ve led platform teams at two Series A startups in London, and I’m free to start in mid-March after my one-month notice period.',
)
return (
<Field className="max-w-md">
<FieldLabel optional>Note to the hiring manager</FieldLabel>
<FieldControl>
<Textarea
value={note}
maxLength={NOTE_LIMIT}
onChange={(event) => setNote(event.target.value)}
/>
</FieldControl>
<FieldMessage
description="Shown with your application."
trailing={`${note.length} / ${NOTE_LIMIT}`}
/>
</Field>
)
}
Enter your highlights from this role.
import { Field, FieldControl, FieldLabel, FieldMessage } from '@dex/shared/components/field'
import { Textarea } from '@dex/shared/components/textarea'
export function TextareaInvalid() {
return (
<Field invalid className="max-w-md">
<FieldLabel>Highlights</FieldLabel>
<FieldControl>
<Textarea placeholder="What did you own, and what changed because of it?" />
</FieldControl>
<FieldMessage error="Enter your highlights from this role." />
</Field>
)
}
import { Field, FieldControl, FieldLabel } from '@dex/shared/components/field'
import { Textarea } from '@dex/shared/components/textarea'
export function TextareaDisabled() {
return (
<Field disabled className="max-w-md">
<FieldLabel>Highlights</FieldLabel>
<FieldControl>
<Textarea
defaultValue="Led the move from a monolith to services, cutting deploy time from 40 minutes to 6."
disabled
/>
</FieldControl>
</Field>
)
}
From your CV.
import { Field, FieldControl, FieldLabel, FieldMessage } from '@dex/shared/components/field'
import { Textarea } from '@dex/shared/components/textarea'
export function TextareaReadOnly() {
return (
<Field className="max-w-md">
<FieldLabel>Highlights</FieldLabel>
<FieldControl>
<Textarea
defaultValue="Led the move from a monolith to services, cutting deploy time from 40 minutes to 6."
readOnly
/>
</FieldControl>
<FieldMessage description="From your CV." />
</Field>
)
}
- Use a textarea for anything longer than a sentence, such as a cover note or the highlights of a role. For one line, use an input.
- It grows with its content, then scrolls, so a long entry cannot push a dialog's buttons off the screen.
- Show a character count only when there is a limit. Set
maxLengthand pass the count toFieldMessageastrailing, which puts it at the end of the helper row. - Give a read-only textarea helper text saying where the value came from.