# zensele-tabs

> Svelte tabs component

Latest version **0.0.17** (published 2020-06-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install zensele-tabs
pnpm add zensele-tabs
yarn add zensele-tabs
bun add zensele-tabs
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.17 |
| Published | 2020-06-15 |
| First published | 2020-05-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 237.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Stefan Stoichev @countnazgul |
| Maintainers | stefan.stoichev |
| Keywords | svelte, tabs, tab |

## Links

- npm: https://www.npmjs.com/package/zensele-tabs
- Repository: https://github.com/countnazgul/zensele-tabs
- Issues: https://github.com/countnazgul/zensele-tabs/issues
- Funding: https://ko-fi.com/stefanstoichev
- npm.io page: https://npm.io/package/zensele-tabs

## Alternatives

- [@lexical/table](https://npm.io/package/@lexical/table.md) — 3.0M weekly downloads
- [mantine-datatable](https://npm.io/package/mantine-datatable.md) — 98.2K weekly downloads
- [react-native-collapsible-tab-view](https://npm.io/package/react-native-collapsible-tab-view.md) — 70.6K weekly downloads
- [@handsontable/vue3](https://npm.io/package/@handsontable/vue3.md) — 16.1K weekly downloads
- [vuewordcloud](https://npm.io/package/vuewordcloud.md) — 7.2K weekly downloads

## Recent versions

- 0.0.17 (latest) — 2020-06-15
- 0.0.16 — 2020-06-14
- 0.0.15 — 2020-06-14
- 0.0.14 — 2020-06-14
- 0.0.13 — 2020-06-11
- 0.0.11 — 2020-06-11
- 0.0.10 — 2020-06-01
- 0.0.9 — 2020-06-01
- 0.0.8 — 2020-05-31
- 0.0.7 — 2020-05-30
- 0.0.6 — 2020-05-30
- 0.0.5 — 2020-05-29
- 0.0.4 — 2020-05-29
- 0.0.3 — 2020-05-29
- 0.0.2 — 2020-05-29
- … 1 more at https://npm.io/package/zensele-tabs/versions

## README

[![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/T6T0148ZP)

# zenSele Tabs

`Svelte` tab bar component.

### Demo

Check out this [repl](https://svelte.dev/repl/b3842886317b4e4e93986c629de007e7?version=3.21.0)

### Install

    npm install --save zensele-tabs

### Usage

- Arrays

  ```javascript
  <script>
      import { Tabs } from "zensele-tabs";

      let tabs = ["One", "Two", "Three"];
  </script>

  <div>
      <Tabs {tabs}/>
  </div>
  ```

- Object Arrays - when passing object arrays then we need to specify which property of the object to be used as label

  ```javascript
  <script>
      import { Tabs } from "zensele-tabs";

      let tabs = [
          { name: "One 1", blah: 123 },
          { name: "Two 2", blah: 123 },
          { name: "Three 3", blah: 123 },
      ];
  </script>

  <div>
      <Tabs {tabs} property={'name'}/>
  </div>
  ```

## Properties

- `tabs` - array (or objects array) with the values that should be displayed as labels
- `color` - what color to be the active tab text and bottom border
- `property` - when object array is passed, as `tabs`, specify which object property to be used as label
- `showNavigation` - (default `true`) When its set to `false` the navigation arrows will be shown only when there is no enough space for all the tabs to be shown at the same time
- `enableDelete` - (default `true`) show/hide delete icon
- `enableAdd` - (default `true`) show/hide add icon
- `maxWidth` - (default `null`, **optional**)  control the max width, in `px`, of the tabs. Example: `maxWidh="{300}"`

## Events

- `tabIndexChange` - when tab index is changed then this event will be dispatched. The data in the event will return the index and the data of the selected tab.

  Having the code below:

  ```javascript
  <script>
      import { Tabs } from "zensele-tabs";

      let tabs = [
          { name: "One 1", blah: 123 },
          { name: "Two 2", blah: 123 },
          { name: "Three 3", blah: 123 },
      ];
  </script>

  <div>
      <Tabs
          {tabs}
          property={'name'}
          on:tabIndexChange={(event) => console.log(event.detail)/>
  </div>
  ```

  And if we select the second element (`{ name: "Two 2", blah: 123 }`) will output the following data in the console:

  ```javascript
  {
      index: 1,
      data: {
          name: "Two 2"
          blah: 123
      }
  }
  ```

  - `addTab` - when add tab button is pressed. Apart from the event iteself no other details are passed
  - `removeTab` - each tab have a remove button when the tab is active). The event returns the index of the tab that triggered it

## Setting active tab

The component expose `selectedTabIndex` function which is used to set the active tab. Just pass the required tab index that need to be "activated"

```javascript
<script>
    import { Tabs } from "zensele-tabs";

    let tabBar;
    function changedType(type) {
        tabBar.selectedTabIndex(0)
    }

    let tabs = [
        { name: "One 1", blah: 123 },
        { name: "Two 2", blah: 123 },
        { name: "Three 3", blah: 123 },
    ];

</script>

<div>
    <Tabs {tabs} bind:this="{tabBar}"/>
</div>
```

---
_Source: https://npm.io/package/zensele-tabs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
