# @anypoint-web-components/anypoint-tabs

> Accessible tabs styled for Material Design and Anypoint platform

Latest version **0.1.19** (published 2021-07-07) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @anypoint-web-components/anypoint-tabs
pnpm add @anypoint-web-components/anypoint-tabs
yarn add @anypoint-web-components/anypoint-tabs
bun add @anypoint-web-components/anypoint-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.1.19 |
| Published | 2021-07-07 |
| First published | 2019-08-29 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 7 |
| Unpacked size | 34.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Pawel Psztyc |
| Maintainers | carowright, jarrodek, twoplustwoone, lbauret |
| Keywords | api-components, api-console, anypoint-tabs |

## Links

- npm: https://www.npmjs.com/package/@anypoint-web-components/anypoint-tabs
- Repository: https://github.com/anypoint-web-components/anypoint-tabs
- Homepage: https://github.com/anypoint-web-components/anypoint-tabs#readme
- Issues: https://github.com/anypoint-web-components/anypoint-tabs/issues
- npm.io page: https://npm.io/package/@anypoint-web-components/anypoint-tabs

## Dependencies (7)

- [lit-html](https://npm.io/package/lit-html.md) ^1.4.1
- [lit-element](https://npm.io/package/lit-element.md) ^2.5.1
- [@anypoint-web-components/anypoint-button](https://npm.io/package/@anypoint-web-components/anypoint-button.md) ^1.2.1
- [@anypoint-web-components/material-ripple](https://npm.io/package/@anypoint-web-components/material-ripple.md) ^1.0.1
- [@advanced-rest-client/arc-resizable-mixin](https://npm.io/package/@advanced-rest-client/arc-resizable-mixin.md) ^1.2.2
- [@anypoint-web-components/anypoint-menu-mixin](https://npm.io/package/@anypoint-web-components/anypoint-menu-mixin.md) ^1.1.8
- [@anypoint-web-components/anypoint-control-mixins](https://npm.io/package/@anypoint-web-components/anypoint-control-mixins.md) ^1.2.0

## Recent versions

- 0.1.19 (latest) — 2021-07-07
- 0.1.17 — 2021-05-21
- 0.1.16 — 2021-05-04
- 0.1.15 — 2021-04-23
- 0.1.14 — 2021-04-20
- 0.1.13 — 2021-03-02
- 0.1.12 — 2020-10-01
- 0.1.11 — 2020-05-26
- 0.1.10 — 2019-11-25
- 0.1.9 — 2019-11-20
- 0.1.8 — 2019-11-14
- 0.1.7 — 2019-10-01
- 0.1.6 — 2019-09-19
- 0.1.5 — 2019-09-19
- 0.1.4 — 2019-09-19
- … 4 more at https://npm.io/package/@anypoint-web-components/anypoint-tabs/versions

## README

# Anypoint tabs

This component is based on Material Design menu and adjusted for Anypoint platform components.

Anypoint web components are set of components that allows to build Anypoint enabled UI in open source projects.

Tabs organize content across different screens, data sets, and other interactions.

[![Published on NPM](https://img.shields.io/npm/v/@anypoint-web-components/anypoint-tabs.svg)](https://www.npmjs.com/package/@anypoint-web-components/anypoint-tabs)

[![tests](https://github.com/anypoint-web-components/anypoint-tabs/actions/workflows/deployment.yml/badge.svg)](https://github.com/anypoint-web-components/anypoint-tabs/actions/workflows/deployment.yml)

## Usage

### Installation

```sh
npm install --save @anypoint-web-components/anypoint-tabs
```

### In a HTML document

```html
<script type="module" src="node_modules/@anypoint-web-components/anypoint-tabs/anypoint-tabs.js"></script>
<script type="module" src="node_modules/@anypoint-web-components/anypoint-tabs/anypoint-tab.js"></script>

<anypoint-tabs selected="1">
  <anypoint-tab>Tab one</anypoint-tab>
  <anypoint-tab>Tab two</anypoint-tab>
  <anypoint-tab>Tab three</anypoint-tab>
</anypoint-tabs>
```

### In a LitElement

```js
import { LitElement, html } from 'lit-element';
import '@anypoint-web-components/anypoint-tabs/anypoint-tabs.js';
import '@anypoint-web-components/anypoint-tabs/anypoint-tab.js';

class SimpleElement extends ControlStateMixin(ButtonStateMixin(LitElement)) {
  render() {
    return html`
    <anypoint-tabs .selected="${this.selectedTab}" @selected-changed="${this._tabHandler}">
      <anypoint-tab>Tab one</anypoint-tab>
      <anypoint-tab>Tab two</anypoint-tab>
      <anypoint-tab>Tab three</anypoint-tab>
    </anypoint-tabs>
    `;
  }

  _tabHandler(e) {
    this.selectedTab = e.detail.value;
  }
}
window.customElements.define('simple-element', SimpleElement);
```

### Styles

Anypoint tabs comes with 2 predefined styles:

- Material - (default) - Material Design styled tabs
- Compatibility To provide compatibility with Anypoint design

See [Tabs](https://material.io/components/tabs/) documentation in Material Design documentation for principles and anatomy of tabs.

### Scrollable tabs

When tabs takes more place than available then set `scrollable` property to enable scrolling.

```html
<div class="width: 320px;">
  <anypoint-tabs selected="0" scrollable>
    <anypoint-tab>Tab one</anypoint-tab>
    <anypoint-tab>Tab two</anypoint-tab>
    <anypoint-tab>Tab three</anypoint-tab>
    <anypoint-tab>Tab four</anypoint-tab>
  </anypoint-tabs>
</div>
```

### Fit container

When the `fitContainer` property is set the tabs expands to full width of the container.

```html
<anypoint-tabs selected="0" fitContainer>
  <anypoint-tab>Tab one</anypoint-tab>
  <anypoint-tab>Tab two</anypoint-tab>
  <anypoint-tab>Tab three</anypoint-tab>
  <anypoint-tab>Tab four</anypoint-tab>
</anypoint-tabs>
```

Otherwise they stay aligned to left/right (depending on dir value)

### Dynamic content

The tab resets when it's children changes.

Note that the tabs won't change the selection when children change. You need to handle this
situation depending on your application context.

```js
render() {
  return html`
  <anypoint-tabs>
    <anypoint-tab>Tab one</anypoint-tab>
    ${this.renderTwo ? html`<anypoint-tab>Tab two</anypoint-tab>` : ''}
    <anypoint-tab>Tab three</anypoint-tab>
  </anypoint-tabs>
  `;
}
```

## Development

```sh
git clone https://github.com/anypoint-web-components/anypoint-tabs
cd anypoint-tabs
npm install
```

### Running the demo locally

```sh
npm start
```

### Running the tests

```sh
npm test
```

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