Hook

useTheme

The useTheme hook provides an easy way to read, update and toggle the active application theme.

Import
import { useTheme } from "@shivms/ui";

theme

Returns the currently active theme.

setTheme

Updates the current application theme.

toggleTheme

Switches between light and dark themes.

Basic Usage

Import the hook and use it inside your React component.

import {
    Button,
    useTheme,
} from "@shivms/ui";

export default function App() {
    const {
        theme,
        toggleTheme,
    } = useTheme();

    return (
        <Button onClick={toggleTheme}>
            Current Theme: {theme}
        </Button>
    );
}

Features

01

Read Theme

Access the current application theme.

02

Update Theme

Change the active theme programmatically.

03

Toggle Theme

Switch between light and dark mode with one function.

Continue Reading

Explore more SHIVMS UI documentation and guides.