Tabbed Content Using Alpine JS
Create tabbed page content with anchors to directly open any tab
Last updated
<div x-show="tab == '#tab1'" x-cloak>
<p>This is the content of Tab 1</p>
</div>
<div x-show="tab == '#tab2'" x-cloak>
<p>This is the content of Tab 2</p>
</div>
<div x-show="tab == '#tab3'" x-cloak>
<p>This is the content of Tab 3</p>
</div>
<div class="flex flex-row justify-between">
<a class="px-4 border-b-2 border-gray-900 hover:border-teal-300"
href="#" x-on:click.prevent="tab='#tab1'">Tab1</a>
<a class="px-4 border-b-2 border-gray-900 hover:border-teal-300"
href="#" x-on:click.prevent="tab='#tab2'">Tab2</a>
<a class="px-4 border-b-2 border-gray-900 hover:border-teal-300"
href="#" x-on:click.prevent="tab='#tab3'">Tab3</a>
</div><div x-data="{ tab: '#tab1' }" class="">
<!-- Links here -->
<!-- Tab Content here -->
</div>
<div x-data="{ tab: window.location.hash ? window.location.hash : '#tab1' }"><form class="" action="{{ route('student.password.change') }}#password" method="POST" >