tailwindlabs / discuss

A place to ask questions, get help, or share what you've built with Tailwind CSS.
MIT License
171 stars 9 forks source link

Overwrite tailwind's underline class #419

Open ahoiroman opened 4 years ago

ahoiroman commented 4 years ago

Hello everybody,

is it possible to overwrite tailwind's .underline class and change the thickness of the line?

Thank you all for your feedback :-)

cytRasch commented 4 years ago

There two IMHO possible ways to do this.

First:

As mentioned here. You can add something like this under the tailwind directives:

@tailwind base;
@tailwind components;
@tailwind utilities;

.underline {
    text-decoration: underline;
    text-decoration-thickness: 3px;
}

Second:

You can achieve this by adding new utilities to your tailwind.config.js:

module.exports = {
    theme: {
        extend: {}
    },
    variants: {},
    plugins: [
        require('@tailwindcss/custom-forms'),
        function ({addUtilities}) {

            const extendUnderline = {

                '.underline': {
                    textDecoration: 'underline',
                    textDecorationThickness: '3px'
                },
            }

            addUtilities(extendUnderline)
        }
    ]
}

The text-decoration-thickness CSS property is not compatible to all browsers, so maybe you have to do a little hack with something like border-bottom.

Hope that helps.