Socket
Socket
Sign inDemoInstall

@css-system/use-css

Package Overview
Dependencies
9
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @css-system/use-css

A react hook for building versatile design primitives. It follow the (theme ui specifications)[https://github.com/system-ui/theme-specification].


Version published
Weekly downloads
6
increased by500%
Maintainers
2
Created
Weekly downloads
 

Readme

Source

css-system/use-css

A react hook for building versatile design primitives. It follow the (theme ui specifications)[https://github.com/system-ui/theme-specification].

Example

import React, {createContext, useContext} from "react"
import ReactDOM from "react-dom"
import {useCss, ThemeContext} from "@css-system/use-css"

const theme = {
  breakpoints: {s: "40em", m: "52em", l: "64em"},
  colors: {
    background: "#ffffff",
    text: "#000000",
    primary: "#ff0000",
  },
  space: [0, 4, 8, 16, 32],
  fontSizes: [0, 12, 14, 16, 20, 24, 32, 48, 64, 72],
}

const View = ({as: Component = "div", css, ...props}) => {
  const className = useCss({
    display: "flex",
    minWidth: 0,
    minHeight: 0,
    flex: "none",
    alignItems: "stretch",
    flexDirection: "column",
    justifyContent: "flex-start",
    ...css,
  })

  return <Component className={className} {...props} />
}

const Text = ({as: Component = "span", css, ...props}) => {
  const className = useCss({
    display: "inline",
    minWidth: 0,
    minHeight: 0,
    flex: "none",
    ...css,
  })

  return <Component className={className} {...props} />
}

const App = () => {
  return (
    <ThemeContext.Provider value={theme}>
      <View
        css={{
          p: {_: 0, s: 1, m: 2, l: 3},
          "&:hover": {
            bg: "text",
            color: "background",
          },
        }}
      >
        <Text css={{fontSize: {_: 1, m: 2}}}>Hello world !</Text>
      </View>
    </ThemeContext.Provider>
  )
}

FAQs

Last updated on 28 Feb 2020

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc