1 Run the shadcn CLI
npx shadcn@latest add https://toggles.dev/r/dark-inner 2 Import and use
import { DarkInner } from "@/components/ui/dark-inner";
export default function App() {
return <DarkInner />;
} 1 Install the package
▾
npm install @theme-toggles/react pnpm add @theme-toggles/react yarn add @theme-toggles/react bun add @theme-toggles/react 2 Import and use
import { DarkInner } from "@theme-toggles/react";
import "@theme-toggles/react/styles/dark-inner.css";
export default function App() {
return <DarkInner />;
} 1 Copy the component
import { type ButtonHTMLAttributes, type CSSProperties } from "react";
export interface DarkInnerProps extends Omit<
ButtonHTMLAttributes<HTMLButtonElement>,
"children"
> {
duration?: number;
[key: `data-${string}`]: string | number | boolean | null | undefined;
}
export function DarkInner({
duration = 500,
className,
type = "button",
title = "Toggle theme",
"aria-label": ariaLabel = "Toggle theme",
...props
}: DarkInnerProps) {
return (
<button
type={type}
title={title}
aria-label={ariaLabel}
className={className}
{...props}
>
<svg
width="1em"
height="1em"
viewBox="0 0 32 32"
aria-hidden="true"
fill={"currentColor"}
style={
{ "--toggles-dark-inner--duration": `${duration}ms` } as CSSProperties
}
>
<path
d={"M16 9c3.9 0 7 3.1 7 7s-3.1 7-7 7"}
className="origin-center transition-transform duration-(--toggles-dark-inner--duration) [transition-timing-function:ease] dark:rotate-180"
/>
<path
d={
"M16 .5C7.4.5.5 7.4.5 16S7.4 31.5 16 31.5 31.5 24.6 31.5 16 24.6.5 16 .5zm0 28.1V23c-3.9 0-7-3.1-7-7s3.1-7 7-7V3.4C23 3.4 28.6 9 28.6 16S23 28.6 16 28.6z"
}
className="origin-center transition-transform duration-(--toggles-dark-inner--duration) [transition-timing-function:ease] dark:-rotate-180"
/>
</svg>
</button>
);
} 1 Install the package
▾
npm install @theme-toggles/svelte pnpm add @theme-toggles/svelte yarn add @theme-toggles/svelte bun add @theme-toggles/svelte 2 Import and use
<script>
import { DarkInner } from "@theme-toggles/svelte";
import "@theme-toggles/svelte/styles/dark-inner.css";
</script>
<DarkInner /> 1 Copy the component
<script lang="ts">
import type { HTMLButtonAttributes } from "svelte/elements";
interface $$Props extends Omit<HTMLButtonAttributes, "children"> {
duration?: number;
ariaLabel?: string;
class?: string;
}
export let duration = 500;
export let type: HTMLButtonAttributes["type"] = "button";
export let title = "Toggle theme";
export let ariaLabel = "Toggle theme";
let className = "";
export { className as class };
</script>
<button
{type}
{title}
aria-label={ariaLabel}
class={className}
on:click
{...$$restProps}
>
<svg
width="1em"
height="1em"
viewBox="0 0 32 32"
aria-hidden="true"
fill={"currentColor"}
style={`--toggles-dark-inner--duration: ${duration}ms`}
>
<path
d={"M16 9c3.9 0 7 3.1 7 7s-3.1 7-7 7"}
class={"origin-center transition-transform duration-(--toggles-dark-inner--duration) [transition-timing-function:ease] dark:rotate-180"}
/>
<path
d={"M16 .5C7.4.5.5 7.4.5 16S7.4 31.5 16 31.5 31.5 24.6 31.5 16 24.6.5 16 .5zm0 28.1V23c-3.9 0-7-3.1-7-7s3.1-7 7-7V3.4C23 3.4 28.6 9 28.6 16S23 28.6 16 28.6z"}
class={"origin-center transition-transform duration-(--toggles-dark-inner--duration) [transition-timing-function:ease] dark:-rotate-180"}
/>
</svg>
</button> 1 Install the package
▾
npm install @theme-toggles/vue pnpm add @theme-toggles/vue yarn add @theme-toggles/vue bun add @theme-toggles/vue 2 Import and use
<script setup lang="ts">
import { DarkInner } from "@theme-toggles/vue";
import "@theme-toggles/vue/styles/dark-inner.css";
</script>
<template>
<DarkInner />
</template> 1 Copy the component
<script setup lang="ts">
import { useAttrs } from "vue";
interface Props {
duration?: number;
type?: "button" | "submit" | "reset";
title?: string;
ariaLabel?: string;
}
const props = withDefaults(defineProps<Props>(), {
duration: 500,
type: "button",
title: "Toggle theme",
ariaLabel: "Toggle theme",
});
const attrs = useAttrs();
</script>
<template>
<button
v-bind="attrs"
:type="props.type"
:title="props.title"
:aria-label="props.ariaLabel"
>
<svg
width="1em"
height="1em"
viewBox="0 0 32 32"
aria-hidden="true"
:fill="'currentColor'"
:style="{ '--toggles-dark-inner--duration': `${props.duration}ms` }"
>
<path
:d="'M16 9c3.9 0 7 3.1 7 7s-3.1 7-7 7'"
:class="'origin-center transition-transform duration-(--toggles-dark-inner--duration) [transition-timing-function:ease] dark:rotate-180'"
/>
<path
:d="'M16 .5C7.4.5.5 7.4.5 16S7.4 31.5 16 31.5 31.5 24.6 31.5 16 24.6.5 16 .5zm0 28.1V23c-3.9 0-7-3.1-7-7s3.1-7 7-7V3.4C23 3.4 28.6 9 28.6 16S23 28.6 16 28.6z'"
:class="'origin-center transition-transform duration-(--toggles-dark-inner--duration) [transition-timing-function:ease] dark:-rotate-180'"
/>
</svg>
</button>
</template>