Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can an external stylesheet be used to style Polymer 1.0 elements?

Polymer 1.0 elements contain custom CSS variables that allow you to style them using inline styles as such:

<style is="custom-style">
  paper-toolbar {
    --paper-toolbar-color: blue;
  }
</style>

This works and is fantastic. How can I accomplish the same, but using an external stylesheet? Adding is="custom-style" to the link tag does not seem to have any effect, as the following does not work:

<link rel="stylesheet" media="all" href="app.css" is="custom-style">
like image 616
David Smith Avatar asked Jun 26 '15 15:06

David Smith


1 Answers

You can load the HTML file containing your custom-style like you would with a polymer element:

<link rel="import" href="my-custom-style.html">

And your my-custom-style.html file would contain:

<style is="custom-style">
    paper-toolbar {
        --paper-toolbar-color: blue;
    }
</style>

As of Polymer 1.1, this feature is now deprecated. See here for an update answer

like image 165
Ben Thomas Avatar answered Nov 10 '22 02:11

Ben Thomas