Textarea

Displays a form textarea or a component that looks like a textarea.

<Textarea Placeholder="Type your message here." />

Installation

blazor-shadcn add textarea

Usage

@using BlazorShadcn.Components.UI
<Textarea Placeholder="Type your message here." />

Examples

Field

Use Field, FieldLabel, and FieldDescription to create a textarea with a label and description.

Enter your message below.

<div class="grid w-full max-w-xs gap-2">
    <Label For="textarea-message">Message</Label>
    <p class="text-muted-foreground text-sm">Enter your message below.</p>
    <Textarea id="textarea-message" Placeholder="Type your message here." />
</div>

Disabled

Use the disabled prop to disable the textarea. To style the disabled state, add the data-disabled attribute to the Field component.

<div class="grid w-full max-w-xs gap-2" data-disabled="true">
    <Label For="textarea-disabled">Message</Label>
    <Textarea id="textarea-disabled" Placeholder="Type your message here." Disabled="true" />
</div>

Invalid

Use the aria-invalid prop to mark the textarea as invalid. To style the invalid state, add the data-invalid attribute to the Field component.

Please enter a valid message.

<div class="grid w-full max-w-xs gap-2" data-invalid="true">
    <Label For="textarea-invalid" Class="text-destructive">Message</Label>
    <Textarea id="textarea-invalid" Placeholder="Type your message here." aria-invalid="true" />
    <p class="text-destructive text-sm">Please enter a valid message.</p>
</div>

Button

Pair with Button to create a textarea with a submit button.

<div class="grid w-full max-w-xs gap-2">
    <Textarea Placeholder="Type your message here." />
    <Button>Send message</Button>
</div>