Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vuetify - change style of select input in table footer

We are using Vuetify for our application where the whole application is using outlined text/select fields like this:

Example of outlined text fields as per our application's style

This is our table definition from the docs:

<v-data-table
    :headers="headers"
    :items="desserts"
    :items-per-page="5"
    class="elevation-1"
  ></v-data-table>

But that makes the table like this:

Table with "Rows per page" select field that doesn't follow the outlined input style

As you can see, tables by default use the common Material text field style. Can you tell me how to change this select field to our outlined style? Thank you.

like image 595
Denis Stephanov Avatar asked Jan 25 '26 23:01

Denis Stephanov


1 Answers

You could change select field to outlined style by using available slots of the v-data-table component. In your case use a footer slot. Slot receives the following parameters:

{
  props: {
    options: {
      page: number
      itemsPerPage: number
      sortBy: string[]
      sortDesc: boolean[]
      groupBy: string[]
      groupDesc: boolean[]
      multiSort: boolean
      mustSort: boolean
    },
    pagination: {
      page: number
      itemsPerPage: number
      pageStart: number
      pageStop: number
      pageCount: number
      itemsLength: number
    },
    itemsPerPageText: string
  },
  on: {}
  headers: TableHeader[]
  widths: []
}

You could create a custom component that will use the parameters as props and render the select component with the outlined property.

<template>
  <v-select :items="items" label="Outlined style" outlined></v-select>
</template>

<script>
export default {
  name: "vue-custom-component",
  data: function () {
    return {
      items: [],
    };
  },
  props: {
    currentPage: {
      type: Number,
      required: true,
    },
    itemsPerPage: {
      type: Number,
      required: true,
    },
    itemsLength: {
      type: Number,
      required: true,
    },
    pageCount: {
      type: Number,
      required: true,
    },
  },
  mounted() {
    //here you could fill items
  },
};
</script>

<style lang='scss'>
</style>

Example of using the custom component in footer slot.

<v-data-table
  :items="items"
>
  <template v-slot:footer="{ props }">
    <v-row align="center">
      <v-col class="d-flex" cols="12" sm="6">
        <vue-custom-component
          :currentPage="props.pagination.page"
          :itemsPerPage="props.pagination.itemsPerPage"
          :itemsLength="props.pagination.itemsLength"
          :pageCount="props.pagination.pageCount"
        ></vue-custom-component>
      </v-col>
    </v-row>
  </template>
</v-data-table>

Here you could find details

like image 73
Anastassiya Grinvald Avatar answered Jan 28 '26 12:01

Anastassiya Grinvald



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!