Coder Social home page Coder Social logo

web75018 / v-tabs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lukaszwatroba/v-tabs

0.0 1.0 0.0 149 KB

Dynamic, flexible and accessible AngularJS tabs.

Home Page: http://lukaszwatroba.github.io/v-tabs/

License: MIT License

JavaScript 65.79% CSS 20.32% HTML 13.89%

v-tabs's Introduction

Dynamic, flexible and accessible AngularJS tabs.

  • Easy to use and customize
  • Keyboard accessible
  • Works with (or without) ng-repeat

Demos

Usage

  • If you use bower or npm, just bower/npm install v-tabs. If not, download files from the github repo.

  • Include angular.js, angular-animate.js, v-tabs.js, and v-tabs.css:

<link href="v-tabs.css" rel="stylesheet" />

<script src="angular.js"></script>
<script src="angular-animate.js"></script>

<script src="v-tabs.js"></script>
  • Add ngAnimate and vTabs as dependencies to your application module:
var myApp = angular.module('myApp', ['ngAnimate', 'vTabs']);
  • And put the following markup in your template:
<v-tabs class="vTabs--default" horizontal active="activeTabIndex">
  <v-tab>Tab 1</v-tab>
  <v-tab>Tab 2</v-tab>
  <v-tab>Tab 3</v-tab>
</v-tabs>

<v-pages class="vPages--default" active="activeTabIndex">
  <v-page>
    <h3>Page 1</h3>
    <p>Lorem ipsum dolor sit amet enim. Etiam ullamcorper. Suspendisse a pellentesque dui, non felis.</p>
  </v-page>
  <v-page>
    <h3>Page 2</h3>
    <p>Maecenas malesuada elit lectus felis, malesuada ultricies.</p>
  </v-page>
  <v-page>
    <h3>Page 3</h3>
    <p>Curabitur et ligula. Ut molestie a, ultricies porta urna.</p>
  </v-page>
</v-pages>
  • You can also use v-tabs with ng-repeat:
<v-tabs class="vTabs--default" horizontal active="activeTabIndex">
  <v-tab ng-repeat="page in pages" ng-bind="page.title"></v-tab>
</v-tabs>

<v-pages class="vPages--default" active="activeTabIndex">
  <v-page ng-repeat="page in pages" ng-bind="page.content"></v-page>
</v-pages>

API

Add the control attribute to use API methods:

<v-tabs class="vTabs--default" control="tabs" active="tabs.active">
  <v-tab ng-repeat="page in pages" ng-bind="page.title"></v-tab>
</v-tabs>

<v-pages class="vPages--default" active="tabs.active" ng-swipe-left="tabs.next()" ng-swipe-right="tabs.previous()">
  <v-page ng-repeat="page in pages" ng-bind="page.content"></v-page>
</v-pages>

<button type="button" ng-click="tabs.previous()">Previous</button>
<button type="button" ng-click="tabs.next()">Next</button>

Methods

  • activate(index)
  • next()
  • previous()

Accessibility

vTabs manages keyboard focus and adds some common aria-* attributes. BUT you should additionally place the aria-controls and aria-labelledby:

<v-tabs class="vTabs--default" horizontal control="tabs" active="tabs.active">
  <v-tab id="tab0{{$index}}" aria-controls="page0{{$index}}" ng-repeat="page in pages" ng-bind="page.title"></v-tab>
</v-tabs>

<v-pages class="vPages--default" active="tabs.active" ng-swipe-left="tabs.next()" ng-swipe-right="tabs.previous()">
  <v-page id="page0{{$index}}" aria-labelledby="tab0{{$index}}" ng-repeat="page in pages" ng-bind="page.content"></v-page>
</v-pages>

v-tabs's People

Contributors

lukaszwatroba avatar

Watchers

KHIRANI avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.