4

How to change the icon and color of the v-file-input component in Vuetify ?

For v-text-field and other component, the slot approach works, but for this component I can not get it work:

<div id="app">
  <v-app id="inspire">
    <v-file-input show-size label="File input">
      <template v-slot:prepend>
         <v-tooltip bottom>
            <template v-slot:activator="{ on }">
               <v-icon v-on="on" color="yellow lighten-3">
                  notes
               </v-icon>
           </template>
        </v-tooltip>
     </template>
    </v-file-input>
  </v-app>
</div>

Codepen.

4
  • Does moving the color to the actual v-file-input component, gives the result you're searching for, or do you only want to color the icon? Commented Dec 20, 2019 at 11:56
  • I want to colorize the icon (but also set a new icon) Commented Dec 20, 2019 at 11:58
  • For adding a new icon use prop prepend-icon Commented Dec 20, 2019 at 11:59
  • You are right, it is also what I did above @Riddhi Commented Dec 20, 2019 at 12:05

2 Answers 2

3

Because it doesn't have prepend slot. You can change icon with prepend-icon prop but not the color. You can go to Vuetify Github and make a feature request.

In the meanwhile, you can also use following little hack (works only because you using MDI icons with CSS/webfont)

In your css file:

.mdi-myFileIcon::before {
  content: "\F39A";
  color: blue;
}
<v-file-input show-size label="File input" prepend-icon="mdi-myFileIcon" />
Sign up to request clarification or add additional context in comments.

4 Comments

Didn't think of using CSS, not stupid at all, for a workaround
@Begueradj BTW there is open issue for your problem. You can go like it and watch it for updates....
My god, you follow everything :) thank you very much for sharing the link.
I'm just using Vuetify myself so I would like to see it fixed too ;)
1

The v-file-input doesn't utilize the same slots as the v-text-field, so unfortunately it's actually not possible at the moment, to set the icon the way you're trying.

The options you have to change the color by changing the color of the whole component. And for the icon, you can only change it by using the prepend-icon prop.

But this would be an actual feature request to post on the Github of Vuetify, would be great to actually achieve what you want for everyone.

1 Comment

Thank you for the feedback. I will leave my question open for few days just in case if an other code guru says something else :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.