Textarea

A flexible textarea component for multi-line text input with support for different sizes, variants, and states.

Import

import { Textarea } from 'rebel-ui';

Usage

<script>
  import { Textarea } from 'rebel-ui';
</script>

<Textarea
  label="Message"
  placeholder="Enter your message"
/>

Sizes

The Textarea component comes in three sizes: sm, md (default), and lg.

<script>
  import { Textarea } from '@rebel-ui/core';
</script>

<div class="flex flex-col gap-4">
  <Textarea
    size="sm"
    label="Small"
    placeholder="Small textarea"
  />
  
  <Textarea
    size="md"
    label="Medium"
    placeholder="Medium textarea"
  />
  
  <Textarea
    size="lg"
    label="Large"
    placeholder="Large textarea"
  />
</div>

Variants

Three variants are available: default, filled, and ghost.

<script>
  import { Textarea } from '@rebel-ui/core';
</script>

<div class="flex flex-col gap-4">
  <Textarea
    variant="default"
    label="Default"
    placeholder="Default variant"
  />
  
  <Textarea
    variant="filled"
    label="Filled"
    placeholder="Filled variant"
  />
  
  <Textarea
    variant="ghost"
    label="Ghost"
    placeholder="Ghost variant"
  />
</div>

States

Required

Add a required indicator to the label.

<script>
  import { Textarea } from '@rebel-ui/core';
</script>

<Textarea
  label="Message"
  required
  placeholder="This field is required"
/>

Disabled

Disable user interaction.

<script>
  import { Textarea } from '@rebel-ui/core';
</script>

<Textarea
  label="Message"
  disabled
  value="This textarea is disabled"
/>

Error and Success States

Display validation states with optional error messages.

<script>
  import { Textarea } from '@rebel-ui/core';
</script>

<div class="flex flex-col gap-4">
  <Textarea
    label="Error State"
    state="error"
    errorMessage="This field is required"
    placeholder="Error state example"
  />
  
  <Textarea
    label="Success State"
    state="success"
    placeholder="Success state example"
  />
</div>

Character Count

Track input length with an optional character limit.

<script>
  import { Textarea } from '@rebel-ui/core';
</script>

<Textarea
  label="Limited Input"
  placeholder="Type something..."
  maxLength={100}
  showCount
/>

Props

PropTypeDefaultDescription
labelstringundefinedLabel text for the textarea
valuestring''Current value of the textarea
placeholderstringundefinedPlaceholder text
size'sm' \| 'md' \| 'lg''md'Size variant of the textarea
variant'default' \| 'filled' \| 'ghost''default'Visual style variant
state'error' \| 'success'undefinedValidation state
errorMessagestringundefinedError message to display
requiredbooleanfalseWhether the field is required
disabledbooleanfalseWhether the textarea is disabled
maxLengthnumberundefinedMaximum character limit
showCountbooleanfalseWhether to show character count
rowsnumber3Number of visible text rows

Events

The component forwards all standard textarea events:

  • on:input
  • on:change
  • on:focus
  • on:blur

Styling

The Textarea component uses CSS custom properties for theming:

:root {
  --rebel-surface: #ffffff;
  --rebel-surface-secondary: #f9fafb;
  --rebel-border: #e5e7eb;
  --rebel-border-light: #f3f4f6;
  --rebel-text-primary: #111827;
  --rebel-text-secondary: #4b5563;
  --rebel-text-tertiary: #9ca3af;
  --rebel-text-disabled: #d1d5db;
  --rebel-brand: #3b82f6;
  --rebel-focus-ring: rgba(59, 130, 246, 0.25);
  --rebel-error: #ef4444;
  --rebel-error-ring: rgba(239, 68, 68, 0.25);
  --rebel-success: #22c55e;
  --rebel-success-ring: rgba(34, 197, 94, 0.25);
  --rebel-disabled-bg: #f3f4f6;
}

Accessibility

The Textarea component follows WAI-ARIA guidelines:

  • Proper labeling using aria-label or <label> elements
  • Error messages are linked using aria-describedby
  • Disabled state is properly conveyed to assistive technologies
  • Focus management with visible focus indicators