0.2.1 • Published 4 years ago

@anypoint-web-components/anypoint-chip v0.2.1

Weekly downloads
19
License
Apache-2.0
Repository
github
Last release
4 years ago

Published on NPM

Build Status

Published on webcomponents.org

anypoint-chip

A compact material design element that represent and input, attribute, or action.

Example

<style>
.avatar {
  background-color: red;
  color: #fff !important;
  width: 24px;
  height: 24px;
}
</style>
<h2>Basics</h2>
<section>
  <anypoint-chip>Simple chip</anypoint-chip>

  <anypoint-chip>
    <span class="avatar" slot="icon">C</span>
    <span>Chip with icon</span>
  </anypoint-chip>

  <anypoint-chip removable>
    <span class="avatar" slot="icon">R</span>
    Chip that can be removed
  </anypoint-chip>

  <anypoint-chip removable disabled>
    <span class="avatar" slot="icon">D</span>
    Disabled chip
  </anypoint-chip>
</section>

<h2>Input chips</h2>
<section>
  <anypoint-chip removable>
    <iron-icon icon="communication:location-on" slot="icon"></iron-icon>
    Portland
  </anypoint-chip>

  <anypoint-chip removable>
    <iron-icon icon="maps:directions-bike" slot="icon"></iron-icon>
    Biking
  </anypoint-chip>
</section>

Usage

Installation

npm install --save @anypoint-web-components/anypoint-chip

In an html file

<html>
  <head>
    <script type="module">
      import './node_modules/@anypoint-web-components/anypoint-chip/anypoint-chip.js';
    </script>
  </head>
  <body>
    <anypoint-chip></anypoint-chip>
  </body>
</html>

In a LitElement

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

class SampleElement extends PolymerElement {
  render() {
    return html`
    <anypoint-chip></anypoint-chip>
    `;
  }
}
customElements.define('sample-element', SampleElement);

Development

git clone https://github.com/anypoint-web-components/anypoint-chip
cd anypoint-chip
npm install

Running the demo locally

npm start

Running the tests

npm test

Styling

<anypoint-chip> provides the following custom properties for styling:

Custom propertyDescriptionDefault
--anypoint-chip-background-colorChip background colorrgba(35, 47, 52, 0.12)
--anypoint-chip-focused-background-colorBackground color when focused#D6D6D6
--anypoint-chip-active-background-colorBackground color when toggle is active#cdcdcd
--anypoint-chip-icon-colorColor of the icon#666666
--anypoint-chip-label-colorColor of the label#232F34
--anypoint-chip-label-focused-colorColor of the when focused
--anypoint-chip-label-active-colorColor of the when active
--anypoint-chip-icon-close-colorColor of the close icon#dfdfdf
--anypoint-chip-icon-close-background-colorBackground color of the close icon#666666

<anypoint-chip> provides the following parts:

Part nameDescription
anypoint-chip-containerStyles applied to the chip container
anypoint-chip-iconStyles applied to the icon container
anypoint-chip-labelStyles applied to the label container
anypoint-chip-removeStyles applied to the delete icon