Socket
Socket
Sign inDemoInstall

@sygnas/tabs

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sygnas/tabs

Simple tab script. シンプルなタブ


Version published
Weekly downloads
4
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

syg-tabs

カスタマイズ可能なタブナビゲーションを実装。

Description

シンプルなタブナビゲーションを使いたい人向け。

タブナビゲーションのスクリプトという名目ですが、data属性を与えるだけでコンテンツ制御を何もしません。 その代わり CSS で好きなように見た目をカスタマイズできます。

  • data属性でターゲットとなるコンテンツ、前後ボタン、初期表示ページを設定
  • URLのハッシュでも初期表示ページを設定可能
  • 表示エフェクトに関しては全てcssにて行う。
  • 非表示状態についてもcssで定義する。

注意:IEで使う場合は polyfill が必要です。

Usage

DEMO

Install

npm install --save @sygnas/tabs

html

<!-- <a href="#{番号}"> でコンテンツ番号を指定-->
<!-- data-tabs-content="{コンテンツのセレクタ}" -->
<ul class="js-tabs" data-tabs-content=".js-tabs-content">
    <li><a href="#0">PROFILE</a></li>
    <li><a href="#1">DISCOGRAPHY</a></li>
</ul>

<!-- 配置順がそのままコンテンツ番号になる -->
<div class="js-tabs_content">コンテンツ 0</div>
<div class="js-tabs_content">コンテンツ 1</div>

Sass

.js-tabs{
    // タブボタン
    a{
        // アクティブ状態
        &[data-tabs-active = "true"]{
            background-color: #ccc;
        }
    }
}



// 表示切り替えコンテンツ
.js-tab-content{
    display: none;

    // アクティブ状態
    &[data-tabs-active = "true"]{
        display: block;
    }
}

Script

import Tabs from '@sygnas/tabs';
const tab = new Tabs('.js-tabs');

Data attributes

data属性初期値説明
data-tabs-content切り替え対象コンテンツのセレクタ
data-tabs-prev戻るボタンのセレクタ
data-tabs-next進むボタンのセレクタ
data-tabs-initial0初期状態で表示するページ番号
data-tabs-hashURLハッシュに対応するなら "true"。 Options より優先される

Options

const tab = new Tabs('.js-tabs', {
    tab_selector: 'button',
    use_url_hash: true
});
項目初期値説明
tab_selector'a'タブボタンのセレクタ。<button> を使いたい時などに変更
use_url_hashfalseタブ状態をURLに反映したり、URLから初期表示ページを設定出来るようにする

License

MIT

Keywords

FAQs

Package last updated on 15 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc