ThemeSwitcher.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { IconMoon, IconSun } from "@tabler/icons-react";
  2. import cn from "classnames";
  3. import { Button } from "src/components";
  4. import { useTheme } from "src/hooks";
  5. import styles from "./ThemeSwitcher.module.css";
  6. interface Props {
  7. className?: string;
  8. }
  9. function ThemeSwitcher({ className }: Props) {
  10. const { setTheme } = useTheme();
  11. return (
  12. <div className={cn("d-print-none", "d-inline-block", className)}>
  13. <Button
  14. size="sm"
  15. className={cn("btn-ghost-dark", "hide-theme-dark", styles.lightBtn)}
  16. data-bs-toggle="tooltip"
  17. data-bs-placement="bottom"
  18. aria-label="Enable dark mode"
  19. data-bs-original-title="Enable dark mode"
  20. onClick={() => setTheme("dark")}
  21. >
  22. <IconMoon width={24} />
  23. </Button>
  24. <Button
  25. size="sm"
  26. className={cn("btn-ghost-light", "hide-theme-light", styles.darkBtn)}
  27. data-bs-toggle="tooltip"
  28. data-bs-placement="bottom"
  29. aria-label="Enable dark mode"
  30. data-bs-original-title="Enable dark mode"
  31. onClick={() => setTheme("light")}
  32. >
  33. <IconSun width={24} />
  34. </Button>
  35. </div>
  36. );
  37. }
  38. export { ThemeSwitcher };