Skip to content

Is there any way to receive 2 or more abritrary values? #11779

Answered by wongjn
scv057 asked this question in Help
Discussion options

You must be logged in to vote

Have some kind of predetermined delimiter in the arbitrary value and then split the value by this delimiter.

For example, here we use a plus sign (+) as a delimiter:

/** @type {import('tailwindcss').Config} */
module.exports = {
  plugins: [
    require('tailwindcss/plugin')(({ matchUtilities }) => {
      matchUtilities({
        'my-class': value => Object.fromEntries(
          value.split('+').map((v, i) => [`--foo-${i}`, v])
        ),
      });
    })
  ],
}

Then you'd use arbitrary values like my-class-[a+b+c].

See this Tailwind Play for a working example (open the Generated CSS panel to see the CSS results).

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
2 replies
@scv057
Comment options

@kingscode-big
Comment options

Answer selected by scv057
Comment options

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

wongjn Jul 23, 2025
Collaborator

@orimay
Comment options

@orimay
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
4 participants