Skip to content

Safelist pattern for arbitrary values #7908

Answered by adamwathan
mastrup asked this question in Help
Discussion options

You must be logged in to vote

Hey! Yeah you can only safelist using patterns against things that Tailwind would generate based on the config, not arbitrary values.

In your situation just do this:

safelist: [
    'top-[0%]',
    'top-[10%]',
    'top-[20%]',
    'top-[30%]',
    'top-[40%]',
    'top-[50%]',
    'top-[60%]',
    'top-[70%]',
    'top-[80%]',
    'top-[90%]',
    'top-[100%]',
    'left-[0%]',
    'left-[10%]',
    'left-[20%]',
    'left-[30%]',
    'left-[40%]',
    'left-[50%]',
    'left-[60%]',
    'left-[70%]',
    'left-[80%]',
    'left-[90%]',
    'left-[100%]',
]

You could get clever and generate programmatically if you wanted to as well:

safelist: [
    ...[...Array(10).keys()].flatMap(i => [`…

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
4 replies
@mastrup
Comment options

@shivasaisagar18
Comment options

@cipriancaba
Comment options

@jwu-ice
Comment options

Answer selected by mastrup
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@danielx-art
Comment options

@damianof
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
8 participants