3.0.1 • Published 7 years ago

@polymer/paper-item v3.0.1

Weekly downloads
10,443
License
BSD-3-Clause
Repository
github
Last release
7 years ago

Published on NPM Build status Published on webcomponents.org

<paper-item>

<paper-item> is an interactive list item. By default, it is a horizontal flexbox.

<paper-item>Item</paper-item>

Use this element with <paper-item-body> to make Material Design styled two-line and three-line items.

<paper-item>
  <paper-item-body two-line>
    <div>Show your status</div>
    <div secondary>Your status is visible to everyone</div>
  </paper-item-body>
  <iron-icon icon="warning"></iron-icon>
</paper-item>

To use paper-item as a link, wrap it in an anchor tag. Since paper-item will already receive focus, you may want to prevent the anchor tag from receiving focus as well by setting its tabindex to -1.

<a href="https://www.polymer-project.org/" tabindex="-1">
  <paper-item raised>Polymer Project</paper-item>
</a>

If you are concerned about performance and want to use paper-item in a paper-listbox with many items, you can just use a native button with the paper-item class applied (provided you have correctly included the shared styles):

<style is="custom-style" include="paper-item-shared-styles"></style>

<paper-listbox>
  <button class="paper-item" role="option">Inbox</button>
  <button class="paper-item" role="option">Starred</button>
  <button class="paper-item" role="option">Sent mail</button>
</paper-listbox>

Styling

The following custom properties and mixins are available for styling:

Custom propertyDescriptionDefault
--paper-item-min-heightMinimum height of the item48px
--paper-itemMixin applied to the item{}
--paper-item-selected-weightThe font weight of a selected itembold
--paper-item-selectedMixin applied to selected paper-items{}
--paper-item-disabled-colorThe color for disabled paper-items--disabled-text-color
--paper-item-disabledMixin applied to disabled paper-items{}
--paper-item-focusedMixin applied to focused paper-items{}
--paper-item-focused-beforeMixin applied to :before focused paper-items{}

Accessibility

This element has role="listitem" by default. Depending on usage, it may be more appropriate to set role="menuitem", role="menuitemcheckbox" or role="menuitemradio".

<paper-item role="menuitemcheckbox">
  <paper-item-body>
    Show your status
  </paper-item-body>
  <paper-checkbox></paper-checkbox>
</paper-item>

<paper-icon-item>

<paper-icon-item> is a convenience element to make an item with icon. It is an interactive list item with a fixed-width icon area, according to Material Design. This is useful if the icons are of varying widths, but you want the item bodies to line up. Use this like a <paper-item>. The child node with the slot item-icon is placed in the icon area.

<paper-icon-item>
  <iron-icon icon="favorite" slot="item-icon"></iron-icon>
  Favorite
</paper-icon-item>
<paper-icon-item>
  <div class="avatar" slot="item-icon"></div>
  Avatar
</paper-icon-item>

Styling

The following custom properties and mixins are available for styling:

Custom propertyDescriptionDefault
--paper-item-icon-widthWidth of the icon area56px
--paper-item-iconMixin applied to the icon area{}
--paper-icon-itemMixin applied to the item{}
--paper-item-selected-weightThe font weight of a selected itembold
--paper-item-selectedMixin applied to selected paper-items{}
--paper-item-disabled-colorThe color for disabled paper-items--disabled-text-color
--paper-item-disabledMixin applied to disabled paper-items{}
--paper-item-focusedMixin applied to focused paper-items{}
--paper-item-focused-beforeMixin applied to :before focused paper-items{}

Changes in 2.0

Distribution is now done with the slot="item-icon" attributes (replacing the item-icon attribute):

<paper-icon-item>
  <iron-icon icon="favorite" slot="item-icon"></iron-icon>
  Favorite
</paper-icon-item>

<paper-item-body>

Use <paper-item-body> in a <paper-item> or <paper-icon-item> to make two- or three- line items. It is a flex item that is a vertical flexbox.

<paper-item>
  <paper-item-body two-line>
    <div>Show your status</div>
    <div secondary>Your status is visible to everyone</div>
  </paper-item-body>
</paper-item>

The child elements with the secondary attribute is given secondary text styling.

Styling

The following custom properties and mixins are available for styling:

Custom propertyDescriptionDefault
--paper-item-body-two-line-min-heightMinimum height of a two-line item72px
--paper-item-body-three-line-min-heightMinimum height of a three-line item88px
--paper-item-body-secondary-colorForeground color for the secondary area--secondary-text-color
--paper-item-body-secondaryMixin applied to the secondary area{}

See: Documentation, Demo.

Usage

Installation

npm install --save @polymer/paper-item

In an html file

<html>
  <head>
    <script type="module">
      import '@polymer/paper-item/paper-item.js';
    </script>
  </head>
  <body>
    <paper-item>Item</paper-item>
  </body>
</html>

In a Polymer 3 element

import {PolymerElement, html} from '@polymer/polymer';
import '@polymer/paper-item/paper-item.js';

class SampleElement extends PolymerElement {
  static get template() {
    return html`
      <paper-item>Item</paper-item>
    `;
  }
}
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

