Pillar UI React Textarea Component documentation

A simple text input field that can be used to collect user input.

Components:

Textarea

Type

Components

import

import { Pillar UI React Textarea Component } from '@pillar-ui/core'

props

Filled

A filled input is a type of input field that has a background color. This makes it easy for users to see where they are typing and to distinguish between input fields.

https://.com
export const FilledTextarea = () => {
  return (
    <Flex gap="sm" direction="column">
      <Textarea aria-label="hello" autoFocus placeholder="Focus" variant="filled" />
      <Textarea aria-label="hello" placeholder="Normal" variant="filled" />
      <Textarea aria-label="hello" disabled placeholder="Disabled" variant="filled" />
      <Textarea aria-label="hello" readOnly placeholder="readOnly" variant="filled" />
      <Textarea aria-label="hello" isInvalid placeholder="Error" variant="filled" />
      <Textarea aria-label="hello" suffixInput={<User width="16" />} placeholder="Error" variant="filled" />
      <Textarea aria-label="hello" prefixInput={<User width="16" />} placeholder="Placeholder" variant="filled" />
      <Textarea
        aria-label="hello"
        prefixInput={'https://'}
        suffixInput=".com"
        defaultValue="Default Value"
        variant="filled"
      />
    </Flex>
  )
}

Outline

The outline variant of the input component is a type of input field that has a border around it. This makes it easy for users to see where they are typing and to distinguish between input fields.

https://.com
export const OutlineTextarea = () => {
  return (
    <Flex gap="sm" direction="column">
      <Textarea variant="outline" aria-label="hello" autoFocus placeholder="Focus" variant="filled" />
      <Textarea variant="outline" aria-label="hello" placeholder="Normal" variant="filled" />
      <Textarea variant="outline" aria-label="hello" disabled placeholder="Disabled" variant="filled" />
      <Textarea variant="outline" aria-label="hello" readOnly placeholder="readOnly" variant="filled" />
      <Textarea variant="outline" aria-label="hello" isInvalid placeholder="Error" variant="filled" />
      <Textarea
        variant="outline"
        aria-label="hello"
        suffixInput={<User width="16" />}
        placeholder="Error"
        variant="filled"
      />
      <Textarea
        variant="outline"
        aria-label="hello"
        prefixInput={<User width="16" />}
        placeholder="Placeholder"
        variant="filled"
      />
      <Textarea
        variant="outline"
        aria-label="hello"
        prefixInput={'https://'}
        suffixInput=".com"
        defaultValue="Default Value"
        variant="filled"
      />
    </Flex>
  )
}

Bordered

The bordered variant of the input component is a type of input field that has a bottom border that visually separates the input from others and shows the edge of the input.

https://.com
export const OutlineInput = () => {
  return (
    <Flex gap="sm" direction="column">
      <Textarea variant="bordered" aria-label="hello" autoFocus placeholder="Focus" variant="filled" />
      <Textarea variant="bordered" aria-label="hello" placeholder="Normal" variant="filled" />
      <Textarea variant="bordered" aria-label="hello" disabled placeholder="Disabled" variant="filled" />
      <Textarea variant="bordered" aria-label="hello" readOnly placeholder="readOnly" variant="filled" />
      <Textarea variant="bordered" aria-label="hello" isInvalid placeholder="Error" variant="filled" />
      <Textarea
        variant="bordered"
        aria-label="hello"
        suffixInput={<User width="16" />}
        placeholder="Error"
        variant="filled"
      />
      <Textarea
        variant="bordered"
        aria-label="hello"
        prefixInput={<User width="16" />}
        placeholder="Placeholder"
        variant="filled"
      />
      <Textarea
        variant="bordered"
        aria-label="hello"
        prefixInput={'https://'}
        suffixInput=".com"
        defaultValue="Default Value"
        variant="filled"
      />
    </Flex>
  )
}

Corner

The corner prop is a prop that can be used to customize the corner radius of the Input component. Valid values for the corner prop are: sharp | xs | sm | md | lg | xl | full

export const CornerInput = () => {
  return (
    <Flex gap="sm" direction="column">
      <Textarea corner="sharp" placeholder="sharp" />
      <Textarea corner="xs" placeholder="xs" />
      <Textarea corner="sm" placeholder="sm" />
      <Textarea corner="md" placeholder="md" />
      <Textarea corner="lg" placeholder="lg" />
      <Textarea corner="xl" placeholder="xl" />
      <Textarea corner="full" placeholder="full" />
    </Flex>
  )
}

Color

  • Type: string
  • Default: primary
  • Options: danger | warning | success | primary | secondary | bg

The color prop can be used to customize the color of the input's border when it is focused. Valid values for the color prop are: primary | purple | secondary | brown | bg

https://.com
export const ColorInput = () => {
  return (
    <Flex gap="sm" direction="column">
      <Textarea color="pri" variant="bordered" autoFocus placeholder="Focus" />
      <Textarea color="war" variant="bordered" autoFocus placeholder="Normal" />
      <Textarea color="sec" variant="outline" autoFocus placeholder="Disabled" />
      <Textarea color="bg" variant="filled" autoFocus placeholder="isInvalid" />
      <Textarea color="suc" variant="bordered" autoFocus prefixInput={<User width="16" />} placeholder="Placeholder" />
      <Textarea
        color="dan"
        variant="bordered"
        autoFocus
        prefixInput={'https://'}
        suffixInput=".com"
        defaultValue="Default Value"
      />
    </Flex>
  )
}

Size

  • Type: string
  • Default: md
  • Options: 2xs | xs | sm | md | lg | xl | 2xl

The size prop of the input component is used to change the size of the input field. The default size is medium md. The following values are supported: sm ,lg

import { Flex, Input } from '@pillar-ui/core'
export const SizeInput = () => {
  return (
    <Flex gap="sm" direction="column">
      <Textarea size="sm" placeholder="Small(sm)" />
      <Textarea placeholder="Medium (md default You don't need it)" />
      <Textarea size="lg" placeholder="Large(lg)" />
    </Flex>
  )
}

Best Practice

  • Use clear and concise labels. The label should be descriptive and accurate, and it should clearly indicate what information is being requested to add label to the input Please wrap it within a FormField Component.
  • Use placeholder text. The placeholder text should provide a hint to the user about what information is expected.
  • Use a consistent style for all input fields. This will help to create a more visually appealing and user-friendly interface. Choose only one variant and use it consistently throughout your site. Do not mix variants within the same site.
  • Validate the input data on both the client and server side. This will help to ensure that the user enters the correct information and provide a good user experience.
  • Provide feedback to the user about the validity of their input data. Use FormController to send error messages to the component, which will then display them to the user.
  • If your input field needs more information, use the hint prop to provide that information to the user. This will help the user to understand what information is expected and to enter the correct information.

Troubleshooting

If you encounter any issues with the Input component, make sure that you have correctly passed the props and values. If you are still having issues, check the console for any error messages.

Conclusion

The Input component is a versatile UI component that can be used to collect user input. It is flexible, customizable, and accessible, making it a great addition to any UI design.