Sun Jul 14 2024 15:32:24 GMT+0000 (Coordinated Universal Time)
Saved by @ishwarpatel100 #tailwind
// tailwind.config.js module.exports = { theme: { extend: { colors: { red: 'hsl(14, 86%, 42%)', green: 'hsl(159, 69%, 38%)', rose: { 50: 'hsl(20, 50%, 98%)', 100: 'hsl(13, 31%, 94%)', 300: 'hsl(14, 25%, 72%)', 400: 'hsl(7, 20%, 60%)', 500: 'hsl(12, 20%, 44%)', 900: 'hsl(14, 65%, 9%)', }, }, }, }, };
#alpinejs #tailwind
<button x-cloak x-data="{scroll : false}" @scroll.window="document.documentElement.scrollTop > 20 ? scroll = true : scroll = false" x-show="scroll" @click="window.scrollTo({top: 0, behavior: 'smooth'})" type="button" data-mdb-ripple="true" data-mdb-ripple-color="light" class="fixed inline-block p-3 text-xs font-medium leading-tight text-white uppercase transition duration-150 ease-in-out bg-blue-600 rounded-full shadow-md hover:bg-blue-700 hover:shadow-lg focus:bg-blue-700 focus:shadow-lg focus:outline-none focus:ring-0 active:bg-blue-800 active:shadow-lg bottom-5 right-5" id="btn-back-to-top" x-transition.opacity> <svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4" viewBox="0 0 20 20" fill="currentColor"> <path fill-rule="evenodd" d="M3.293 9.707a1 1 0 010-1.414l6-6a1 1 0 011.414 0l6 6a1 1 0 01-1.414 1.414L11 5.414V17a1 1 0 11-2 0V5.414L4.707 9.707a1 1 0 01-1.414 0z" clip-rule="evenodd" /> </svg> </button>
##javascript ##react #tailwind
// Button.jsx import classnames from 'classnames'; function Button ({size, bgColor, textColor, children}) { return ( <button className={classnames("bg-${bgColor} text-${textColor} font-bold py-2 px-4 rounded", { "text-xs": size === 'sm' "text-xl": size === 'lg', })}> {children} </button> ) }; export default Button;
#hyrdation #mismatch #tailwind #darkmode #dark #mode #fix
import { useTheme } from 'next-themes' const ThemeChanger = () => { const [mounted, setMounted] = useState(false) const { theme, setTheme } = useTheme() // When mounted on client, now we can show the UI useEffect(() => setMounted(true), []) if (!mounted) return null return ( <div> The current theme is: {theme} <button onClick={() => setTheme('light')}>Light Mode</button> <button onClick={() => setTheme('dark')}>Dark Mode</button> </div> ) }
#alpinejs #select #tailwind
#react #react.js #javascript #jsx #tailwind #css
export function TailwindIndicator() { if (process.env.NODE_ENV === "production") return null return ( <div className="fixed bottom-1 left-1 z-50 flex h-6 w-6 items-center justify-center rounded-full bg-gray-800 p-3 font-mono text-xs text-white"> <div className="block sm:hidden">xs</div> <div className="hidden sm:block md:hidden">sm</div> <div className="hidden md:block lg:hidden">md</div> <div className="hidden lg:block xl:hidden">lg</div> <div className="hidden xl:block 2xl:hidden">xl</div> <div className="hidden 2xl:block">2xl</div> </div> ) }
#tailwind
Copy this HTML code:
Preview:
open_in_newInstructions on embedding in Medium
Comments