Vue-tabs-with-active-line
Simple Vue 2 component, that allows you to make tabs with moving bottom line.
Install
via NPM
Usage
Import the component
Define the data for props tabs
, currentTab
, and method for onClick
callback
here's the HTML structure generated from the data entered:
Finally, add some styles for component elements:
.tabs
- component wrapper.tabs__item
- button.tabs__item_active
- active button.tabs__active-line
- bottom line
Be sure to add position: relative;
for .tabs
class
and position: absolute;
with bottom, left, height, background-color
properties for .tabs__active-line
class
Below you'll find basic style in CSS and SCSS
CSS EXAMPLE
SCSS Example
Props
tabs
type: Array
, required: true
The array must contain objects with the following properties:
-
title
- required, typestring
. Title of tab -
value
- required, typestring
. Value of tab -
disabled
- optional, typestring
. Disabled attribute
currentTab
type: String
, required: true
.
Required: true
onClick
type: Function
, required: true
.
Returns new tab value when clicked
wrapperClass
type: String
, required: false
.
Custom class for container
tabClass
type: String
, required: false
.
Custom class for tab item
tabActiveClass
type: String
, required: false
.
Custom class for active tab item
lineClass
type: String
, required: false
.
Custom class for active line
How to run it locally
- Clone repository:
git clone git@github.com:karambafe/vue-tabs-with-active-line.git
- Install cli-service-global:
npm install -g @vue/cli-service-global
Vue CLI 3 docs - Run any vue file with hot reload and static server:
vue serve demo-src/App.vue