Skip to content
Advertisement

How to add tooltip to datatable header in vuetify?

In older version on vuetify you could access headerCell slot and easily add tooltips – see https://codepen.io/nueko/pen/dZoXeZ

In the latest version you have named slots, so you need to know header name before

JavaScript

Is there a way to add a tooltip to all headers?

Advertisement

Answer

There are 2 ways to achieve this.

Option 1: Customizing whole table row

If you need to customize whole row element inside table heading this might be useful. Even though I would not recommend to follow this way if you don’t want to loose sorting functionality which exist by default in v-data-table.

Example:

JavaScript

Working pen: https://codepen.io/onelly/pen/QWWmpZN

Option 2: Customizing each heading without losing sorting functionality

I guess this is more like what you are trying to do and the replacement for the old way. You can loop <template v-slot:header> and use Dynamic Slot Names to accomplish this. Syntax for Dynamic slot name looks like this <template v-slot:[dynamicSlotName]>.

Example:

JavaScript

Working pen: https://codepen.io/onelly/pen/ExxEmWd

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement