app/resources/views/components/input.blade.php

29 lines
922 B
PHP
Raw Normal View History

@props([
'type' => 'text',
'name',
'label' => null,
'placeholder' => '',
'value' => null,
'required' => false,
'autofocus' => false,
])
<div class="mb-4">
@if($label)
<label for="{{ $name }}" class="block text-sm font-medium mb-1">{{ $label }}</label>
@endif
<input type="{{ $type }}"
id="{{ $name }}"
name="{{ $name }}"
value="{{ old($name, $value) }}"
placeholder="{{ $placeholder }}"
{{ $required ? 'required' : '' }}
{{ $autofocus ? 'autofocus' : '' }}
{{ $attributes->merge(['class' => 'w-full p-2 border rounded bg-gray-700 border-secondary text-gray-100 focus:bg-gray-900 focus:outline-none focus:border-accent-blue' . ($errors->has($name) ? ' border-red-500' : '')]) }}>
@error($name)
<span class="text-red-500 text-xs mt-1 block">{{ $message }}</span>
@enderror
</div>