@polymer/paper-listbox
Version:
Implements an accessible material design listbox
125 lines (112 loc) • 3.99 kB
HTML
<!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<title>paper-listbox demo</title>
<script src="https://unpkg.com/@webcomponents/webcomponentsjs@^2.0.0/webcomponents-loader.js"></script>
<script type="module">
import '@polymer/iron-demo-helpers/demo-pages-shared-styles.js';
import '@polymer/iron-demo-helpers/demo-snippet.js';
import '@polymer/paper-item/paper-item.js';
import '../paper-listbox.js';
import {html} from '@polymer/polymer/lib/utils/html-tag.js';
const template = html
`<custom-style><style is="custom-style" include="demo-pages-shared-styles"></style></custom-style>`;
document.body.appendChild(template.content);
</script>
</head>
<body unresolved>
<custom-style>
<style is="custom-style">
code {
background-color: #eee;
color: #222;
border-radius: 2px;
padding: 2px;
}
paper-listbox {
border: 1px dotted #ccc;
}
paper-item {
cursor: pointer;
}
</style>
</custom-style>
<div class="vertical-section-container centered">
<h3>Initially, no item is selected.</h3>
<demo-snippet>
<template>
<paper-listbox>
<paper-item>Inbox</paper-item>
<paper-item>Starred</paper-item>
<paper-item>Sent mail</paper-item>
<paper-item>Drafts</paper-item>
</paper-listbox>
</template>
</demo-snippet>
</div>
<div class="vertical-section-container centered">
<h3>
Use <code>selected</code> to specity an item to be selected by default.
</h3>
<demo-snippet>
<template>
<paper-listbox selected="0">
<paper-item>Inbox</paper-item>
<paper-item disabled>Starred</paper-item>
<paper-item>Sent mail</paper-item>
<paper-item>Drafts</paper-item>
</paper-listbox>
</template>
</demo-snippet>
</div>
<div class="vertical-section-container centered">
<h3>
Use <code>multi</code> to allow multiple items to be selected.
</h3>
<demo-snippet>
<template>
<paper-listbox multi>
<paper-item>Bold</paper-item>
<paper-item>Italic</paper-item>
<paper-item>Underline</paper-item>
<paper-item>Strikethrough</paper-item>
</paper-listbox>
</template>
</demo-snippet>
</div>
<div class="vertical-section-container centered">
<h3>
Use <code>attr-for-selected</code> (from <code>IronSelectableBehavior</code>)
to select items by attribute value, rather than index.
</h3>
<demo-snippet>
<template>
<dom-bind>
<template is="dom-bind">
<p>"[[itemName]]" is selected.</p>
<paper-listbox attr-for-selected="item-name" selected="{{itemName}}" fallback-selection="None">
<paper-item item-name="None">None</paper-item>
<paper-item item-name="Bold">Bold</paper-item>
<paper-item item-name="Italic">Italic</paper-item>
<paper-item item-name="Underline">Underline</paper-item>
<paper-item item-name="Strikethrough">Strikethrough</paper-item>
</paper-listbox>
</template>
</dom-bind>
</template>
</demo-snippet>
</div>
</body>
</html>