Last active
September 19, 2020 12:35
-
-
Save jamiecarter7/06575a6ec77f77f60b219ba448fcccfb to your computer and use it in GitHub Desktop.
iOS 14 Segmented Control with Vue and TailwindCSS - HTML Template
This file contains hidden or 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
<div class="bg-gray-200 rounded-lg" style="padding: 2px;"> | |
<div class="relative flex items-center"> | |
<!-- tab dividers --> | |
<div class="absolute w-full"> | |
<div class="w-1/3 flex justify-between m-auto"> | |
<div class="h-3 w-px bg-gray-400 rounded-full opacity-0 transition-opacity duration-100 ease-in-out" :class="{ 'opacity-100': selectedTab === 'segment3'}"></div> | |
<div class="h-3 w-px bg-gray-400 rounded-full opacity-0 transition-opacity duration-100 ease-in-out" :class="{ 'opacity-100': selectedTab === 'segment1'}"></div> | |
</div> | |
</div> | |
<!-- white sliding tab block --> | |
<div class="absolute left-0 inset-y-0 w-1/3 flex bg-white transition-all ease-in-out duration-200 transform rounded-md shadow" :class="{'translate-x-0': selectedTab === 'segment1', 'translate-x-full': selectedTab === 'segment2', 'translate-x-fullx2': selectedTab === 'segment3'}"></div> | |
<!-- clickable buttons --> | |
<div class="relative flex-1 flex text-sm font-semibold capitalize items-center justify-center cursor-pointer m-px p-px" @click="selectedTab = 'segment1'">Segment 1</div> | |
<div class="relative flex-1 flex text-sm font-semibold capitalize items-center justify-center cursor-pointer m-px p-px" @click="selectedTab = 'segment2'">Segment 2</div> | |
<div class="relative flex-1 flex text-sm font-semibold capitalize items-center justify-center cursor-pointer m-px p-px" @click="selectedTab = 'segment3'">Segment 3</div> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment