How to style a <paper-input> tag in Polymer 1.0

a 夏天 提交于 2019-12-28 05:58:11

问题


How do you style the <paper-input> tag in Polymer 1.0

Can you show how to specifically custom style the label text color, the underline color, input text color, and how to access them using custom-style?


回答1:


You can change the appearance of <paper-input> by changing the custom properties listed over here (The information has been moved for the most recent version - it is available for versions older than v1.1.21).

Here's an example:

<style is="custom-style">
:root {
        /* Label and underline color when the input is not focused */
        --paper-input-container-color: red;

        /* Label and underline color when the input is focused */
        --paper-input-container-focus-color: blue;

        /* Label and underline color when the input is invalid */
        --paper-input-container-invalid-color: green;

        /* Input foreground color */
        --paper-input-container-input-color: black;
}
</style>

EDIT:

The :root selector is used to define custom properties that apply to all custom elements. You can also target a specific element instead of :root:

<style is="custom-style">
    paper-input-container.my-class {
        --paper-input-container-color: red;
        --paper-input-container-focus-color: blue;
        --paper-input-container-invalid-color: green;
        --paper-input-container-input-color: black;
    }
</style>


来源:https://stackoverflow.com/questions/30628050/how-to-style-a-paper-input-tag-in-polymer-1-0

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!