Custom styling Vuetify buttons
Tags: beginners, webdev, vue, tutorial
Published: 2020-05-14 16:12:30

As a developer working on user interfaces, it’s a common struggle to find yourself in this scenario: You find an awesome library to work with, the site components come together ultra fast and you feel invincible! Well, that’s right up until the point you want to overwrite some default CSS for your application. And then you find yourself elbow-deep in your Devtools and Stack Overflow trying to figure out `What selector should I use?` and `How many lines of !important do I need to add to make this style show up?` 😐

Today we’re going to  take a look at how to overwrite some of the behaviour and styling of Vuetify's default buttons. Check out the Codepen below to see what we get out of the box and what we want to achieve:
{% codepen https://codepen.io/anzuj/pen/wvKXLOj default-tab=result %}
####🎨 Button width####
Let's begin with trying to make the button take on a square styling. By default, Vuetify's button height is *36px*.
Therefore, it would make sense that setting `.v-btn { width: 36px; }` creates a square button, right?
That was my first instinct, but the button was still rectangular 🤔 In order to hunt down what was going on, I opened my Devtools. When you find yourself trying to style something and it just doesn't work as expected - a good first step is to look under the hood! 🛠️
In order to do that, right click the element you want to style in your project and choose "Inspect" ("Inspect element" in Firefox).
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/2jo9q7z2c776gj1wt352.png)
Next, when we check the styles on the `div` with a class `.v-btn`, we can see that Vuetify's default styling is interfering with our square plans.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/sb8w5dny75lvavvph2cg.png)
Here you can see that `.v-btn` has a `min-width: 64px` property, which is the culprit in the matter. Therefore, to get our button square, we need to overwrite that in our stylesheet like so:
```css
.v-btn {
  width: 36px;
  min-width: 36px;
}
```
####🎨 Ripple effect####
Ripple effect is what happens by default after you click a `.v-btn`. 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/73vfpniybfxykg5uymw0.gif)The color of the effect is generated automatically by Vuetify from the color of the button itself. 
In most cases that's quite handy, since you can have a nice red ripple for your red button with 0 work. However, sometimes you want the ripple effect to be a different color. 
For example I wanted the button to be modest light gray, but the ripple effect to be blue. To modify the ripple effect, it would be necessary to hack a bit into Vuetify's `v-ripple` directive. You can use Material Design's [color palette](https://vuetifyjs.com/en/styles/colors/) names or theme colors (primary, secondary, success etc) to modify the ripple color like so:
```js
 <v-btn v-ripple="{ class: 'primary--text' }">
```
####🎨 Hover effects####
By default, Vuetify buttons have a hover effect of a slightly darker background color. I wanted to remove that so that the only hover effect would be the icon scaling up. Interestingly enough `.v-btn:hover { background-color: none; }` or any other background property removal attempts did not work. It wasn't until scrolling all the way down in Devtools when I started to suspect the `::before` pseudo selectors. `::before` was there before `:hover` was cool 😉 
Here's how to get rid of that sneaky hover color:
```css
.v-btn::before {
  background-color: transparent;
}
```
And a cherry on top, enlarging the icons on hover is easy to change like so:
```css
.v-btn i:hover{
  transform: scale(1.15);
}
```
And that's a wrap! Hope you found these little tips useful when wrestling with Vuetify buttons in your own projects 💪

***
🐣 This blog post is a part of [Vuetify Beginner's Guide Series](https://vuetifyjs.com/en/introduction/guide/). Each blog has been collaboratively worked on by the Vuetify Core Team. 
💡 Interested in contributing a topic? Reach out to [Johanna](https://dev.to/johannarlee) on Dev.to or in the [Vuetify Community Discord](https://discord.com/invite/s93b7Fv).