ndiego / block-visibility

Conditional visibility controls for all WordPress blocks.
https://www.blockvisibilitywp.com
GNU General Public License v2.0
129 stars 10 forks source link

Add support for a "Color scheme" (dark mode/light mode) visibility setting #101

Open andersnoren opened 7 months ago

andersnoren commented 7 months ago

What problem does this address?

In some cases, you might want to hide or show a block depending on whether the visitor has their system appearance settings set to dark mode or light mode.

A recent scenario I've run into is that one set of illustrations (image blocks) with black strokes should be shown to light mode visitors, and another set of illustrations with white strokes should be shown for dark mode visitors.

What is your proposed solution?

Add a "Color scheme" setting allowing you to hide blocks for either "Light mode" or "Dark mode", using prefers-color-scheme.

Stormrunn3r commented 7 months ago

Hi @andersnoren ,

Great idea! I made an block visibility add-on based on your suggestion. It uses the prefers-color-scheme setting to show or hide blocks depending on whether the user is in dark mode or light mode. You're welcome to try it out and see if it helps!