Presets

Blocks

Get PRO

Need premium blocks and templates? Upgrade to PRO and get access.

Upgrade
JoinLogin
Presets
Monochrome
Overview
  • Introduction
  • Components
  • Installation
Components
  • Accordion
  • Alert
  • Alert Dialog
  • Aspect Ratio
  • Avatar
  • Badge
  • Breadcrumb
  • Button
  • Button Group
  • CalendarNEW
  • Card
  • CarouselNEW
  • Checkbox
  • Collapsible
  • Dialog
  • Dropdown Menu
  • Empty
  • Field
  • Input
  • Input Group
  • Item
  • Kbd
  • Label
  • Native Select
  • Scroll Area
  • SelectNEW
  • Separator
  • SwitchNEW
  • Table
  • Tabs
  • Textarea
  • TooltipNEW

Textarea

PreviousNext

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

1import { Textarea } from "@/components/ui/textarea";23export default function Preview() {4  return <Textarea class="max-w-sm" placeholder="Type your message here." />;

Installation

pnpm dlx sprawlify@latest add textarea
npx sprawlify@latest add textarea
yarn sprawlify@latest add textarea
bunx --bun sprawlify@latest add textarea

Install the following dependencies:

pnpm add @sprawlify/primitives @sprawlify/solid
npm install @sprawlify/primitives @sprawlify/solid
yarn add @sprawlify/primitives @sprawlify/solid
bun add @sprawlify/primitives @sprawlify/solid

Add the following files to your project:

textarea.tsx
1import { cn } from "@/lib/utils";2import { sprawlify } from "@sprawlify/solid";3import type { ComponentProps } from "solid-js";4import { splitProps } from "solid-js";56function Textarea(props: ComponentProps<typeof sprawlify.textarea>) {7  const [local, others] = splitProps(props, ["class"]);89  return (10    <sprawlify.textarea11      data-scope="textarea"12      data-part="root"13      data-slot="textarea"14      class={cn(15        "border-input dark:bg-input/30 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 disabled:bg-input/50 dark:disabled:bg-input/80 rounded-lg border bg-input/30 px-2.5 py-2 text-base transition-colors focus-visible:ring-3 aria-invalid:ring-3 md:text-sm placeholder:text-muted-foreground flex field-sizing-content min-h-16 w-full outline-none disabled:cursor-not-allowed disabled:opacity-50",16        local.class,17      )}18      {...others}19    />20  );21}2223export { Textarea };24

Update the import paths to match your project setup.

Usage

1import { Textarea } from "@/components/ui/textarea"
1<Textarea />

Examples

Button

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

1import { Button } from "@/components/ui/button";2import { Textarea } from "@/components/ui/textarea";34export default function Preview() {

Disabled

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

1import { Field, FieldLabel } from "@/components/ui/field";2import { Textarea } from "@/components/ui/textarea";34export default function Preview() {

Field

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

1import { Field, FieldDescription, FieldLabel } from "@/components/ui/field";2import { Textarea } from "@/components/ui/textarea";34export default function Preview() {

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.

1import { Field, FieldDescription, FieldLabel } from "@/components/ui/field";2import { Textarea } from "@/components/ui/textarea";34export default function Preview() {

On This Page

InstallationUsageExamplesButtonDisabledFieldInvalid

Get PRO

Need premium blocks and templates? Upgrade to PRO and get access.