How can I change the placeholder/label color inside a v-text-field?

我们两清 提交于 2020-07-22 10:05:25

问题


I'm trying to change the color of both the label and the text being inputted by the user on a v-text-field. I've tried applying the color prop to it, but it only changes de bottom divider's color. What should I do to get it as I want?

This is my actual code:

<v-text-field label="Search here!" color="blue lighten-1">
    <template slot="append">
        <v-btn class="blue--text text--lighten-1" flat>
            <v-icon>search</v-icon>
        </v-btn>
    </template>
</v-text-field>

NOTE: I've removed some props as the v-model one, just to increase readability

This and this are the actual results i'm getting. But what i would like is to get the 'Find a user' text on the same blue lighten-1 Material Design color always (not only when there has been no text inputted), as well as such inputted text in the same color (not in black).

Thanks! :)


回答1:


You can do it overwriting the CSS default classes:

.custom-placeholer-color input::placeholder {
  color: red!important;
  opacity: 1;
}

.custom-label-color .v-label {
  color: red;
  opacity: 1;
}

[EDIT]

You can change the input color to have the text red/any other color:

.custom-placeholer-color input,
.custom-label-color input{
  color: red!important;
}

Codepen updated here:

https://codepen.io/fabiozanchi/pen/RmQbBd



来源:https://stackoverflow.com/questions/56262429/how-can-i-change-the-placeholder-label-color-inside-a-v-text-field

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