We use cookies to ensure you get the best experience on our website. Read our privacy policy

Skip to main content

Directory

Theme Selector Component

The Theme Selector component provides seamless dark mode functionality for your Astro website. Built as a Web Component, it intelligently handles theme detection, persistence, and switching while maintaining a smooth user experience.

  • Check Circle

    System Theme Detection: Automatically matches user’s system preferences

  • Check Circle

    Theme Persistence: Remembers user’s choice across sessions

  • Check Circle

    Smooth Transitions: Animated theme switching

  • Check Circle

    Code Highlighting: Automatic syntax theme switching

Add the Theme Selector to your layout with a single line, the script to manange the theme selector is found in the Head Component.

<ThemeSelector />
  1. Theme Implementation

    • Place the selector in consistent locations
    • Maintain sufficient contrast in both themes
    • Test all interactive elements in both modes
    • Consider transition animations
  2. User Experience

    • Respect system preferences initially
    • Persist user choices
    • Provide clear visual feedback
    • Ensure smooth transitions
  3. Performance

    • Prevent flash of incorrect theme
    • Optimize theme assets loading

Limited Time Launch Sale

Add professional dark mode support to your website in minutes. Get our AstroJS starter template with the Theme Selector component built-in.

GET 60% OFF!
North Star Themes Logo

Subscribe to our newsletter

Get the latest AstroJS tips and tricks right to your inbox

Email: [email protected]

© 2025 North Star Themes

Web Kit Provided By North Star Themes