Components
Textarea
Textarea is used when the user needs to enter text that spans multiple lines.
HTML
Press Enter to start editing
Unable to parse html
const Preview = () => { return ( <> <Label htmlFor='my-textarea'>Label</Label> <Textarea id='my-textarea' /> </> ); }; render(<Preview />)
Use
Apply the class name ds-input to <textarea>.
Example
With Rows
Use the rows attribute to set the number of visible rows in the text area.
This only affects the initial height of the field.
HTML
Press Enter to start editing
Unable to parse html
const WithRowsEn = () => { return ( <> <Label htmlFor='my-textarea-rows'>Description</Label> <Textarea id='my-textarea-rows' rows={6} /> </> ); }; render(<WithRowsEn />)
CSS variables and data attributes
Textarea gets styling from ds-input, so we show variables and data attributes from that class here.
Sizes are controlled with data-size and colors with data-color. The component will inherit from the closest parent where these are set.
| Name | Value |
|---|---|
| --dsc-input-padding-block | var(--ds-size-2) |
| --dsc-input-padding-inline | var(--ds-size-3) |
| --dsc-input-padding | var(--dsc-input-padding-block) var(--dsc-input-padding-inline) |
| --dsc-input-size--toggle | var(--ds-size-6) |
| --dsc-input-size | var(--ds-size-12) |
| --dsc-input-background--readonly | var(--ds-color-neutral-surface-tinted) |
| --dsc-input-background | var(--ds-color-neutral-surface-default) |
| --dsc-input-border-color--readonly | var(--ds-color-neutral-border-subtle) |
| --dsc-input-border-color | var(--ds-color-neutral-border-default) |
| --dsc-input-border-style | solid |
| --dsc-input-border-width--toggle | max(var(--ds-border-width-default),calc(var(--ds-size-1)/2)) |
| --dsc-input-border-width | var(--ds-border-width-default) |
| --dsc-input-outline-color--hover | var(--ds-color-neutral-border-default) |
| --dsc-input-outline-color--toggle--hover | var(--dsc-input-accent-color) |
| --dsc-input-outline-width--hover | var(--ds-border-width-default) |
| --dsc-input-outline-style--hover | solid |
| --dsc-input-color--readonly | var(--ds-color-neutral-text-default) |
| --dsc-input-color | var(--ds-color-neutral-text-default) |
| --dsc-input-stroke-color | var(--ds-color-base-contrast-default) |
| --dsc-input-stroke-color--invalid | var(--ds-color-danger-base-contrast-default) |
| --dsc-input-stroke-width | 0.05em |
| --dsc-input-accent-color | var(--ds-color-base-default) |
| --dsc-input-accent-color--invalid | var(--ds-color-danger-text-subtle) |
| --dsc-input-line-height | var(--ds-line-height-md) |
| Name | Value |
|---|---|
| data-width | auto |