2.0.0 • Published 8 months ago
tacos v2.0.0
Tacos
Boostrap a Next.js project with components, API routes, and utilities.
Usage
In a Next.js project:
npm i tacos
Theme (light/dark modes)
Comes with support for dark
and light
themes, and system
for the current user agent theme. To set it up, in app/layout.tsx
, add the ThemeSetter
component within <head>
, and suppressHydrationWarning
, data-theme-preference=""
, and data-theme=""
on <html>
:
import ThemeSetter from 'tacos/components/theme-setter';
export default function Layout() {
return (
<html suppressHydrationWarning data-theme-preference="" data-theme="">
<head>
<ThemeSetter />
</head>
{/* ... */}
</html>
);
}
Then, within your CSS, you can do the following:
.component {
color: black;
:where([data-theme='dark']) & {
color: white;
}
}
Use the current theme
import {useTheme} from 'tacos/components/theme-setter';
function Component() {
const theme = useTheme();
console.log(theme); // > dark
}
Change theme preference
import {setThemePreference} from 'tacos/components/theme-setter';
function Component() {
const handleClick = useCallback(() => {
setThemePreference('dark');
}, []);
return <button onClick={handleClick}>Use dark mode</button>;
}
1.0.0
8 months ago
2.0.0
8 months ago
0.0.6
9 months ago
0.0.1
11 months ago
0.0.3
11 months ago
0.0.2
11 months ago
0.0.4
11 months ago
1.1.11
8 years ago
1.1.10
8 years ago
1.1.9
8 years ago
1.1.8
8 years ago
1.1.7
8 years ago
1.1.6
8 years ago
1.1.5
8 years ago
1.1.4
8 years ago
1.1.3
8 years ago
1.1.2
8 years ago
1.1.1
8 years ago
1.1.0
8 years ago
1.0.7
8 years ago
1.0.6
8 years ago
1.0.5
8 years ago
1.0.4
8 years ago
1.0.3
8 years ago
0.2.0
8 years ago
0.1.0
8 years ago