Level 29
Hey, I tried to quickly reproduce your issue in Tailwind playground but its working fine there, maybe I missed something.
This is the link of the playground: https://play.tailwindcss.com/D5XRioRO1C
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have a problem where I have a theme layout which I want in such a way for re usability.
The problem is, is that I wanna position theme layout on the page, relative to the whole page, but no matter what I do the navbar covers the button, if I give the button padding so it is below the navbar I can see it. So I messed about with the zIndex to no avail. I hope you can help.
import React, { useState, useEffect } from 'react'
export default function ThemeLayout({ children }) {
const [theme, setTheme] = useState(
localStorage.getItem("theme") || "light"
);
useEffect(() => {
document.documentElement.setAttribute("data-theme", theme);
localStorage.setItem("theme", theme);
}, [theme]);
const toggleTheme = () => {
setTheme((prevTheme) => (prevTheme === "light" ? "dark" : "light"));
};
return (
<div className={`${theme} text-primarytext overflow-x-hidden`}>
<label className="inline-flex items-center cursor-pointer">
<input type="checkbox" value="" className="sr-only peer" onClick={toggleTheme} />
<div
className="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-grey-600 dark:peer-focus:ring-grey-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-grey-900"
></div>fix this later problem with positioning and z index - has to be solo component
</label>
{children}
</div>
)
}
<label className="inline-flex items-center cursor-pointer">
<input type="checkbox" value="" className="sr-only peer" onClick={toggleTheme} />
<div
className="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-grey-600 dark:peer-focus:ring-grey-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-grey-900"
></div>fix this later problem with positioning and z index - has to be solo component
</label>
return (
<FadeInLayout>
<ThemeLayout>
<nav className="w-full bg-navbar border-b border-zinc-800">
Hey, I tried to quickly reproduce your issue in Tailwind playground but its working fine there, maybe I missed something.
This is the link of the playground: https://play.tailwindcss.com/D5XRioRO1C
Please or to participate in this conversation.