Tabby is an accessible tab library built entirely with CSS.
Quick start
There are 3 ways to get started with tabby.css:
Install manually
Download Tabby and link css/tabby.min.css
in the <head>
of your website.
<link rel="stylesheet" href="css/tabby.min.css" />
Usage from CDN
Alternatively, you can use jsDelivr CDN to link tabby.css
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tabbycss/tabby/css/tabby.min.css" />
Install with NPM
npm install @tabbycss/tabby
Usage in HTML
index.html
<div role="tablist" class="tabby">
<a role="tab" class="tab" selected>
Movies
<div class="tab-border"></div>
</a>
<a role="tab" class="tab">
Shows
<div class="tab-border"></div>
</a>
<a role="tab" class="tab" disabled>
Disabled
<div class="tab-border"></div>
</a>
</div>
To add functionality to tabby we can add this snippet of javascript.
index.html
<script>
const Tabby = document.querySelectorAll('.tabby');
Tabby.forEach(container => {
const Tabs = container.querySelectorAll('.tab');
Tabs.forEach(item => {
item.addEventListener('click', () => {
Tabs.forEach(i => i.removeAttribute('selected'));
item.setAttribute('selected', '');
});
});
});
</script>
Check out the demo on codepen.
Copyright and license
Licensed under the MIT License, Copyright © 2024-present tabbycss.
See LICENSE for more information.