Tabbed Content With Equal Height Support – sv-tabs-js

Category: Javascript | February 27, 2024
Views Total:55 views
Official Page:Go to website
Last Update:February 27, 2024


Tabbed Content With Equal Height Support – sv-tabs-js


A tiny tabs JavaScript library that helps create tabbed content with equal height support.

The library automatically adjusts the height of the tabs component based on the tallest tabbed content.

Also provides a functionality to automatically update hashtag in the URL, which means that the users are able to open specific tabbed content by URL.

How to use it:

1. Insert the sv-tabs-js’ JavaScript and CSS files into the document.

<link rel="stylesheet" href="sv-tabs.css" />
<script src="sv-tabs.js"></script>

2. The required HTML structure for the tabs & tabbed content.

<div class="sv-tabs-wrapper">
  <nav class="sv-tabs-tab-list">
    <a class="sv-tabs-tab active" href="#tab1">Tab 1</a>
    <a class="sv-tabs-tab" href="#tab2">Tab 2: Tab Harder</a>
    <a class="sv-tabs-tab" href="#tab3">3</a>
  <div class="sv-tabs-panel-list">
    <div class="sv-tabs-panel" id="tab2">
      I'll be whatever I wanna do.
    <div class="sv-tabs-panel" id="tab3">
      Interesting. No, wait, the other thing: tedious. Shut up and take my money! OK, if everyone's finished being stupid. And I'd do it again! And perhaps a third time! But that would be it. Throw her in the brig. I'm just glad my fat, ugly mama isn't alive to see this day. File not found. Ah, the 'Breakfast Club' soundtrack! I can't wait til I'm old enough to feel ways about stuff.
    <div class="sv-tabs-panel active" id="tab1">
      You may have to metaphorically make a deal with the devil. And by "devil", I mean Robot Devil. And by "metaphorically", I mean get your coat.

3. Initialize the tabs component.

var tabWrapper = document.querySelector('.sv-tabs-wrapper');
var svTabs = new SV.Tabs(tabWrapper);

4. Determine whether the equalize the height of the tabbed content. Default: false.

var svTabs = new SV.Tabs(tabWrapper,{
    equalHeight: true

5. Determine whether to add anchor links to tabs. Default: false.

var svTabs = new SV.Tabs(tabWrapper,{
    useAnchors: true

6. Override the default variables to create your own styles.

// Compile with `sass sv-tabs.scss:sv-tabs.css --no-source-map`
$spacing-unit: 16px !default;
$base-border: 1px solid #ccc !default;
$bd-rad: 4px !default;
$tab-bg-on: #fff !default;
$tab-bg-off: #eee !default;
$tab-bg-hover: #ddd !default;
$tab-text-on: #666 !default;
$tab-text-off: #666 !default;


v2.1.0 (02/27/2024)

  • Keep Sass file for backwards compatibility

v2.0.2 (01/03/2024)

  • Bugfix

v2.0.1 (12/10/2023)

  • Restructure code

You Might Be Interested In:

Leave a Reply