Last active
December 20, 2021 06:18
-
-
Save shibbirweb/3e6e5ee8c8c18c329bc6f60626aa3e1b to your computer and use it in GitHub Desktop.
Laravel Regular Components
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{-- Anchor tag --}} | |
{{-- | |
Usage Example:: | |
<x-a class="nav-link" href="{{ route('dashboard') }}" exact>Dashboard</x-a> | |
<x-a class="nav-link" :href="route('dashboard')">Dashboard</x-a> | |
<x-a class="nav-link" :href="url('dashboard')">Dashboard</x-a> | |
<x-a class="nav-link" href="{{ url('dashboard') }}">Dashboard</x-a> | |
<x-a class="nav-link" :href="url('dashboard')" active-class="my-active-class">Dashboard</x-a> | |
<x-a class="nav-link" :href="url('dashboard')" activeClass="my-active-class">Dashboard</x-a> | |
<x-a class="nav-link" href="{{ route('dashboard') }}" exact>Dashboard</x-a> | |
<x-a class="nav-link" href="{{ route('dashboard') }}" :exact="true">Dashboard</x-a> | |
--}} | |
@props([ | |
'href' => '#', | |
'activeClass' => 'active', | |
'exact' => false, | |
]) | |
<a {{ $attributes->class([ | |
$activeClass => $exact ? url()->current() == $href : \Illuminate\Support\Str::startsWith(url()->full(), $href), | |
]) }} href="{{ $href }}"> | |
{{ $slot }} | |
</a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment