How can I override styles in tabulator?

Issue

I’m using Vue Tabulator here to over ride the column header not to use ellipsis when I continue to reduce the size of the column. Can’t we update the column header in tabulator using inline style?

<VueTabulator ref="tabulator" v-model="receipts" :options="options" style="white-space: normal; text-overflow: clip"/>

But when I inspected the element, the values of white-space and text-overflow didn’t change

enter image description here

I also tried inside the style tag within my vue component. No luck

<style>
.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-title{
    white-space: normal;
    text-overflow: clip;
}
</style>

Solution

Adding an !important fixed the issue.

This comes from CSS specificity: https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity

That one is easier to understand too: https://specifishity.com/

The thing is that you do have some classes coming from the package you’re using.
And there is probably a higher specificity there, hence why your default CSS doesn’t work.
!important is quite overkill and not recommend usually because it defeats the whole purpose of CSS cascade by nuking it.

Meanwhile, for 3rd party packages you don’t really have control overall: it’s totally fine and quite regular to force an overwrite like that. Common practice for Bootstrap, Vuetify etc…and smaller packages.

Answered By – kissu

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published