Back

Theme Visibility Toggle

This code provides overrides that allow you to show or hide layers in your Framer prototype based on the user's system theme (light or dark). It detects the current system theme and updates the visibility of layers accordingly. You can add this override to any layer in your site. It's particularly valuable for showcasing different designs for light and dark modes without manually switching between them.

0

Status

Working

Code Component

Yes

Preview

Preview

Preview

This component is a part of the 300+ components, layouts and code overrides from the SegmentUI KIt. Learn More. We also have a library of freebies here

0:00 / 0:00

Instructions

  1. Copy and paste the provided code into a new file in your Framer project.

  2. Create an override by clicking the "+" button in the left panel under "Code," then select "Create Override" and paste the copied code.

  3. In your design, select the layer you want to control based on the theme.

  4. In the properties panel on the right, click the "+" button next to "Overrides."

  5. Choose either withThemeLight or withThemeDark from the list of available overrides:

    • Use withThemeLight for layers that should only be visible in light mode.

    • Use withThemeDark for layers that should only be visible in dark mode.

  6. Repeat steps 3-5 for any other layers you want to control based on the theme.

  7. Preview your prototype. The visibility of the layers will automatically adjust based on your system's theme settings. To test, try changing your system theme and observe the changes in your prototype.

How it Works

This code utilizes React hooks and the window.matchMedia() API to detect and respond to the user's system theme preference (light or dark). It exports two Framer overrides, withThemeLight and withThemeDark, which dynamically control layer visibility based on the current theme. The useSystemTheme custom hook manages theme state and listens for changes, ensuring the prototype stays in sync with the user's system settings. When applied to layers in Framer, these overrides modify the display property, showing or hiding elements based on whether the current theme matches the intended visibility condition.

Note - This will not work with our manual theme toggle component. This override depends entirely on system theme.

Frequently Asked Questions

I'm having issues with this component. What should I do?

I'm having issues with this component. What should I do?

I'm having issues with this component. What should I do?

How can i make this responsive?

How can i make this responsive?

How can i make this responsive?

0:00 / 0:00

What is SegmentUI Pro?

SegmentUI Pro is a UI kit and component library containing 500+ assets, components, power ups, upgrades, code overrides, layouts, design systems, Premium templates and a custom Framer code generator. You can preview the UI Kit here.

Additionally, we have a Figma Design system to compliment the Framer components.

Our mission is simple - give superpowers to designers. Everything from the first pixel, education to code components. It's an ever growing, ever evolving set of tools for designer without the hefty price tag.

vs

Who is SegmentUI Pro For?

SegmentUI Pro is for Framer designers and template creators who want to power up their designs

After creating multiple templates and client projects myself, I realised one thing - In order to make more revenue, you need to give more value. This was the main intent behind SegmentUI. To empower designers and to be able to allow them to deliver more value for the time they spend

SegmentUI Pro is for Framer designers and template creators who want to power up their designs

After creating multiple templates and client projects myself, I realised one thing - - In order to make more revenue, you need to give more value. This was the main intent behind SegmentUI. To power up designers to and to be able to allow them to deliver more value for the time they spend

SegmentUI Pro is for Framer designers and template creators who want to power up their designs

After creating multiple templates and client projects myself, I realised one thing - - In order to make more revenue, you need to give more value. This was the main intent behind SegmentUI. To power up designers to and to be able to allow them to deliver more value for the time they spend

For Framer

For Figma

Resources

Loved by Designers, Developers and Founders

See what our 3500+ customers have to say

Unlock everything with a one time payment

For the fraction of your next project, you can boost your workflow by 10 folds

Happy ! Use discount code for a special holiday discount!

Pro

$99

One Time Payment

Full Access to the Figma UI Kit

Full Access to the Framer UI Kit

Full Access to the Framer Code Components & CMS Upgrades

Full Access to 4 Premium Framer Templates

Full Access to Framer Code Genie GPT

Request Components & Layouts

Get Updates Forever

Light, Dark & Dynamic Modes

Use for Unlimited Projects

Commercial License Only

Use for personal and client projects

Pro Creator

$199

One Time Payment

Everything in Pro

Template & Commercial License

Use UI Kit to create unlimited client projects and templates

Frequently Asked

For anything not covered here, mail us at hello@segmentui.com

General

What is SegmentUI?

Is it for Figma or Framer?

How do I access after purchasing?

License

How does the licenses work?

Can I use it to create client projects?

Can I use it to create Framer templates?

Pricing

Is there a free version?

Do you have a student discount?

Can I buy components seperately?

Will I get future updates if I purchase now?

Is this a one time payment or a subscription?

What is the difference between Pro and Pro Creator Access?

Supercharge Your Design Workflow

1000+ variations of styles, components, interactions, layouts, transforms, code overrides, code components for Framer & Figma. Power Up Now!

Loved by Designers, Developers and Founders

See what our 3500+ customers have to say

Unlock everything with a one time payment

For the fraction of your next project, you can boost your workflow by 10 folds

Happy ! Use discount code for a special holiday discount!

Pro

$99

One Time Payment

Full Access to the Figma UI Kit

Full Access to the Framer UI Kit

Full Access to the Framer Code Components & CMS Upgrades

Full Access to 4 Premium Framer Templates

Full Access to Framer Code Genie GPT

Request Components & Layouts

Get Updates Forever

Light, Dark & Dynamic Modes

Use for Unlimited Projects

Commercial License Only

Use for personal and client projects

Pro Creator

$199

One Time Payment

Everything in Pro

Template & Commercial License

Use UI Kit to create unlimited client projects and templates

Frequently Asked

For anything not covered here, mail us at hello@segmentui.com

General

What is SegmentUI?

Is it for Figma or Framer?

How do I access after purchasing?

License

How does the licenses work?

Can I use it to create client projects?

Can I use it to create Framer templates?

Pricing

Is there a free version?

Do you have a student discount?

Can I buy components seperately?

Will I get future updates if I purchase now?

Is this a one time payment or a subscription?

What is the difference between Pro and Pro Creator Access?

Supercharge Your Design Workflow

1000+ variations of styles, components, interactions, layouts, transforms, code overrides, code components for Framer & Figma. Power Up Now!

Loved by Designers, Developers and Founders

See what our 3500+ customers have to say

Unlock everything with a one time payment

For the fraction of your next project, you can boost your workflow by 10 folds

Happy ! Use discount code for a special holiday discount!

Pro

$99

One Time Payment

Full Access to the Figma UI Kit

Full Access to the Framer UI Kit

Full Access to the Framer Code Components & CMS Upgrades

Full Access to 4 Premium Framer Templates

Full Access to Framer Code Genie GPT

Request Components & Layouts

Get Updates Forever

Light, Dark & Dynamic Modes

Use for Unlimited Projects

Commercial License Only

Use for personal and client projects

Pro Creator

$199

One Time Payment

Everything in Pro

Template & Commercial License

Use UI Kit to create unlimited client projects and templates

Frequently Asked

For anything not covered here, mail us at hello@segmentui.com

General

What is SegmentUI?

Is it for Figma or Framer?

How do I access after purchasing?

License

How does the licenses work?

Can I use it to create client projects?

Can I use it to create Framer templates?

Pricing

Is there a free version?

Do you have a student discount?

Can I buy components seperately?

Will I get future updates if I purchase now?

Is this a one time payment or a subscription?

What is the difference between Pro and Pro Creator Access?

Supercharge Your Design Workflow

1000+ variations of styles, components, interactions, layouts, transforms, code overrides, code components for Framer & Figma. Power Up Now!