Skip to content

Defining Custom Spacing Scale with extendTailwindMerge #494

Answered by dcastil
jeniabrook asked this question in Help
Discussion options

You must be logged in to vote

Hey @jeniabrook and @jkinley! 👋

Thanks for your patience! You basically figured it out already. tailwind-merge sometimes supports the theme scale and sometimes only the class group. It's a bit confusing indeed, but all for bundle size reasons because all this code needs to be sent to the browser.

If you want to have T-shirt sizes in the spacing scale, you can also do this:

import { extendTailwindMerge, validators } from 'tailwind-merge'

const twMerge = extendTailwindMerge({
    extend: {
        theme: {
            spacing: [validators.isTshirtSize]
        }
    }
})

That will allow all T-shirt sizes and even values like 123xl or 0.5md.

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@jkinley
Comment options

@jeniabrook
Comment options

@dcastil
Comment options

Answer selected by jeniabrook
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
context-v2 Related to tailwind-merge v2
3 participants