Rost

← All components

component

Textarea

A text field for several lines, with Input's label, help line, error and focus ring.

In code Contract: review Guidance: agreed Contract on GitHub Figma 528:814 As markdown
Only you see this.
Default · Not selected · Not error
Only you see this.
Default · Selected · Not error
Only you see this.
Disabled · Not selected · Not error
Keep it under 500 characters.
Default · Not selected · Error
Keep it under 500 characters.
Default · Selected · Error
Only you see this.
Follows focus

Hover, press or tab to one to see the other 2 states.

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

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.

  • 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-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.

Props

PropTypeValuesDefault
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

  • gap 4px spacing/gap/2xsmall
  • padding-top 12px spacing/gap/small-medium
  • padding-bottom 12px spacing/gap/small-medium
  • padding-left 12px spacing/gap/small-medium
  • padding-right 12px spacing/gap/small-medium
  • border-radius 12px spacing/radius/medium

displayflex · flex-directioncolumn · positionrelative · cursortext

outline

  • border-style solid no token yet
  • border-width 1px spacing/outline/small
  • border-radius 12px spacing/radius/medium
  • opacity 1 opacity/solid

positionabsolute · inset0 · pointer-eventsnone

header

  • gap 8px spacing/gap/small
  • min-height 16px spacing/size/2xsmall

displayflex · align-itemscenter · positionrelative

label

  • font-family 'General Sans Variable' font-family/base
  • font-weight 400 typography/label/font-weight/regular
  • font-size 10px typography/placeholder/font-size
  • line-height 12px typography/placeholder/line-height
  • letter-spacing 0px typography/placeholder/letter-spacing

flex1 0 0 · min-width1px · pointer-eventsnone

icons-alarm

  • width 16px spacing/size/2xsmall
  • height 16px spacing/size/2xsmall
  • mask url(./icon-alarm.svg) center / contain no-repeat on purpose: The icon file itself, the same one Input uses.

displayblock · flex-shrink0

value

  • padding 0px spacing/gap/none
  • font-family 'General Sans Variable' font-family/base
  • font-weight 400 typography/paragraph/font-weight/regular
  • font-size 14px typography/paragraph/font-size
  • line-height 20px typography/paragraph/line-height
  • letter-spacing 0px typography/paragraph/letter-spacing

displayblock · positionrelative · width100% · bordernone · backgroundnone · outlinenone · resizevertical

supportive

  • left 12px spacing/gap/small-medium
  • top calc(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-weight 500 typography/label/font-weight/medium
  • font-size 10px typography/placeholder/font-size
  • line-height 12px typography/placeholder/line-height
  • letter-spacing 0px typography/placeholder/letter-spacing

positionabsolute · white-spacenowrap

focus-ring

  • border-style solid no token yet
  • border-width 2px spacing/outline/medium
  • border-radius 16px spacing/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

PropertyNot errorError
focus-ring.border-colortextarea/… regular/focus/focus-ring #00d669 negative/focus/focus-ring #00d669

Follows state and selected

Not selected

PropertyDefaultHover
icons-alarm.backgroundtextarea/negative/… default/icon #e93120 hover/icon #e93120

Selected

PropertyDefaultHover
icons-alarm.background textarea/negative/focus/icon #e93120·

Follows state and selected and error

Not selected · Not error

PropertyDefaultHoverDisabled
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

PropertyDefaultHoverDisabled
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

PropertyDefaultHoverDisabled
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

PropertyDefaultHoverDisabled
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.display block layout