-
Notifications
You must be signed in to change notification settings - Fork 3
/
tabs.html
60 lines (57 loc) · 2.48 KB
/
tabs.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tabs</title>
<script src="https://cdn.tailwindcss.com"></script>
<script defer src="https://unpkg.com/@alpinejs/[email protected]/dist/cdn.min.js"></script>
<script src="//unpkg.com/alpinejs" defer></script>
</head>
<style>
[x-cloak] { display: none !important; }
</style>
<body class="bg-gray-100">
<!-- Layout -->
<div class="flex items-center justify-center h-screen max-w-2xl px-2 mx-auto">
<div x-data="{ tab: $persist('1')}" class="w-full rounded-md">
<!-- Tabs Navigation -->
<div class="flex justify-end px-4 pt-3 space-x-4 font-bold text-white bg-gray-600 text rounded-tr-md rounded-tl-md">
<button @click="tab = '1'"
:class="{ 'bg-gray-700 transition transform ease-in-out duration-300': tab === '1' }"
class="px-4 py-2 font-bold tracking-wider rounded-tr-md rounded-tl-md">
Tab 1
</button>
<button @click="tab = '2'"
:class="{ 'bg-gray-700 transition transform ease-in-out duration-300': tab === '2' }"
class="px-4 py-2 font-bold tracking-wider rounded-tr-md rounded-tl-md">
Tab 2
</button>
</div>
<!-- End Tabs Navigation -->
<!-- Tabs Content -->
<div x-cloak class="flex px-4 py-2 tracking-wider text-white bg-gray-700 h-72">
<!-- Tab 1 -->
<div x-show="tab === '1'">
This tabs using persist plugin
</div>
<!-- End Tab 1 -->
<!-- Tab 2 -->
<div x-show="tab === '2'"
class="space-y-3">
<a href="https://alpinejs.dev/plugins/persist" class="font-semibold underline"># Persist Plugin</a>
<div class="">Alpine's Persist plugin allows you to persist Alpine state across page loads.</div>
<div class="">
This is useful for persisting search filters, <span class="font-semibold">active tabs</span> ,
and other features where users will be frustrated if their configuration is reset after refreshing or leaving and revisiting a page.
</div>
</div>
<!-- End Tab 2 -->
</div>
<!-- End Tabs Content -->
</div>
</div>
<!-- End Layout -->
</body>
</html>