Skip to content

@sqlrooms/ui / ThemeSwitch

Function: ThemeSwitch()

ThemeSwitch(props, deprecatedLegacyContext?): ReactNode

A theme toggle switch component that allows users to switch between light and dark themes.

This component provides a visually appealing switch with sun/moon icons that animate smoothly during theme transitions. It integrates with the theme context to manage theme state.

Features:

  • Smooth icon animations
  • Accessible keyboard navigation
  • Focus and hover states
  • Customizable via className prop

Parameters

ParameterTypeDescription
props{ className: string; }-
props.className?stringOptional CSS class name for styling the switch container
deprecatedLegacyContext?anyDeprecated See React Docs

Returns

ReactNode

Component

Example

tsx
// Basic usage
<ThemeSwitch />

// With custom styling
<ThemeSwitch className="my-custom-class" />

// Within a theme provider
import { ThemeProvider } from '../theme/theme-provider';

function App() {
  return (
    <ThemeProvider>
      <ThemeSwitch />
    </ThemeProvider>
  );
}