Skip to content

[FEAT]: add light/dark background toggle for component demo previews #158

@FreshmanJ

Description

@FreshmanJ

Share your suggestion

Many demos are currently presented on dark backgrounds, which works well for dark-themed websites. However, developers building light-themed websites may also want to preview how components look in a light context.

I would like to propose adding a small light/dark background toggle to the component demo preview area.

Proposed behavior

  • Keep the current dark background as the default.
  • Add a Light / Dark toggle for demo preview containers.
  • Only change the preview background, not the component source code.
  • Avoid changing existing component APIs.
  • Optionally persist the selected preview background in localStorage.
  • For components that do not adapt well to a light background, the toggle can be hidden or disabled, keeping the current dark-only preview.

Why this is useful

This would help developers building light-themed websites evaluate components in a more realistic context without manually editing the demo code.

I would be happy to open a PR for this if the direction sounds good.

I have already tried this approach locally with several existing components, and many of them appear to work well with both dark and light preview backgrounds.
examples:
Image

Image Image Image

Validations

  • I have checked other issues to see if my issue was already discussed or addressed

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions