The example below loads live from Storybook; open it in Storybook to use the controls.
Default
Section titled “Default”Textarea starts three lines high (rows) and grows with its content up to maxRows lines. Label, help text and error are bound through Field.
Help text goes here.
import { Textarea } from '@bigbang/ui';
export default function Default() { return ( <div className="max-w-96"> <Textarea label="Field label" description="Help text goes here." /> </div> );}Character counter
Section titled “Character counter”maxLength and showCount turn on the counter. From 80 % of the limit the remaining characters are announced politely; over the limit the field turns invalid. Typing is not blocked.
import { Provider, Textarea } from '@bigbang/ui';import { useState } from 'react';
export default function Counter() { const [value, setValue] = useState(''); return ( <Provider locale="en-GB"> <div className="max-w-96"> <Textarea label="Field label" maxLength={40} showCount value={value} onValueChange={setValue} /> </div> </Provider> );}Auto-resize
Section titled “Auto-resize”By default (autoResize) the field grows with its content from rows up to maxRows lines; then it scrolls, and there is no resize handle. Set autoResize={false} for a fixed height that the user can resize vertically.
import { Textarea } from '@bigbang/ui';
export default function AutoResize() { return ( <div className="max-w-96"> <Textarea label="Field label" rows={2} autoResize maxRows={5} /> </div> );}States
Section titled “States”Required with an error, read-only and disabled fields.
import { Provider, Textarea } from '@bigbang/ui';
export default function States() { return ( <Provider locale="en-GB"> <div className="flex max-w-96 flex-col gap-lg"> <Textarea label="Field label" required error="This field cannot be empty." /> <Textarea label="Field label" defaultValue="Sample text" readOnly /> <Textarea label="Field label" defaultValue="Sample text" disabled /> </div> </Provider> );}Light and dark mode
Section titled “Light and dark mode”Colours come from the color-border-*, color-surface-* and color-text-* tokens.
import { Provider, Textarea } from '@bigbang/ui';
export default function States() { return ( <Provider locale="en-GB"> <div className="flex max-w-96 flex-col gap-lg"> <Textarea label="Field label" required error="This field cannot be empty." /> <Textarea label="Field label" defaultValue="Sample text" readOnly /> <Textarea label="Field label" defaultValue="Sample text" disabled /> </div> </Provider> );}