git clone https://github.com/PolymerElements/paper-item
cd paper-item
npm install
npm install -g polymer-cli

Running the demo locally

polymer serve --npm
open http://127.0.0.1:<port>/demo/

Running the tests

polymer test --npm
fundwave-fund-managementzagenzagen-productionplaytwo-core-cms-sections@vinay.jadhav/drop-downzagen-zagen@delawarepro/dlw-snb-with-dependencies@teipublisher/pb-components7air_controlcontact-dialog2simple-material-table@phil-cd/frontendtest2@infinitebrahmanuniverse/nolb-_pol@everything-registry/sub-chunk-731tangy-custom-formtangy-formtest-pk-ecqm-gridwysiwyg-e-forkwysiwyg-e-nofontspinner-elementveltec-multi-video@cwmr/paper-autocomplete@cwmr/paper-search@doubletrade/lit-datatable@doubletrade/lit-datepicker@doubletrade/paper-datatable-api@doubletrade/range-datepicker@rpapeters/paper-autocompletetest-contact-dialog@anviltech/wuf-poly-paper-elements@api-components/api-candidates-dialog@api-components/authorization-panel@arkihillel/paper-chip@aspen-elements/aspen-login-menu-item@aspen-elements/aspen-nav-menu@aspen-elements/aspen-nav-menu-item@aspen-elements/firefly-login@aspen-elements/paper-bottom-sheet@aspen-elements/paper-chip@advanced-rest-client/websocket-history@advanced-rest-client/rest-api-menu@advanced-rest-client/project-requests-list@advanced-rest-client/projects-menu@adzadzadz/paper-autocomplete@adzadzadz/paper-expand@advanced-rest-client/arc-data-settings-panel@advanced-rest-client/arc-privacy-settings-panel@advanced-rest-client/arc-request-settings-panel@advanced-rest-client/arc-view-settings-panel@advanced-rest-client/paper-autocomplete@advanced-rest-client/paper-chip-input@advanced-rest-client/arc-electron-experiment-settings@biopolymer-elements/bio-interpro@biopolymer-elements/bio-pathways@01ht/ht-drawer-nav@01ht/ht-elements-catalog@01ht/ht-elements-item@01ht/ht-elements-toolbar-signin-menu@decooda/generic-questions@delawarepro/dlw-search-and-browse-extended@haxtheweb/paper-search@haxtheweb/lrnsys-comment@haxtheweb/select-menu@haxtheweb/haxcms-elements@hegdemahesh/moonraft-ui-element-sidebar@flowingcode/fc-menuitem@hatiolab/things-shell@hillelarki/paper-chip@hydrofoil/hydrofoil-paper-shell@firefly-elements/firefly-tags@firefly-elements/firefly-login@firefly-elements/firefly-name-multiselect@fluidnext-polymer/paper-autocomplete@fluidnext-polymer/paper-pagination@elifent/paper-datepicker@logo-elements/pagination@lrnwebcomponents/lrnsys-comment@lrnwebcomponents/lrndesign-contentsequencer@lrnwebcomponents/lrnapp-cis@lucentray/pine-web-components@lrnwebcomponents/haxcms-elements@lrnwebcomponents/eco-json-schema-form@longlost/app-inputs@longlost/app-shell@longlost/ezf-shared@lrnwebcomponents/select-menu@lrnwebcomponents/paper-contact@lrnwebcomponents/paper-icon-picker@lrnwebcomponents/paper-search@lit-any/components-paper-elements@neogrup/nc-combo@neovici/paper-autocomplete@neovici/paper-autocomplete-chips@exmg/exmg-grid@exmg/exmg-paper-datatable@exmg/exmg-paper-sidemenu@exmg/exmg-searchbar@exmg/exmg-sidemenu@exmg/exm-grid@fabricelements/fabric-imgix@fabricelements/skeleton-auth
3.0.1

7 years ago

3.0.0

7 years ago

3.0.0-pre.26

7 years ago

3.0.0-pre.25

7 years ago

3.0.0-pre.24

7 years ago

3.0.0-pre.23

7 years ago

3.0.0-pre.22

7 years ago

3.0.0-pre.21

7 years ago

3.0.0-pre.20

7 years ago

3.0.0-pre.19

7 years ago

3.0.0-pre.18

7 years ago

3.0.0-pre.17

7 years ago

3.0.0-pre.16

7 years ago

3.0.0-pre.15

7 years ago

3.0.0-pre.14

7 years ago

3.0.0-pre.13

7 years ago

3.0.0-pre.12

7 years ago

3.0.0-pre.11

7 years ago

3.0.0-pre.10

7 years ago

3.0.0-pre.8

7 years ago

3.0.0-pre.7

7 years ago

3.0.0-pre.6

7 years ago

3.0.0-pre.4

7 years ago

3.0.0-pre.3

7 years ago

3.0.0-pre.2

7 years ago

3.0.0-pre.1

8 years ago

1.2.1-pre.3

8 years ago

1.2.1-pre.2

8 years ago

1.2.1-pre.1

8 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.1

9 years ago