Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

css-system/gatsby-plugin-css-system

Repository files navigation

gatsby-plugin-css-system

npm package

Getting started

You can download gatsby-plugin-css-system from the NPM registry via the npm or yarn commands

yarn add @css-system/gatsby-plugin-css-system
# OR
npm install @css-system/gatsby-plugin-css-system --save

Usage

Add the plugin in your gatsby-config.js file with a theme object following the theme ui specifications:

module.exports = {
 plugins: [
 {
 resolve: "@css-system/gatsby-plugin-css-system",
 options: {
 theme: {
 breakpoints: {
 s: "40em",
 m: "52em",
 l: "64em"
 },
 space: [0, 4, 8, 16, 32],
 fontSizes: [12, 14, 16, 20, 24],
 colors: {
 // your colors
 }
 }
 }
 }
 ]
};

It also provide support for multiple themes

module.exports = {
 plugins: [
 {
 resolve: "@css-system/gatsby-plugin-css-system",
 options: {
 defaultTheme: "light",
 themes: {
 light: {
 breakpoints: {
 s: "40em",
 m: "52em",
 l: "64em"
 },
 space: [0, 4, 8, 16, 32],
 fontSizes: [12, 14, 16, 20, 24],
 colors: {
 background: 'white'
 text: 'black'
 }
 },
 dark: {
 breakpoints: {
 s: "40em",
 m: "52em",
 l: "64em"
 },
 space: [0, 4, 8, 16, 32],
 fontSizes: [12, 14, 16, 20, 24],
 colors: {
 background: 'black'
 text: 'white'
 }
 }
 } {
 }
 }
 }
 ]
};
// You can then create a toggler component like this in your application
import {useSwitchTheme} from "@css-system/gatsby-plugin-css-system"
export const ToggleDarkThemeButton = () => {
 const [themeKey, switchTheme] = useSwitchTheme()
 const handleToggleDarkMode = () => switchTheme(themeKey === "dark" ? "light" : "dark")
 return <button onClick={handleToggleDarkMode}>{themeKey === "dark" ? "🌞" : "πŸŒ›"}</button>
}

For advanced configuration, please checkout documentation

About

Gatsby plugin to enable server-side rendering for css-system

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /