Created
January 21, 2023 11:04
-
-
Save aeither/cded6345625ad32da2b45b63d39ef92e to your computer and use it in GitHub Desktop.
Reactive Tab with daisyUI + tailwind + clsx
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
import clsx from 'clsx' | |
export const Page: FC = ({}) => { | |
const [activeTab, setActiveTab] = useState(1) | |
return ( | |
<> | |
<div className="tabs"> | |
{['List', 'Favourite', 'Profile'].map((title, index) => ( | |
<> | |
<a | |
key={index} | |
className={clsx( | |
'tab tab-bordered', | |
activeTab === index && 'tab-active' | |
)} | |
onClick={() => setActiveTab(index)} | |
> | |
{title} | |
</a> | |
</> | |
))} | |
</div> | |
<div className={clsx(activeTab != 0 && 'hidden')}>Content 1</div> | |
<div className={clsx(activeTab != 1 && 'hidden')}>Content 2</div> | |
<div className={clsx(activeTab != 2 && 'hidden')}>Content 3</div> | |
</> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment