Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@css-system/gatsby-plugin-css-system

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@css-system/gatsby-plugin-css-system

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

  • 0.6.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
2
Weekly downloads
 
Created
Source

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

Keywords

FAQs

Package last updated on 14 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc