DarkThemeToggle

The DarkThemeToggle component is a button that allows the user to switch between light and dark themes with a simple click.

Importation

Import the component from pol-ui to use the conveyor element:

import { DarkThemeToggle } from "pol-ui";

Default darkThemeToggle

Default darkThemeToggle

import { DarkThemeToggle } from "pol-ui";
 
import React from "react";
 
const DarkThemeToggleComponent = () => {
  return (
    <PoluiProvider>
      <DarkThemeToggle />
    </PoluiProvider>
  );
};
export default DarkThemeToggleComponent;

Props

Prop nameTypeDefaultDescription
iconDarkstringTbSunThe icon to display when the dark theme is active.
iconLightstringTbMoonThe icon to display when the light theme is active.
themeDarkThemeToggleThemeThe theme to apply to the darkThemeToggle.
refobjectnullThe ref to apply to the darkThemeToggle.
colorstringprimaryThe color to apply to the darkThemeToggle.
labelstring""The label to apply to the button's tooltip.

Examples

Custom styles

Custom styles

import { DarkThemeToggle } from "pol-ui";
 
import React from "react";
 
const DarkThemeToggleComponent = () => {
  return (
    <PoluiProvider>
      <DarkThemeToggle className="bg-transparent hover:bg-gray-100 dark:hover:bg-secondary-800 text-secondary-900 dark:text-secondary-50" />
    </PoluiProvider>
  );
};
export default DarkThemeToggleComponent;

Theme

To learn more about how to customize the appearance of components, please see the Theme docs.

interface DarkThemeToggleRootTheme {
  base: string;
  icon: string;
}

Since February 15, 2024

Proudly Open Source
  • Npm

  • Github

  • Creator

  • Made with love and Pol-ui by Pol Gubau Amores