Andath
Andath

Reputation: 22724

How to change <v-text-field> icon's color?

In my <v-toolbar> component, I want to set a text field search with the icon search prepended:

<v-text-field                                                                                                                                  
    solo-inverted                                                                                                                                                        
    prepend-icon="search"                                                                                                                                                
    label="Search"                                                                                                                                                       
    class="hidden-sm-and-down"                                                                                                                                           
    >                                                                                                                                                                    
</v-text-field> 

This works but it gives me this result I do not like:

enter image description here

I do not like it because I want both the text field and icon in white color, so I added the property background-color="white" to the previous code:

<v-text-field                                                                                                                                                          
    background-color="white"                                                                                                                                             
    solo-inverted                                                                                                                                                        
    prepend-icon="search"                                                                                                                                                
    label="Search"                                                                                                                                                       
    class="hidden-sm-and-down"                                                                                                                                           
    >                                                                                                                                                                    
</v-text-field> 

This gives me half of what I want:

enter image description here

How can change the color of that icon into white?

I did some search on Vuetify.js API but could not see an appropriate option there.

Upvotes: 9

Views: 15700

Answers (2)

Kirill Manakhov
Kirill Manakhov

Reputation: 81

Had a similar problem. So I show as example the color-picker with vuetify

<v-menu
    v-model="menu"
    :close-on-content-click="false"
    transition="scale-transition"
>
    <v-text-field
       slot="activator"
       v-model="newClass.color.hex"
       label="color"
       readonly
    >
       <v-icon slot="prepend" :color="newClass.color.hex">
          format_color_fill
       </v-icon>
    </v-text-field>
    <material-picker v-model="newClass.color" />
 </v-menu>

Upvotes: 8

Nika Kurashvili
Nika Kurashvili

Reputation: 6462

You can override icon color by class

OR

You can use v-text-field class to override icon color, for example:

.hidden-sm-and-down .v-icon {
    color: white !important;
}

Upvotes: 6

Related Questions