AppyKit UI

Textarea

A multi-line input field for longer text content.

import { Text } from "@/components/ui/text";
import { Textarea } from "@/components/ui/textarea";
import React from "react";
import { View } from "react-native";
export default function TextAreaDemo() {
const [value, setValue] = React.useState("");
return (
 <View className="flex-1  justify-center items-center p-6  bg-white">
   <View className="grid gap-2 w-80">
     <Text className="font-semibold">Description</Text>
     <Textarea
       className="min-h-20"
       placeholder="Please include all information relevant to your issue"
       value={value}
       onChangeText={setValue}
       aria-labelledby="textareaLabel"
     />
   </View>
 </View>
);
}

Installation

npx appykit@latest add textarea

Create a folder named ui under component folder in your project and add the following code in a file named textarea.tsx:

import * as React from 'react';
import { TextInput, type TextInputProps } from 'react-native';
import { cn } from '@/lib/utils';

function Textarea({
  className,
  multiline = true,
  numberOfLines = 4,
  placeholderClassName,
  ...props
}: TextInputProps & {
  ref?: React.RefObject<TextInput>;
}) {
  return (
    <TextInput
      className={cn(
        'web:flex min-h-[80px] w-full rounded-xl border border-input bg-background px-3 py-2 text-base lg:text-sm native:text-[14px] native:leading-[1.25] text-foreground web:ring-offset-background placeholder:text-muted-foreground web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2 ',
        props.editable === false && 'opacity-50 web:cursor-not-allowed',
        className
      )}
      placeholderClassName={cn('text-muted-foreground ', placeholderClassName)}
      multiline={multiline}
      numberOfLines={numberOfLines}
      textAlignVertical='top'
      {...props}
    />
  );
}

export { Textarea };

This component depends on the Text component. Please follow the installation guide here before using the Textarea.

Update the import paths to match your project setup.

Usage

import { Textarea } from "@/components/ui/textarea";
<Textarea
  className="min-h-20"
  placeholder="Please include all information relevant to your issue"
  value={value}
  onChangeText={setValue}
  aria-labelledby="textareaLabel"
/>

On this page