# @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].

Latest version **0.4.1** (published 2020-02-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install @css-system/use-css
pnpm add @css-system/use-css
yarn add @css-system/use-css
bun add @css-system/use-css
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.1 |
| Published | 2020-02-28 |
| First published | 2020-02-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=8 |
| Dependencies | 1 |
| Unpacked size | 130.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | myagoo, xuopled |

## Links

- npm: https://www.npmjs.com/package/@css-system/use-css
- Repository: https://github.com/css-system/use-css
- Homepage: https://css-system.github.io/use-css
- npm.io page: https://npm.io/package/@css-system/use-css

## Dependencies (1)

- [hash-sum](https://npm.io/package/hash-sum.md) ^2.0.0

## Recent versions

- 0.4.1 (latest) — 2020-02-28
- 0.4.0 — 2020-02-28
- 0.3.0 — 2020-02-27
- 0.2.0 — 2020-02-24
- 0.1.0 — 2020-02-17

## README

# 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

```jsx
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>
  )
}
```

---
_Source: https://npm.io/package/@css-system/use-css · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
