Components
Textarea

Textarea

The Textarea component is used to create multi-line text input fields. It provides the ability to auto-adjust the height of the textarea based on its content, making it suitable for various text input scenarios.

Props

NameTypeDefaultDescription
valuestringThe current value of the textarea.
onChange(event: React.ChangeEvent) => voidA function to handle changes in the textarea's content.
disabledbooleanfalseIf true, the textarea is disabled and cannot be interacted with.
successbooleanfalseIf true, the textarea is in a success state.
warningbooleanfalseIf true, the textarea is in a warning state.
errorbooleanfalseIf true, the textarea is in an error state.
size"default" | "large" | "medium" | "small" | "mini""default"The size of the textarea. See available sizes below.
autosizeboolean | { minRows?: number, maxRows?: number }{ minRows: 2, maxRows: 5 }Controls the auto-sizing behavior of the textarea. If true, it will automatically adjust its height based on content. You can also specify minRows and maxRows for more precise control.
...restPropsVarious HTML attributes and event handlers.Additional attributes and event handlers passed down to the underlying textarea element.

Try It

import { Textarea } from '@kloktun/uikit'
import React, { useState } from 'react';

export default function TextareaExample() {

    const [value, setValue] = useState("");
    const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
        setValue(e.target.value);
    }

    return (
        <div className="flex flex-col gap-4">

            Text: <pre>{value}</pre>

            <Textarea 
                value={value}
                onChange={handleChange}
                placeholder="Write something..."
                autosize={
                    {
                        minRows: 2,
                        maxRows: 5
                    }
                }
            />
        </div>
    );
}