Press "Enter" to skip to content

Add Another Vanilla JavaScript Tabbed Content With Equal Height | sv-tabs-js

sv-tabs-js is a JavaScript library of small tabs that helps create tabbed content with equal height support and it automatically adjusts the height of the tabs component based on the longest tabbed content.

It also provides a function to automatically update the hashtag in the URL, which means that users are able to open specific classified content by URL.

How to make use of it:

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

<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 element.

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

4. Determine whether or not they equalize the height of the tabbed content material.

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

5. Determine whether or not so as to add anchor links to tabs.

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

6. Override the default variables to create your individual types.

// 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;

Tabbed Content With Equal Height Support, sv-tabs-js Plugin/Github

See Demo And Download

Official Website(svivian): Click Here

This superior jQuery/javascript plugin is developed by svivian. For extra advanced usage, please go to the official website.

Be First to Comment

    Leave a Reply

    Your email address will not be published.