# react-style-singleton

> Just create a single stylesheet...

Latest version **2.2.3** (published 2024-12-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-style-singleton
pnpm add react-style-singleton
yarn add react-style-singleton
bun add react-style-singleton
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

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

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.3 |
| Published | 2024-12-15 |
| First published | 2018-06-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 2 |
| Unpacked size | 19 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | Anton Korzunov |
| Maintainers | kashey |
| Keywords | react, style, css |

## Links

- npm: https://www.npmjs.com/package/react-style-singleton
- Repository: https://github.com/theKashey/react-style-singleton
- Homepage: https://github.com/theKashey/react-style-singleton#readme
- Issues: https://github.com/theKashey/react-style-singleton/issues
- npm.io page: https://npm.io/package/react-style-singleton

## Dependencies (2)

- [tslib](https://npm.io/package/tslib.md) ^2.0.0
- [get-nonce](https://npm.io/package/get-nonce.md) ^1.0.0

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 2.2.3 (latest) — 2024-12-15
- 2.2.2 — 2024-12-15
- 2.2.1 — 2022-06-06
- 2.2.0 — 2022-04-17
- 2.1.1 — 2020-11-27
- 2.1.0 — 2020-04-16
- 2.0.0 — 2019-06-04
- 1.1.1 — 2019-01-20
- 1.1.0 — 2018-12-06
- 1.0.1 — 2018-06-07

## README

react-style-singleton
====

__300b__ with all dependencies, minified and gzipped


Creates a style component with internal _tracker_.
- Adds styles to the browser on the __first__ instance mount.
- Removes after the __last__ instance unmount.
- Thus helps you deliver styles you need to the customer, and clean up later.
- Is not server-side rendering compatible!


# API

## Component

```js
import {styleSingleton} from 'react-style-singleton'

const Style = styleSingleton();

export const App = () => (
  <Style styles={'body {color:red}'} />
);
```

## Hook

```js
import {styleHookSingleton} from 'react-style-singleton';

const useStyle = styleHookSingleton();
const useAnotherStyle = styleHookSingleton();

export const App = () => {
  useStyle('div {color:red}');
  useAnotherStyle('body { background-color:red }');
  return (<div />);
}
```

# License

MIT

---
_Source: https://npm.io/package/react-style-singleton · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
