Skip to main content

Forms

Textarea code

Copy the implementation or inspect every file that belongs to this component unit.

resources/views/components/ui/textarea.blade.php

@props([
    'rows' => 4,
    'invalid' => false,
    'disabled' => false,
])

@php
    /*
    | Multi-line text input.
    |
    | Usage:
    |   <x-ui.textarea rows="6" placeholder="Tell us more..." />
    */
    $ring = $invalid
        ? 'border-red-400 dark:border-red-500 focus:border-red-500 focus:ring-red-500'
        : 'border-gray-300 dark:border-gray-700 focus:border-brand-500 focus:ring-brand-500';

    $classes = "block w-full rounded-lg bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100 placeholder-gray-400 dark:placeholder-gray-500 shadow-sm text-sm px-3.5 py-2.5 transition focus:ring-1 disabled:opacity-50 disabled:cursor-not-allowed {$ring}";
@endphp

<textarea
    rows="{{ $rows }}"
    @disabled($disabled)
    @if ($invalid) aria-invalid="true" @endif
    {{ $attributes->merge(['class' => $classes]) }}
>{{ $slot }}</textarea>