# @polymer/paper-listbox

> Implements an accessible material design listbox

Latest version **3.0.1** (published 2018-09-14) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install @polymer/paper-listbox
pnpm add @polymer/paper-listbox
yarn add @polymer/paper-listbox
bun add @polymer/paper-listbox
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2018-09-14 |
| First published | 2016-02-03 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 19.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | The Polymer Authors |
| Maintainers | aomarks, azakus, bicknellr, emarquez, justinfagnani, keanulee, notwaldorf, polymer-devs, samli, sorvell, usergenic |
| Keywords | web-components, polymer, listbox |

## Links

- npm: https://www.npmjs.com/package/@polymer/paper-listbox
- Repository: https://github.com/PolymerElements/paper-listbox
- Issues: https://github.com/PolymerElements/paper-listbox/issues
- npm.io page: https://npm.io/package/@polymer/paper-listbox

## Dependencies (4)

- [@polymer/polymer](https://npm.io/package/@polymer/polymer.md) ^3.0.0
- [@polymer/paper-styles](https://npm.io/package/@polymer/paper-styles.md) ^3.0.0-pre.26
- [@polymer/iron-behaviors](https://npm.io/package/@polymer/iron-behaviors.md) ^3.0.0-pre.26
- [@polymer/iron-menu-behavior](https://npm.io/package/@polymer/iron-menu-behavior.md) ^3.0.0-pre.26

## Recent versions

- 3.0.1 (latest) — 2018-09-14
- 3.0.0-pre.20 (next) — 2018-06-23
- 1.1.2-pre.3 (preview) — 2017-01-24
- 3.0.0 — 2018-09-13
- 3.0.0-pre.26 — 2018-09-12
- 3.0.0-pre.25 — 2018-08-29
- 3.0.0-pre.24 — 2018-08-29
- 3.0.0-pre.23 — 2018-08-25
- 3.0.0-pre.22 — 2018-08-25
- 3.0.0-pre.21 — 2018-06-23
- 3.0.0-pre.19 — 2018-05-09
- 3.0.0-pre.18 — 2018-05-09
- 3.0.0-pre.17 — 2018-05-08
- 3.0.0-pre.16 — 2018-05-04
- 3.0.0-pre.15 — 2018-05-02
- … 16 more at https://npm.io/package/@polymer/paper-listbox/versions

## README

[![Published on NPM](https://img.shields.io/npm/v/@polymer/paper-listbox.svg)](https://www.npmjs.com/package/@polymer/paper-listbox)
[![Build status](https://travis-ci.org/PolymerElements/paper-listbox.svg?branch=master)](https://travis-ci.org/PolymerElements/paper-listbox)
[![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://webcomponents.org/element/@polymer/paper-listbox)

## &lt;paper-listbox&gt;
`<paper-listbox>` implements an accessible listbox control with Material Design styling. The focused item
is highlighted, and the selected item has bolded text.

```html
<paper-listbox>
  <paper-item>Item 1</paper-item>
  <paper-item>Item 2</paper-item>
</paper-listbox>
```

An initial selection can be specified with the `selected` attribute.

```html
<paper-listbox selected="0">
  <paper-item>Item 1</paper-item>
  <paper-item>Item 2</paper-item>
</paper-listbox>
```

Make a multi-select listbox with the `multi` attribute. Items in a multi-select listbox can be deselected,
and multiple item can be selected.

```html
<paper-listbox multi>
  <paper-item>Item 1</paper-item>
  <paper-item>Item 2</paper-item>
</paper-listbox>
```

### Styling

The following custom properties and mixins are available for styling:

| Custom property | Description | Default |
| --- | --- | --- |
| `--paper-listbox-background-color` | Menu background color | `--primary-background-color` |
| `--paper-listbox-color` | Menu foreground color | `--primary-text-color` |
| `--paper-listbox` | Mixin applied to the listbox | `{}` |

### Accessibility

`<paper-listbox>` has `role="listbox"` by default. A multi-select listbox will also have
`aria-multiselectable` set. It implements key bindings to navigate through the listbox with the up and
down arrow keys, esc to exit the listbox, and enter to activate a listbox item. Typing the first letter
of a listbox item will also focus it.

See: [Documentation](https://www.webcomponents.org/element/@polymer/paper-listbox),
  [Demo](https://www.webcomponents.org/element/@polymer/paper-listbox/demo/demo/index.html).

## Usage

### Installation
```
npm install --save @polymer/paper-listbox
```

### In an html file
```html
<html>
  <head>
    <script type="module">
      import '@polymer/paper-listbox/paper-listbox.js';
    </script>
  </head>
  <body>
    <paper-listbox>
      <div role="option">item 1</div>
      <div role="option">item 2</div>
      <div role="option">item 3</div>
    </paper-listbox>
  </body>
</html>
```
### In a Polymer 3 element
```js
import {PolymerElement, html} from '@polymer/polymer';
import '@polymer/paper-listbox/paper-listbox.js';

class SampleElement extends PolymerElement {
  static get template() {
    return html`
      <paper-listbox>
        <div role="option">item 1</div>
        <div role="option">item 2</div>
        <div role="option">item 3</div>
      </paper-listbox>
    `;
  }
}
customElements.define('sample-element', SampleElement);
```

## Contributing
If you want to send a PR to this element, here are
the instructions for running the tests and demo locally:

### Installation
```sh
git clone https://github.com/PolymerElements/paper-listbox
cd paper-listbox
npm install
npm install -g polymer-cli
```

### Running the demo locally
```sh
polymer serve --npm
open http://127.0.0.1:<port>/demo/
```

### Running the tests
```sh
polymer test --npm
```

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