Skip to content

Custom Variant group-toggle Not Working with group-toggle/item – How to Configure Correctly? #17640

Answered by wongjn
mustafa-soylemez asked this question in Help
Discussion options

You must be logged in to vote

Taking inspiration from core:

group: (_, { modifier }) =>
modifier
? [`:merge(${prefix('.group')}\\/${escapeClassName(modifier)})`, ' &']
: [`:merge(${prefix('.group')})`, ' &'],

You need to use matchVariant() so that you get access to the modifier (the string after the slash):

matchVariant(
  'group-toggle',
  (_, { modifier }) =>
    modifier
      ? `:merge(.group\\/${modifier}).toggle &`
      : ':merge(.group).toggle &',
  {
    values: { DEFAULT: '' }
  }
);

The empty DEFAULT is so that the "root" name, group-toggle can be used on its own. The value doesn't really matter, but the existance of…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mustafa-soylemez
Comment options

Answer selected by mustafa-soylemez
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants