Re-scoped from @lilith/ui-theme to @cocotte/ui-theme. In-set cross-package deps re-pointed to @cocotte; out-of-set @lilith deps preserved (same Verdaccio). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
23 lines
No EOL
619 B
JavaScript
23 lines
No EOL
619 B
JavaScript
import { useContext } from 'react';
|
|
import { ThemeContext } from './ThemeProvider';
|
|
/**
|
|
* Hook to access theme context
|
|
*
|
|
* @throws Error if used outside of ThemeProvider
|
|
*
|
|
* @example
|
|
* ```tsx
|
|
* function MyComponent() {
|
|
* const { theme, themeName, setTheme } = useTheme();
|
|
* return <button onClick={() => setTheme('luxe')}>Switch Theme</button>;
|
|
* }
|
|
* ```
|
|
*/
|
|
export function useTheme() {
|
|
const context = useContext(ThemeContext);
|
|
if (context === undefined) {
|
|
throw new Error('useTheme must be used within a ThemeProvider');
|
|
}
|
|
return context;
|
|
}
|
|
//# sourceMappingURL=useTheme.js.map
|