Polymer > ℹ️ Note: This is the current stable version of the Polymer library. At Google I/O 2018 we announced a new Web Component base class, LitElement, as a successor…
Polymer



> ℹ️ Note: This is the current stable version of the Polymer library. At Google I/O 2018 we announced a new Web Component base class, LitElement, as a successor to the PolymerElement base class in this library.
>
> If you're starting a new project, we recommend that you consider using LitElement instead.
>
> If you have a project you've built with an earlier version of the Polymer library, we recommend that you [migrate](#about-polymer-30) to 3.0 for best compatibility with the JavaScript ecosystem. Thanks to the interoperability of Web Components, elements built with Polymer 3.0 and LitElement can be mixed and matched in the same app, so once you have updated your project to Polymer 3.0, you can migrate to LitElement incrementally, one element at a time. See our blog post on the Polymer Project roadmap for more information.
Polymer lets you build encapsulated, reusable Web Components that work just like standard HTML elements, to use in building web applications. Using a Web Component built with Polymer is as simple as importing its definition then using it like any other HTML element:
html
<!-- Import a component -->
<!-- Use it like any other HTML element -->
Web Components!
Web Components are now implemented natively on Safari and Chrome (~70% of installed browsers), and run well on Firefox, Edge, and IE11 using polyfills. Read more [below](#overview).
Getting started
* The easiest way to try out Polymer is to use one of these online tools:
* Runs in all [supported](#supported-browsers) browsers: StackBlitz, Glitch
* Runs in browsers with JavaScript Modules: JSBin,
CodePen.
* You can also save this HTML file to a local file and run it in any browser that supports [JavaScript Modules]((https://caniuse.com/#search=modules)).
* When you're ready to use Polymer in a project, install it via npm. To run the project in the browser,
a module-compatible toolchain is required. We recommend installing the Polymer CLI to and using its development server as follows.
1. Add Polymer to your project:
npm i @polymer/polymer
1. Create an element by extending PolymerElement and calling customElements.define with your class (see the examples below).
1. Install the Polymer CLI:
npm i -g polymer-cli
1. Run the development server and open a browser pointing to its URL:
polymer serve --npm
> Polymer 3.0 is published on npm using JavaScript Modules.
This means it can take advantage of the standard native JavaScript module loader available in all current major browsers.
>
> However, since Polymer uses npm conventions to reference dependencies by name, a light transform to rewrite specifiers to URLs is required to run in the browser. The polymer-cli's development server polymer serve, as well as polymer build (for building an optimized app for deployment) automatically handles this transform.
Tools like webpack and Rollup can also be used to serve and/or bundle Polymer elements.
Minimal Example
1. Create a class that extends PolymerElement.
1. Implement a static properties getter that describes the element's public property/attribute API
(these automatically become observed attributes).
1. Then implement a template getter that returns an HTMLTemplateElement describing the element's rendering, including encapsulated styling and any property bindings.
html
import {PolymerElement, html} from '@polymer/polymer';
class MyElement extends PolymerElement {
static get properties() { return { mood: String }}
static get template() {
return html`
.mood { color: green; }
Web Components are [[mood]]!
`;
}
}
customElements.define('my-element', MyElement);
Overview
Web components are an incredibly powerful new set of primitives baked into the web platform, and open up a whole new world of possibility when it comes to componentizing front-end code and easily creating powerful, immersive, app-like experiences on the web.
Polymer is a lightweight library built on top of the web standards-based Web Components APIs, and makes it easier to build your very own custom HTML elements. Creating reusable custom elements - and using elements built by others - can make building complex web applications easier and more efficient.
By being based on the Web Components APIs built in the browser (or polyfilled where needed), elements built with Polymer are:
- Built from the platform up
- Self-contained
- Re-usable
- Interoperable across frameworks
Polymer provides a declarative syntax to easily create your own custom elements, using all standard web technologies - define the structure of the element with HTML, style it with CSS, and add interactions to the element with JavaScript.
Polymer also provides optional two-way data-binding, meaning:
1. When properties in the model for an element get updated, the element can update itself in response.
2. When the element is updated internally, the changes can be propagated back to the model.
Polymer is designed to be flexible, lightweight, and close to the web platform - the library doesn't invent complex new abstractions and magic, but uses the best features of the web platform in straightforward ways to simply sugar the creation of custom elements.
About Polymer 3.0
Polymer 3.0 is now released to stable, and introduces a major change to how Polymer is distributed: from HTML Imports on Bower, to JS modules on npm. Otherwise, the API is almost entirely backward compatible with Polymer 2.0 (the only changes are removing APIs related to HTML Imports like importHref, and converting Polymer's API to be module-based rather than globals-based).
Migrating to Polymer 3.0 by hand is mostly mechanical:
- Components should be defined in JS modules instead of in HTML
- Templates should be encoded in JS modules using a
static get template()getter on PolymerElement subclasses using thehtmltagged template literal function (which parsesHTMLTemplateElements out of strings in JS) rather than using `elements in a - All dependencies should be imported JS module imports rather than HTML Imports.
However, the polymer-modulizer` tool automates the vast majority of this migration work. Please see details on that repo for automated conversion of Polymer 2.0 apps and elements to Polymer 3.0.
👀 Looking for Polymer v2.x? Please see the v2 branch.
👀 Looking for Polymer v1.x? Please see the v1 branch.
Contributing
The Polymer team loves contributions from the community! Take a look at our [contributing guide](CONTRIBUTING.md) for more information on how to contribute. Please file issues on the Polymer issue tracker following the issue template and contributing guide issues.
Communicating with the Polymer team
Beyond GitHub, we try to have a variety of different lines of communication available:
License
The Polymer library uses a BSD-like license that is available [here](./LICENSE.txt)
Members
-
polymer
Our original Web Component library.
HTML ★ 22k 3mo agoExplain → -
polymer-starter-kit ▣
A starting point for Polymer apps
JavaScript ★ 2.4k 7y agoExplain → -
pwa-starter-kit ▣
Starter templates for building full-featured Progressive Web Apps from web components.
JavaScript ★ 2.3k 6y agoExplain → -
polymer-bundler ▣
Moved to Polymer/tools monorepo
TypeScript ★ 1.2k 8y agoExplain → -
shop
The Shop app
JavaScript ★ 1.0k 1mo agoExplain → -
old-docs-site ▣
Old Polymer site. Replaced by these repos: polymer-project.org, polymer-library-docs
HTML ★ 1.0k 7y agoExplain → -
designer ▣
Polymer Designer Tool
JavaScript ★ 837 6y agoExplain → -
web-component-tester
Moved to Polymer/tools monorepo
TypeScript ★ 564 1mo agoExplain → -
polymer-cli ▣
Moved to Polymer/tools monorepo
JavaScript ★ 494 7y agoExplain → -
tools
Polymer Tools Monorepo
TypeScript ★ 437 1mo agoExplain → -
pwa-helpers ▣
Small helper methods or mixins to help you build web apps.
TypeScript ★ 437 4y agoExplain → -
prpl-server ▣
⚠️Maintenance mode⚠️ An HTTP server for Node designed to serve PRPL apps in production.
TypeScript ★ 419 4y agoExplain → -
news
Polymer News (Progress Web App Template)
HTML ★ 265 1mo agoExplain → -
polycasts ▣
No description.
HTML ★ 219 5y agoExplain → -
polyserve ▣
Moved to Polymer/tools monorepo
TypeScript ★ 189 8y agoExplain → -
polymer-analyzer ▣
Moved to Polymer/tools monorepo
TypeScript ★ 158 7y agoExplain → -
hn-polymer-2 ▣
Polymer Hacker News clone
HTML ★ 155 8y agoExplain → -
polymer-modulizer ▣
Moved to https://github.com/Polymer/tools/tree/master/packages/modulizer
HTML ★ 144 7y agoExplain → -
polymer-build ▣
Moved to Polymer/tools monorepo
TypeScript ★ 103 8y agoExplain → -
polymer-decorators
TypeScript decorators for Polymer.
TypeScript ★ 93 1mo agoExplain → -
polymer-editor-service ▣
Moved to Polymer/tools monorepo
TypeScript ★ 75 8y agoExplain → -
vscode-plugin ▣
Provides autocompletion, linting, and more for web components.
TypeScript ★ 74 8y agoExplain → -
pwa-starter-kit-hn
No description.
TypeScript ★ 70 4mo agoExplain → -
lazy-imports ▣
Declarative lazy HTML imports as a behavior.
HTML ★ 64 8y agoExplain → -
polymer-css-build ▣
No description.
JavaScript ★ 40 6y agoExplain → -
polymer-linter ▣
Moved to Polymer/tools monorepo
TypeScript ★ 34 8y agoExplain → -
atom-plugin ▣
Provides autocompletion, linting, and more for web components.
JavaScript ★ 32 8y agoExplain → -
polymer-library-docs
Polymer library documentation site.
HTML ★ 24 1mo agoExplain → -
wct-local ▣
Moved to Polymer/tools monorepo
TypeScript ★ 22 8y agoExplain → -
gen-typescript-declarations ▣
Moved to Polymer/tools monorepo
TypeScript ★ 21 7y agoExplain → -
dom5 ▣
No description.
TypeScript ★ 19 8y agoExplain → -
polymer-resin ▣
XSS mitigation for Polymer webcomponents that uses safe html type contracts
JavaScript ★ 17 7y agoExplain → -
wct-sauce ▣
Moved to Polymer/tools monorepo
JavaScript ★ 17 8y agoExplain → -
polymer-project.org ▣
Polymer Project site & blog.
HTML ★ 16 2y agoExplain → -
koa-node-resolve ▣
Koa middleware that transforms Node package specifiers to relative paths
TypeScript ★ 15 2y agoExplain → -
browser-capabilities ▣
Moved to Polymer/tools monorepo
TypeScript ★ 13 8y agoExplain → -
tattoo ▣
Test All The Things Over and Over
TypeScript ★ 12 8y agoExplain → -
koa-esm-transform
Middleware for Koa servers that transforms standard JavaScript modules to AMD modules for use with older browsers that don't support modules natively.
TypeScript ★ 10 1mo agoExplain → -
polymer-project-config ▣
Moved to Polymer/tools monorepo
JavaScript ★ 8 8y agoExplain → -
polymer-workspaces ▣
Moved to https://github.com/Polymer/tools/tree/master/packages/workspaces
TypeScript ★ 8 8y agoExplain → -
css-select-parse5-adapter ▣
An adapter for the css-select package to allow querying of parse5 generated trees.
TypeScript ★ 8 4y agoExplain → -
benchmarks
Benchmarks for Polymer project libraries
JavaScript ★ 7 2mo agoExplain → -
polymer.github.io ▣
No description.
HTML ★ 7 10y agoExplain → -
tools-sample-projects ▣
Sample projects that Polymer tools should handle.
HTML ★ 7 9y agoExplain → -
ar-logo ▣
No description.
JavaScript ★ 7 8y agoExplain → -
tools-common ▣
Moved to Polymer/tools monorepo
JavaScript ★ 6 8y agoExplain → -
elements ▣
A collection of elements made by the Polymer team
★ 4 9y agoExplain → -
plylog ▣
A logger for the Polymer CLI toolchain
TypeScript ★ 4 5y agoExplain → -
koa-karma-proxy
Simplified coordination of karma and upstream proxy server using the koa web framework.
TypeScript ★ 4 2mo agoExplain → -
mocha-suite-child ▣
Runs mocha test suites defined in HTML documents and include the results as if they are part of the main context.
★ 3 6y agoExplain → -
tools-team ▣
Issues for tools in general
★ 2 9y agoExplain → -
.allstar ▣
No description.
★ 2 3y agoExplain → -
sinon.js ⑂ ▣
SinonJS proxy repository for the BowerJS package manager
JavaScript ★ 2 6y agoExplain → -
polygit ▣
Polygit
TypeScript ★ 1 8y agoExplain → -
.github ▣
No description.
★ 1 3y agoExplain →
No repos match these filters.