Skip to content

Instantly share code, notes, and snippets.

@newbornfrontender
Created October 1, 2018 06:57
Show Gist options
  • Save newbornfrontender/e788f6b52ad6ca352b44c35ce590fa3c to your computer and use it in GitHub Desktop.
Save newbornfrontender/e788f6b52ad6ca352b44c35ce590fa3c to your computer and use it in GitHub Desktop.
Polymer - css properties
<!doctype html>
<html>
<head>
<script src="https://unpkg.com/@webcomponents/webcomponentsjs@latest/webcomponents-loader.js"></script>
<title>App</title>
</head>
<body>
<script type="module">
import { LitElement, html } from 'https://unpkg.com/@polymer/lit-element@latest/lit-element.js?module';
class MyApp extends LitElement {
constructor () {
super();
};
static get properties () { return {
msg: {
type: String,
},
color: {
type: String,
},
}};
render () {
const { color } = this;
return html`
<style>
span {
color: ${this.color};
}
</style>
<h1>Hello <span>${this.msg}</span>!</h1>
`;
};
};
window.customElements.define('my-app', MyApp);
</script>
<my-app msg="world" color="red"></my-app>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment