Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Styling vuetify v-data-table

Tags:

css

vuetify.js

Between each not-last-child row of a v-data-table a line is being printed by default. I would like to modify the css to change that line, e.g. remove it. Originally, in the developer console the css regarding the border-bottom looks as follows.

.theme--light.v-table tbody tr:not(:last-child) {
    border-bottom: 1px solid rgba(0,0,0,0.12);
}

I have assigned the data-table an additional class "mytable":

<v-data-table
        :headers="headers"
        :items="desserts"
        hide-actions
        class="elevation-1 mytable">
    <template slot="items" slot-scope="props">
        <td>{{ props.item.name }}</td>
        <td class="text-xs-right">{{ props.item.calories }}</td>
        <td class="text-xs-right">{{ props.item.fat }}</td>
        <td class="text-xs-right">{{ props.item.carbs }}</td>
        <td class="text-xs-right">{{ props.item.protein }}</td>
        <td class="text-xs-right">{{ props.item.iron }}</td>
    </template>
</v-data-table>

And with css I am trying to modify the table

.mytable table tr {
    background-color: lightgoldenrodyellow;
    border-bottom: none;
}

Although the background-color is changed to lightgoldenrodyellow the border-bottom is still printed. In the developer console the directive to remove the border-bottom is stroken through. The background-color is not. Which selector do I have to use to change as well the border-bottom? Using the same css as used by the theme originally doesn't work either.

like image 365
Kavau Avatar asked Sep 24 '18 06:09

Kavau


4 Answers

try this.

.v-data-table tbody tr:not(:last-child) {
  border-bottom: 1px solid rgba(0,0,0,0.12) !important; }
like image 120
Adrish Avatar answered Oct 16 '22 10:10

Adrish


I am using Vuetify version 2.3.21. After trying a lot of things, I managed to remove the lines by changing td. Changing tr did not remove the lines, but you can change it to color the row, for example.

I also had to use !important. I added this to my page's CSS:

.v-data-table td {
    border-bottom: none !important;
}

This modification works with <v-simple-table> as well.

like image 43
Heitor Chang Avatar answered Oct 16 '22 10:10

Heitor Chang


Which selector do I have to use to change the border-bottom?

Use your custom class and the one used by vuetify

.mytable .v-table tbody tr:not(:last-child) {
    border-bottom: none;
}

Additionally you can add .theme--light if you want to style the light theme specifically.

codepen


More about styling vuetify components:

CSS not working (taking effect) inside component
Styling Vuetify selectors

like image 5
Traxo Avatar answered Oct 16 '22 08:10

Traxo


I am using VueJS 2.x. the following way of selection worked for me well.

<style lang="scss" scoped>
.table-header /deep/ {
  thead {
    background-color: black;
  }
}
</style>
like image 3
Ravi Anand Avatar answered Oct 16 '22 09:10

Ravi Anand