Code Monkey home page Code Monkey logo

vue-slim-tabs's Introduction

tabs

NPM version NPM downloads CircleCI donate

Install

yarn add vue-slim-tabs

CDN: UNPKG | jsDelivr

Usage

<template>
  <tabs>
    <tab title="Vue">
      This is Vue
    </tab>
    <tab title="React">
      This is React
    </tab>
    <tab title="Svelte">
      This is Svelte
    </tab>
  </tabs>
</template>

<script>
import { Tabs, Tab } from 'vue-slim-tabs'

export default {
  components: {
    Tabs, Tab
  }
}
</script>

<!-- optionally use our default style -->
<style src="vue-slim-tabs/themes/default.css"></style>

You can use it as a plugin if you don't mind registering components globally:

import * as Tabs from 'vue-slim-tabs'

Vue.use(Tabs)
Use a slot as tab title
<template>
  <tabs>
    <tab title-slot="vue">
      This is Vue
    </tab>

    <template slot="vue">
      <strong>Vue</strong>
    </template>
  </tabs>
</template>

Props

<Tabs>

defaultIndex

Type: Number
Default: 0

Index of selected tab on the first render.

onSelect

Type: function
Default: undefined

The function to invoke as user selects a tab by clicking:

function onSelect(e, index) {
  // e: click event
  // index: index of selected tab
}

<Tab>

title

Type: string vNode
Required: required unless titleSlot is set

Use a string or vNode as tab title.

titleSlot

Type: string

Use a slot as the tab title.

disabled

Type: Boolean
Default: undefined

Disable relevant tab, i.e. make it unselectable.

Development

Run the example with Poi:

cd vue-slim-tabs
yarn
yarn dev

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

vue-slim-tabs © egoist, Released under the MIT License.
Authored and maintained by egoist with help from contributors (list).

egoist.moe · GitHub @egoist · Twitter @_egoistlily

vue-slim-tabs's People

Contributors

dependabot-preview[bot] avatar egoist avatar t-cst avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vue-slim-tabs's Issues

Provide types for TypeScript

Issuehunt badges

*.ts

import * as Tabs from 'vue-slim-tabs';

Could not find a declaration file for module 'vue-slim-tabs'. '.../node_modules/vue-slim-tabs/dist/vue-slim-tabs.common.js' implicitly has an 'any' type. Try npm install @types/vue-slim-tabs if it exists or add a new declaration (.d.ts) file containing declare module 'vue-slim-tabs';ts(7016)


IssueHunt Summary

Backers (Total: $100.00)

Submitted pull Requests


Become a backer now!

Or submit a pull request to get the deposits!

Tips


IssueHunt has been backed by the following sponsors. Become a sponsor

Emit event on tab change

Rather than (or in addition to) using an onSelect prop: this.$emit('select', index).

Additionally, onSelect fires every time a tab is selected, even if it's already the active tab. This may not be intended behavior, so:

    switchTab(e, index, isDisabled) {
      // Only fire event/function if not currently selected
      if (!isDisabled && this.selectedIndex !== index) {
        this.selectedIndex = index;
        // Left in place for backwards compatibility
        this.onSelect && this.onSelect(e, index);
        // Not sure if the event variable is actually needed here
        this.$emit('select', index);
      }
    }

tab scroll

how could we scroll through tabs?
via mouse

Tabs hang occasionally

Thanks for the simplicity of tabs component.

I am experiencing the tabs to hang occasionally. After the freeze, one cannot change to another tab anymore and it seems that only part of the tabpage was loaded.

Any thoughts on what may cause the problem? I reproduced the freeze both in Chrome and in Firefox.

I am using an unordered list within a tab, everything item is, therefore, a list item.

Any thoughts greatly appreceated.

cache component in tab content

Every time I switch back to the tab, component in it will be re-mounted. How can I make it cached there? No need to re-mount every time I switch back to it. Thank you!

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.