component
Textarea
A text field for several lines, with Input's label, help line, error and focus ring.
Default · Not selected · Not errorDefault · Selected · Not errorDisabled · Not selected · Not errorDefault · Not selected · ErrorDefault · Selected · ErrorFollows focusHover, press or tab to one to see the other 2 states.
import { Textarea } from 'rost/components/textarea/Textarea'
<Textarea label="Note" supportive="Only you see this." />
<Textarea label="Note" error supportive="Keep it under 500 characters." /> src/components/textarea/Textarea.tsx
import { useId, useRef, useState, type ReactNode, type TextareaHTMLAttributes } from 'react'
import './textarea.css'
export interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
/** The field's name, small at the top. */
readonly label: ReactNode
/** One line of help under the field, or the fix when there's an error. */
readonly supportive?: ReactNode
readonly error?: boolean
/** Forces the focused look, for previews and tests. In use, it follows focus. */
readonly selected?: boolean
}
const b = 'rost-textarea'
/**
* A text field for several lines. Input grown down: the same label, help
* line, error and focus ring, from the same tokens. Built from
* contracts/textarea.contract.yaml.
*/
export function Textarea({
label, supportive, error = false, selected, className, id, rows = 3, onFocus, onBlur, disabled, ...rest
}: TextareaProps) {
const own = useId()
const fieldId = id ?? own
const helpId = `${fieldId}-help`
const [focused, setFocused] = useState(false)
const ref = useRef<HTMLTextAreaElement>(null)
const isSelected = selected ?? focused
const cls = [b, isSelected && `${b}--selected`, error && `${b}--error`, className].filter(Boolean).join(' ')
return (
// The whole field is the target: a press on the padding or the label puts the caret in the textarea.
<div className={cls} onMouseDown={(e) => {
if (disabled || e.target === ref.current) return
e.preventDefault(); ref.current?.focus()
}}>
<span className={`${b}__outline`} />
<span className={`${b}__header`}>
<label className={`${b}__label`} htmlFor={fieldId}>{label}</label>
{error && <span className={`${b}__icons-alarm`} aria-hidden="true" />}
</span>
<textarea
ref={ref}
id={fieldId}
className={`${b}__value`}
rows={rows}
disabled={disabled}
aria-invalid={error || undefined}
aria-describedby={supportive ? helpId : undefined}
onFocus={(e) => { setFocused(true); onFocus?.(e) }}
onBlur={(e) => { setFocused(false); onBlur?.(e) }}
{...rest}
/>
{supportive && <span className={`${b}__supportive`} id={helpId}>{supportive}</span>}
<span className={`${b}__focus-ring`} />
</div>
)
}
The source for everything on this page: contracts/textarea.contract.yaml (opens in a new tab). The CSS, the docs and the checks in each app are built from it.
# yaml-language-server: $schema=../schema/component-contract.schema.json
schemaVersion: 2
id: textarea
name: Textarea
kind: component
status: review
summary: A text field for several lines, with Input's label, help line, error and focus ring.
category: inputs
related: [ input ]
source:
tool: figma
fileKey: 1Zy0wiWKXQAvsfDBX3KR0d
nodeId: "528:814"
url: https://www.figma.com/design/1Zy0wiWKXQAvsfDBX3KR0d/UI-Kit-v01?node-id=528-814
extractedAt: "2026-10-30"
extractedBy: hand
frozenAt: "2026-10-30"
props:
label: { type: slot, notes: "The field's name. Always small at the top, where a filled Input puts it." }
value: { type: slot, notes: "What's typed. In React, the textarea's value." }
placeholder: { type: slot, notes: "Shown in the empty field. Never instead of the label." }
supportive: { type: slot, notes: "One line of help under the field, or the fix when there's an error." }
selected:
type: boolean
default: false
notes: The field has focus. In code it follows focus; `selected` forces it, for previews and tests.
error:
type: boolean
default: false
stateSelectors:
Disabled: ":has(textarea:disabled)"
states: [ Default, Hover, Disabled ]
elements:
root:
notes: "Input's field, grown down. The same 12px padding and corners, and the same tokens for every colour."
styles:
display: { value: flex, assert: false }
flex-direction: { value: column, assert: false }
position: { value: relative, assert: false }
gap: { token: spacing/gap/2xsmall, value: 4px }
padding-top: { token: spacing/gap/small-medium, value: 12px }
padding-bottom: { token: spacing/gap/small-medium, value: 12px }
padding-left: { token: spacing/gap/small-medium, value: 12px }
padding-right: { token: spacing/gap/small-medium, value: 12px }
border-radius: { token: spacing/radius/medium, value: 12px }
cursor: { value: text, assert: false }
outline:
notes: The field's fill and its 1px edge, on their own layer, as in Input.
styles:
position: { value: absolute }
inset: { value: "0" }
border-style: { value: solid }
border-width: { token: spacing/outline/small, value: 1px }
border-radius: { token: spacing/radius/medium, value: 12px }
opacity: { token: opacity/solid, value: "1" }
pointer-events: { value: none, assert: false }
header:
notes: "The label's line, with the alarm at the end when there's an error. 16px tall either way, so the text doesn't move when an error shows up."
styles:
display: { value: flex, assert: false }
align-items: { value: center }
position: { value: relative, assert: false }
gap: { token: spacing/gap/small, value: 8px }
min-height: { token: spacing/size/2xsmall, value: 16px }
label:
notes: "Input's floated label: placeholder type, regular. Unlike Input it never sits large in the field. A box this tall would leave it floating alone in the middle."
styles:
flex: { value: 1 0 0, assert: false }
min-width: { value: 1px, assert: false }
font-family: { token: font-family/base, value: "'General Sans Variable'" }
font-weight: { token: typography/label/font-weight/regular, value: "400" }
font-size: { token: typography/placeholder/font-size, value: 10px }
line-height: { token: typography/placeholder/line-height, value: 12px }
letter-spacing: { token: typography/placeholder/letter-spacing, value: 0px }
pointer-events: { value: none, assert: false }
icons-alarm:
notes: "Input's alarm, at 16px so it fits the label's line. Input draws it at 24 beside a single line."
styles:
display: { value: block, assert: false }
flex-shrink: { value: "0", assert: false }
width: { token: spacing/size/2xsmall, value: 16px }
height: { token: spacing/size/2xsmall, value: 16px }
mask: { value: url(./icon-alarm.svg) center / contain no-repeat, untokenised: "The icon file itself, the same one Input uses." }
value:
notes: "The real `<textarea>`. Its own look goes; it takes the field's type and colour. You can drag it taller, not wider."
styles:
display: { value: block, assert: false }
position: { value: relative, assert: false }
width: { value: 100% }
padding: { token: spacing/gap/none, value: 0px }
border: { value: none, assert: false }
background: { value: none, assert: false }
outline: { value: none, assert: false }
resize: { value: vertical, assert: false }
font-family: { token: font-family/base, value: "'General Sans Variable'" }
font-weight: { token: typography/paragraph/font-weight/regular, value: "400" }
font-size: { token: typography/paragraph/font-size, value: 14px }
line-height: { token: typography/paragraph/line-height, value: 20px }
letter-spacing: { token: typography/paragraph/letter-spacing, value: 0px }
supportive:
notes: "Hangs below the field, outside it, as Input's does. Leave 16px under a field that has one."
styles:
position: { value: absolute }
left: { token: spacing/gap/small-medium, value: 12px }
top: { value: "calc(100% + var(--spacing-gap-2xsmall))", untokenised: "Composed from a token: the field's own height, whatever it is, plus spacing/gap/2xsmall." }
white-space: { value: nowrap, assert: false }
font-family: { token: font-family/base, value: "'General Sans Variable'" }
font-weight: { token: typography/label/font-weight/medium, value: "500" }
font-size: { token: typography/placeholder/font-size, value: 10px }
line-height: { token: typography/placeholder/line-height, value: 12px }
letter-spacing: { token: typography/placeholder/letter-spacing, value: 0px }
focus-ring:
styles:
display: { value: none, assert: false }
position: { value: absolute }
inset: { value: "calc(-1 * var(--spacing-gap-2xsmall))", untokenised: "Composed from a token: the ring sits spacing/gap/2xsmall outside the field." }
border-style: { value: solid }
border-width: { token: spacing/outline/medium, value: 2px }
border-radius: { token: spacing/radius/large, value: 16px }
pointer-events: { value: none, assert: false }
variants:
- when: { state: Default, selected: false, error: false }
figmaNode: "528:761"
elements:
outline:
background: { token: textarea/regular/default/background, value: "#060805" }
border-color: { token: textarea/regular/default/outline, value: "#747573" }
label:
color: { token: textarea/regular/default/label, value: "#999999" }
value:
color: { token: textarea/regular/default/placeholder, value: "#c2c7c3" }
supportive:
color: { token: textarea/regular/default/supportive, value: "#999999" }
- when: { state: Hover, selected: false, error: false }
figmaNode: "528:767"
elements:
outline:
background: { token: textarea/regular/hover/background, value: "#171717" }
border-color: { token: textarea/regular/hover/outline, value: "#999999" }
label:
color: { token: textarea/regular/hover/label, value: "#d3d9d5" }
value:
color: { token: textarea/regular/hover/placeholder, value: "#d3d9d5" }
supportive:
color: { token: textarea/regular/hover/supportive, value: "#d3d9d5" }
- when: { state: Default, selected: true, error: false }
figmaNode: "528:773"
elements:
outline:
background: { token: textarea/regular/focus/background, value: "#060805" }
border-color: { token: textarea/regular/focus/outline, value: "#747573" }
label:
color: { token: textarea/regular/focus/label, value: "#999999" }
value:
color: { token: textarea/regular/focus/placeholder, value: "#c2c7c3" }
supportive:
color: { token: textarea/regular/focus/supportive, value: "#999999" }
focus-ring:
display: { value: block, assert: false }
border-color: { token: textarea/regular/focus/focus-ring, value: "#00d669" }
- when: { state: Disabled, selected: false, error: false }
figmaNode: "528:780"
elements:
outline:
background: { token: textarea/regular/disabled/background, value: "#171717" }
border-color: { token: textarea/regular/disabled/outline, value: "#3a3a3a" }
label:
color: { token: textarea/regular/disabled/label, value: "#555555" }
value:
color: { token: textarea/regular/disabled/placeholder, value: "#555555" }
supportive:
color: { token: textarea/regular/disabled/supportive, value: "#555555" }
- when: { state: Default, selected: false, error: true }
figmaNode: "528:786"
elements:
outline:
background: { token: textarea/negative/default/background, value: "#060805" }
border-color: { token: textarea/negative/default/outline, value: "#f2705f" }
label:
color: { token: textarea/negative/default/label, value: "#e93120" }
value:
color: { token: textarea/negative/default/placeholder, value: "#999999" }
supportive:
color: { token: textarea/negative/default/supportive, value: "#e93120" }
icons-alarm:
background: { token: textarea/negative/default/icon, value: "#e93120" }
- when: { state: Hover, selected: false, error: true }
figmaNode: "528:795"
elements:
outline:
background: { token: textarea/negative/hover/background, value: "#171717" }
border-color: { token: textarea/negative/hover/outline, value: "#e93120" }
label:
color: { token: textarea/negative/hover/label, value: "#f2705f" }
value:
color: { token: textarea/negative/hover/placeholder, value: "#999999" }
supportive:
color: { token: textarea/negative/hover/supportive, value: "#e93120" }
icons-alarm:
background: { token: textarea/negative/hover/icon, value: "#e93120" }
- when: { state: Default, selected: true, error: true }
figmaNode: "528:804"
elements:
outline:
background: { token: textarea/negative/focus/background, value: "#060805" }
border-color: { token: textarea/negative/focus/outline, value: "#f2705f" }
label:
color: { token: textarea/negative/focus/label, value: "#e93120" }
value:
color: { token: textarea/negative/focus/value, value: "#ededed" }
supportive:
color: { token: textarea/negative/focus/supportive, value: "#e93120" }
icons-alarm:
background: { token: textarea/negative/focus/icon, value: "#e93120" }
focus-ring:
display: { value: block, assert: false }
border-color: { token: textarea/negative/focus/focus-ring, value: "#00d669" }
guidance:
status: agreed
use:
- title: More than a line
text: "Text that runs to more than a line: a note on a payment, a message, a description."
show: state=Default, selected=False, error=False
avoid:
- title: One line
text: One line of text, like a name or an amount. That's **Input**.
- title: Rich text
text: Rich text with bold and lists. This is plain text only.
show: state=Default, selected=False, error=False
behaviour: |-
It's Input grown down, with the same tokens for the fill, the edge, the label, the help line and the focus ring. Three things change it:
- **`selected`**: it has focus, so the focus ring shows.
- **`error`**: the edge, label and help text go red, and the alarm shows at the end of the label's line.
- **`state`**: `Default`, `Hover` and `Disabled`.
One difference from Input: the label always sits small at the top. Input's label sits large in an empty field, but in a box three lines tall it would float alone in the middle. It starts three lines tall (`rows`), and you can drag it taller.
I built it in code from Input's contract, then drew it in the kit, on a page of its own, with Input's variables. The seven variants match Figma.
accessibility:
element: "a real `<textarea>` with a `<label for>`. Never a `placeholder` instead of the label."
supportiveText: connected with `aria-describedby`.
error: "`aria-invalid=\"true\"`, and the help text says how to fix it."
colour: an error shows as the alarm icon and the message, not only red.
keyboard: "Tab reaches it and Enter starts a new line, so a form with one can't submit on Enter from inside it."
focus: the ring shows on `:focus-visible` and when you arrive by keyboard. Never remove the outline without the ring.
content: |-
Label: a noun, sentence case ("Note"). Help text: one line, a hint before an error and the fix after it ("Keep it under 500 characters"). The help line hangs below the field, so leave 16px under it.
Install
npx github:Runceanu/rost add textarea It lands in src/rost/textarea/, with what it needs and its contract. Install has the rest.
When to use
More than a line
Text that runs to more than a line: a note on a payment, a message, a description.
When not to use
One line
One line of text, like a name or an amount. That's Input.
Rich text
Rich text with bold and lists. This is plain text only.
Behaviour
It's Input grown down, with the same tokens for the fill, the edge, the label, the help line and the focus ring. Three things change it:
- selected: it has focus, so the focus ring shows.
- error: the edge, label and help text go red, and the alarm shows at the end of the label's line.
- state: Default, Hover and Disabled.
One difference from Input: the label always sits small at the top. Input's label sits large in an empty field, but in a box three lines tall it would float alone in the middle. It starts three lines tall (rows), and you can drag it taller.
I built it in code from Input's contract, then drew it in the kit, on a page of its own, with Input's variables. The seven variants match Figma.
Accessibility
- Element
a real
<textarea>with a<label for>. Never aplaceholderinstead of the label. - Supportive Text
connected with
aria-describedby. - Error
aria-invalid="true", and the help text says how to fix it. - Colour
an error shows as the alarm icon and the message, not only red.
- Keyboard
Tab reaches it and Enter starts a new line, so a form with one can't submit on Enter from inside it.
- Focus
the ring shows on
:focus-visibleand when you arrive by keyboard. Never remove the outline without the ring.
Content
Label: a noun, sentence case ("Note"). Help text: one line, a hint before an error and the fix after it ("Keep it under 500 characters"). The help line hangs below the field, so leave 16px under it.
Props
| Prop | Type | Values | Default |
|---|---|---|---|
label | slot | | |
value | slot | | |
placeholder | slot | | |
supportive | slot | | |
selected | boolean | | false |
error | boolean | | false |
States: Default, Hover, Disabled.
Values
Straight from the contract. Each value sits next to its token, because six tokens here all come out as #3a3a3a and the colour alone can't tell you which one is right.
Never changes
root
-
gap4pxspacing/gap/2xsmall -
padding-top12pxspacing/gap/small-medium -
padding-bottom12pxspacing/gap/small-medium -
padding-left12pxspacing/gap/small-medium -
padding-right12pxspacing/gap/small-medium -
border-radius12pxspacing/radius/medium
displayflex · flex-directioncolumn · positionrelative · cursortext
outline
-
border-stylesolidno token yet -
border-width1pxspacing/outline/small -
border-radius12pxspacing/radius/medium -
opacity1opacity/solid
positionabsolute · inset0 · pointer-eventsnone
header
-
gap8pxspacing/gap/small -
min-height16pxspacing/size/2xsmall
displayflex · align-itemscenter · positionrelative
label
-
font-family'General Sans Variable'font-family/base -
font-weight400typography/label/font-weight/regular -
font-size10pxtypography/placeholder/font-size -
line-height12pxtypography/placeholder/line-height -
letter-spacing0pxtypography/placeholder/letter-spacing
flex1 0 0 · min-width1px · pointer-eventsnone
icons-alarm
-
width16pxspacing/size/2xsmall -
height16pxspacing/size/2xsmall -
maskurl(./icon-alarm.svg) center / contain no-repeaton purpose: The icon file itself, the same one Input uses.
displayblock · flex-shrink0
value
-
padding0pxspacing/gap/none -
font-family'General Sans Variable'font-family/base -
font-weight400typography/paragraph/font-weight/regular -
font-size14pxtypography/paragraph/font-size -
line-height20pxtypography/paragraph/line-height -
letter-spacing0pxtypography/paragraph/letter-spacing
displayblock · positionrelative · width100% · bordernone · backgroundnone · outlinenone · resizevertical
supportive
-
left12pxspacing/gap/small-medium -
topcalc(100% + var(--spacing-gap-2xsmall))on purpose: Composed from a token: the field's own height, whatever it is, plus spacing/gap/2xsmall. -
font-family'General Sans Variable'font-family/base -
font-weight500typography/label/font-weight/medium -
font-size10pxtypography/placeholder/font-size -
line-height12pxtypography/placeholder/line-height -
letter-spacing0pxtypography/placeholder/letter-spacing
positionabsolute · white-spacenowrap
focus-ring
-
border-stylesolidno token yet -
border-width2pxspacing/outline/medium -
border-radius16pxspacing/radius/large
displaynone · positionabsolute · insetcalc(-1 * var(--spacing-gap-2xsmall)) · pointer-eventsnone
Changes by variant
7 variants. Each table is what one thing changes with: a column per error, a row per property. Where every row starts with the same token path, it's written once, under the property.
Follows error
Selected
| Property | Not error | Error |
|---|---|---|
focus-ring.border-colortextarea/… | regular/focus/focus-ring #00d669 | negative/focus/focus-ring #00d669 |
Follows state and selected
Not selected
| Property | Default | Hover |
|---|---|---|
icons-alarm.backgroundtextarea/negative/… | default/icon #e93120 | hover/icon #e93120 |
Selected
| Property | Default | Hover |
|---|---|---|
icons-alarm.background | textarea/negative/focus/icon #e93120 | · |
Follows state and selected and error
Not selected · Not error
| Property | Default | Hover | Disabled |
|---|---|---|---|
label.colortextarea/regular/… | default/label #999999 | hover/label #d3d9d5 | disabled/label #555555 |
outline.backgroundtextarea/regular/… | default/background #060805 | hover/background #171717 | disabled/background #171717 |
outline.border-colortextarea/regular/… | default/outline #747573 | hover/outline #999999 | disabled/outline #3a3a3a |
supportive.colortextarea/regular/… | default/supportive #999999 | hover/supportive #d3d9d5 | disabled/supportive #555555 |
value.colortextarea/regular/… | default/placeholder #c2c7c3 | hover/placeholder #d3d9d5 | disabled/placeholder #555555 |
Selected · Not error
| Property | Default | Hover | Disabled |
|---|---|---|---|
label.color | textarea/regular/focus/label #999999 | · | · |
outline.background | textarea/regular/focus/background #060805 | · | · |
outline.border-color | textarea/regular/focus/outline #747573 | · | · |
supportive.color | textarea/regular/focus/supportive #999999 | · | · |
value.color | textarea/regular/focus/placeholder #c2c7c3 | · | · |
Not selected · Error
| Property | Default | Hover | Disabled |
|---|---|---|---|
label.colortextarea/negative/… | default/label #e93120 | hover/label #f2705f | · |
outline.backgroundtextarea/negative/… | default/background #060805 | hover/background #171717 | · |
outline.border-colortextarea/negative/… | default/outline #f2705f | hover/outline #e93120 | · |
supportive.colortextarea/negative/… | default/supportive #e93120 | hover/supportive #e93120 | · |
value.colortextarea/negative/… | default/placeholder #999999 | hover/placeholder #999999 | · |
Selected · Error
| Property | Default | Hover | Disabled |
|---|---|---|---|
label.color | textarea/negative/focus/label #e93120 | · | · |
outline.background | textarea/negative/focus/background #060805 | · | · |
outline.border-color | textarea/negative/focus/outline #f2705f | · | · |
supportive.color | textarea/negative/focus/supportive #e93120 | · | · |
value.color | textarea/negative/focus/value #ededed | · | · |
Only in some variants
These don't change: they're just set in some variants and not others.
Selected
-
focus-ring.displayblocklayout