Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input: Easier label styling #726

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/View/Components/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Input extends Component

public function __construct(
public ?string $label = null,
public ?string $labelClass = null,
public ?string $icon = null,
public ?string $iconRight = null,
public ?string $hint = null,
Expand Down Expand Up @@ -66,7 +67,7 @@ public function render(): View|Closure|string

{{-- STANDARD LABEL --}}
@if($label && !$inline)
<label for="{{ $uuid }}" class="pt-0 label label-text font-semibold">
<label for="{{ $uuid }}" @class(['pt-0 label label-text font-semibold', $labelClass])>
<span>
{{ $label }}

Expand Down Expand Up @@ -156,8 +157,13 @@ public function render(): View|Closure|string

{{-- INLINE LABEL --}}
@if($label && $inline)
<label for="{{ $uuid }}" class="absolute text-gray-400 duration-300 transform -translate-y-1 scale-75 top-2 origin-left rtl:origin-right rounded px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-focus:dark:text-blue-500 peer-placeholder-shown:scale-100 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-2 peer-focus:scale-75 peer-focus:-translate-y-1 @if($inline && $icon) start-9 @else start-3 @endif">
{{ $label }}
<label for="{{ $uuid }}"
@class([
'absolute text-gray-400 duration-300 transform -translate-y-1 scale-75 top-2 origin-left rtl:origin-right rounded px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-focus:dark:text-blue-500 peer-placeholder-shown:scale-100 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-2 peer-focus:scale-75 peer-focus:-translate-y-1',
($inline && $icon) ? 'start-9' : 'start-3',
$labelClass
])>
{{ $label }}
</label>
@endif

Expand Down