0.3.3 • Published 7 months ago

vue3-tabs-chrome v0.3.3

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

vue3-tabs-chrome

A Vue3 component for Chrome-like tabs. Drag-and-drop support provided by Draggabilly by @desandro.

Currently there is only a simple api, waiting for the completion.

If you are using Vue2, please see here. https://github.com/viewweiwu/vue-tabs-chrome

Live Demo

https://viewweiwu.github.io/vue3-tabs-chrome/

Code Sandbox

https://codesandbox.io/s/crazy-mcclintock-p514v?file=/src/App.vue

Install

npm i vue3-tabs-chrome -S

# or

yarn add vue3-tabs-chrome -S

Usage

<template>
  <vue3-tabs-chrome :tabs="tabs" v-model="tab" />
</template>

<script>
  import Vue3TabsChrome from 'vue3-tabs-chrome'
  import 'vue3-tabs-chrome/dist/vue3-tabs-chrome.css'
  import { defineComponent, reactive, ref } from 'vue'

  export default defineComponent({
    components: {
      Vue3TabsChrome
    },
    setup() {
      const tab = ref('google')
      const tabs = reactive([
        {
          label: 'google',
          key: 'google',
          favico: require('./assets/google.jpg')
        },
        {
          label: 'facebook',
          key: 'facebook',
          favico: require('./assets/fb.jpg')
        },
        {
          label: 'New Tab',
          key: 'costom key'
        }
      ])
      return {
        tabs,
        tab
      }
    }
  })
</script>

Attributes

AttributesDescriptionTypeDefault
tabstabs configuration. Details are mentioned below.Array[]
modelValue / v-modelbinding valueString-
insert-to-afterInsert to tag's afterBooleanfalse
is-mousedown-activeset tab is active when mousedownBooleantrue
render-labelrender labelFunction(tab, index)-
auto-hidden-close-icon-widthauto hidden close tab width. if tabWidth < 120, close icon can not show. If you don’t want this feature, you can set the value to 0.Number120
on-closewhen tab close btn click. if return false, it cannot be closed.Function(tab, key, index)-

Tabs Attributes

AttributesDescriptionTypeDefault
labeltab labelString-
keytab keyString-
classtab classString-
closabletab closableBooleantrue
dragabletab dragableBooleantrue
swappabletab swappableBooleantrue
favicotab favico. Custom favico renderer. It uses Vue's render function. It accepts two arguments: the first is h, the second is an object. including tab and indexFunction(tab, index), image src-

Methods

MethodDescriptionParameters
addTabadd tab(tab1, , ...tab, ...tabN)
removeTabremove tab(tabKey or index)

Events

Event NameDescriptionParameters
clickTriggered when the user's pointer is pressed and unpressed and has not moved enough to start dragging.(event, tab, index)
swapSwap tab(tab, targetTab)
removeRemove tab(tab, index)
contextmenuContextmenu event(event, tab, index)
dragstartTab dragstart event(event, tab, index)
draggingTab dragstart event(event, tab, index)
dragendTab dragend event(event, tab)

Slots

AttributesDescription
afterTab after slot

Changelog

0.3.3

2023-10-16

fix: dragable = false No click event is triggered. #19

0.3.2

2022-04-12

fix: remove debugger trigger. #8

0.3.1

2022-04-06

fix: is-mousedown-active bug. #7

0.3.0

feat: add TypeScript support. #PR5

License

MIT

0.3.3

7 months ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.3.0-beta.0

2 years ago

0.2.1-beta.0

2 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago