# @microsoft/arbutus.use-css-vars

> useCSSVars takes an object of theme values, generates CSS variables from them, and injects them into the document.

Latest version **1.1.2** (published 2023-11-29) · 0 weekly downloads

## Install

```sh
npm install @microsoft/arbutus.use-css-vars
pnpm add @microsoft/arbutus.use-css-vars
yarn add @microsoft/arbutus.use-css-vars
bun add @microsoft/arbutus.use-css-vars
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2023-11-29 |
| First published | 2022-09-22 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 19.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | jinjun-ms, riacarmin |

## Links

- npm: https://www.npmjs.com/package/@microsoft/arbutus.use-css-vars
- npm.io page: https://npm.io/package/@microsoft/arbutus.use-css-vars

## Dependencies (1)

- [@fluentui/utilities](https://npm.io/package/@fluentui/utilities.md) ^8.13.18

## Recent versions

- 1.1.2 (latest) — 2023-11-29
- 1.1.1 — 2023-11-09
- 1.1.0 — 2023-09-07
- 1.0.3 — 2023-06-05
- 1.0.2 — 2023-05-25
- 1.0.1 — 2023-04-26
- 1.0.0 — 2023-03-16
- 0.0.3 — 2023-01-16
- 0.0.2 — 2022-11-09
- 0.0.1 — 2022-09-22

## README

# Hook: useCSSVars

**useCSSVars takes an object of theme values, generates CSS variables from them, and injects them into the document.**

## Get Started

```sh
npm i @microsoft/arbutus.use-css-vars
```

```tsx
import { useCSSVars } from '@microsoft/arbutus.use-css-vars';
```

## Usage

- `theme` An object of theme values. An object can be nested (e.g. `color.button.primary: #fff` will translate to `--color-button-primary: #fff`).
- `prefix` A string to prefix all CSS variables with. This is an optional parameter, but it is recommended to use it to avoid CSS variable collisions.

```tsx
const theme = {
  color: {
    button: {
      primary: '#fff',
      secondary: '#000',
    },
  },
};

const MyAppShell = () => {
  // Injects CSS variables into the document.
  useCSSVars({ theme, prefix: 'MY_APP' });

  return <div>...</div>;
};
```

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