Skip to content

Instantly share code, notes, and snippets.

@Ademking
Last active March 3, 2025 23:32
Show Gist options
  • Save Ademking/dc13aa0dc870d5f75fdcf4ff15029088 to your computer and use it in GitHub Desktop.
Save Ademking/dc13aa0dc870d5f75fdcf4ff15029088 to your computer and use it in GitHub Desktop.
Regex - Tailwind - Get all CSS classes with "dark" mode

dark:\w+([-:\w]*\w)

[^'"\s]*dark:[^'"\s]*

Thanks to @angus-mcritchie

@chandler-barlow
Copy link

thanks!

@angus-mcritchie
Copy link

This regex doesn't include more complex dark classes with prefixes like [&[data-test]]:dark:text-white here is a regex example.

For those who are looking to match those as well, you can try [^'"\s]*dark:[^'"\s]* here is the regex example.

@Ademking
Copy link
Author

Ademking commented Mar 3, 2025

This regex doesn't include more complex dark classes with prefixes like [&[data-test]]:dark:text-white here is a regex example.

For those who are looking to match those as well, you can try [^'"\s]*dark:[^'"\s]* here is the regex example.

Thank you so much @angus-mcritchie ❤️
This gist is quite old which is why the complex dark mode classes aren't working...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment