2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
3 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
5 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
6 Code distributed by Google as part of the polymer project is also
7 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
10 The `core-style` element helps manage styling inside other elements and can
11 be used to make themes. The `core-style` element can be either a producer
12 or consumer of styling. If it has its `id` property set, it's a producer.
13 Elements that are producers should include css styling as their text content.
14 If a `core-style` has its `ref` property set, it's a consumer. A `core-style`
15 typically sets its `ref` property to the value of the `id` property of the
16 `core-style` it wants to use. This allows a single producer to be used in
17 multiple places, for example, in many different elements.
19 It's common to place `core-style` producer elements inside HTMLImports.
20 Remote stylesheets should be included this way, the @import css mechanism is
21 not currently supported.
23 Here's a basic example:
25 <polymer-element name="x-test" noscript>
27 <core-style ref="x-test"></core-style>
32 The `x-test` element above will be styled by any `core-style` elements that have
33 `id` set to `x-test`. These `core-style` producers are separate from the element
34 definition, allowing a user of the element to style it independent of the author's
37 <core-style id="x-test">
39 backgound-color: steelblue;
43 The content of the `x-test` `core-style` producer gets included inside the
44 shadowRoot of the `x-test` element. If the content of the `x-test` producer
45 `core-style` changes, all consumers of it are automatically kept in sync. This
46 allows updating styling on the fly.
48 The `core-style` element also supports bindings, in which case the producer
49 `core-style` element is the model. Here's an example:
51 <core-style id="x-test">
53 background-color: {{myColor}};
57 document._currentScript.ownerDocument.getElementById('x-test').myColor = 'orange';
60 Finally, to facilitate sharing data between `core-style` elements, all
61 `core-style` elements have a `g` property which is set to the global
62 `CoreStyle.g`. Here's an example:
64 <core-style id="x-test">
66 background-color: {{g.myColor}};
70 CoreStyle.g.myColor = 'tomato';
73 Finally, one `core-style` can be nested inside another. The `core-style`
74 element has a `list` property which is a map of all the `core-style` producers.
75 A `core-style` producer's content is available via its `cssText` property.
76 Putting this together:
78 <core-style id="common">
80 font-family: sans-serif;
84 <core-style id="x-test">
85 {{list.common.cssText}}
88 background-color: {{g.myColor}};
93 @group Polymer Core Elements
96 --><html><head><link rel="import" href="../polymer/polymer.html">
98 </head><body><polymer-element name="core-style" hidden="" assetpath="">
101 <script charset="utf-8" src="core-style-extracted.js"></script></body></html>