components
Tailwind CSS
Theme Controller If a checkbox or radio input with the theme-controller class is present on the page, the page's theme will be set to the value of that input.
The Theme Controller changes the theme using only CSS. You can use JavaScript to save the input state to the server or localStorage if you want it to persist across page refreshes.
Here’s an example demonstrating how to save the checkbox state in localStorage: Stackblitz
Use the theme-controller
component class with a checkbox input to create a theme switcher that toggles between the default theme and the theme specified in the value.
Copy
toggleRTL($refs.previewFrame), 100);
}" class="size-9.5 border-neutral/10 rounded-btn text-base-content hover:bg-neutral/[0.03] flex items-center justify-center gap-2 border max-sm:hidden">
Create a theme controller using a switch based on the example provided below.
Copy
toggleRTL($refs.previewFrame), 100);
}" class="size-9.5 border-neutral/10 rounded-btn text-base-content hover:bg-neutral/[0.03] flex items-center justify-center gap-2 border max-sm:hidden">
The example below shows how to implement a theme controller using a switch component.
Copy
toggleRTL($refs.previewFrame), 100);
}" class="size-9.5 border-neutral/10 rounded-btn text-base-content hover:bg-neutral/[0.03] flex items-center justify-center gap-2 border max-sm:hidden">
The example below illustrates how to create a theme controller using a switch combined with text.
Copy
toggleRTL($refs.previewFrame), 100);
}" class="size-9.5 border-neutral/10 rounded-btn text-base-content hover:bg-neutral/[0.03] flex items-center justify-center gap-2 border max-sm:hidden">
The example provided shows how to build a theme controller using a switch that features icons.
Copy
toggleRTL($refs.previewFrame), 100);
}" class="size-9.5 border-neutral/10 rounded-btn text-base-content hover:bg-neutral/[0.03] flex items-center justify-center gap-2 border max-sm:hidden">
The example below shows how to build a theme controller using a switch with personalized colors.
Copy
toggleRTL($refs.previewFrame), 100);
}" class="size-9.5 border-neutral/10 rounded-btn text-base-content hover:bg-neutral/[0.03] flex items-center justify-center gap-2 border max-sm:hidden">
Create a theme controller using a radio input based on the example below.
Copy
toggleRTL($refs.previewFrame), 100);
}" class="size-9.5 border-neutral/10 rounded-btn text-base-content hover:bg-neutral/[0.03] flex items-center justify-center gap-2 border max-sm:hidden">
The example below shows how to create a theme controller using a radio button.
Copy
toggleRTL($refs.previewFrame), 100);
}" class="size-9.5 border-neutral/10 rounded-btn text-base-content hover:bg-neutral/[0.03] flex items-center justify-center gap-2 border max-sm:hidden">
Here’s a ready-to-use example of a theme controller utilizing a dropdown menu.
For more information about dropdowns, refer to the
Dropdown
documentation.
Copy
toggleRTL($refs.previewFrame), 100);
}" class="size-9.5 border-neutral/10 rounded-btn text-base-content hover:bg-neutral/[0.03] flex items-center justify-center gap-2 border max-sm:hidden">