# @csstools/postcss-private-rule

> Declare private custom properties

Latest version **1.1.1** (published 2026-10-02) · MIT-0 license · 0 weekly downloads

## Install

```sh
npm install @csstools/postcss-private-rule
pnpm add @csstools/postcss-private-rule
yarn add @csstools/postcss-private-rule
bun add @csstools/postcss-private-rule
```

## Health

**Score 60/100 (C)** — status: active.

Positive: esm support; no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2026-10-02 |
| First published | 2026-08-30 |
| Weekly downloads | 0 |
| License | MIT-0 |
| TypeScript types | none |
| Module format | ESM |
| Node | >=20.19.0 |
| Dependencies | 2 |
| Unpacked size | 9.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1057 |
| Maintainers | jonathantneal, alaguna, romainmenke |
| Keywords | at-rule, css, custom-property, fallback, postcss, postcss-plugin, private |

## Links

- npm: https://www.npmjs.com/package/@csstools/postcss-private-rule
- Repository: https://github.com/csstools/postcss-plugins
- Homepage: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-private-rule#readme
- Issues: https://github.com/csstools/postcss-plugins/issues
- Funding: https://github.com/sponsors/csstools
- npm.io page: https://npm.io/package/@csstools/postcss-private-rule

## Dependencies (2)

- [@csstools/css-tokenizer](https://npm.io/package/@csstools/css-tokenizer.md) ^4.0.2
- [@csstools/css-parser-algorithms](https://npm.io/package/@csstools/css-parser-algorithms.md) ^4.0.2

## 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

- 1.1.1 (latest) — 2026-10-02
- 1.1.0 — 2026-10-01
- 1.0.3 — 2026-09-25
- 1.0.2 — 2026-09-15
- 1.0.1 — 2026-09-06
- 1.0.0 — 2026-08-30

## README

# PostCSS Private Rule [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS]

`npm install @csstools/postcss-private-rule --save-dev`

[PostCSS Private Rule] lets you declare private custom properties following the [CSS Mixins Specification].

```css
section {
	@private {
		--size: 2px;
	}

	&, & > h1 {
		border-width: var(--size);
	}
}

section > h1 {
	--size: 4px;
}

/* becomes */

section {
		--_csstools-p-1gice1e-0--size: 2px;

	&, & > h1 {
		border-width: var(--_csstools-p-1gice1e-0--size);
	}
}

section > h1 {
	--size: 4px;
}
```

## Usage

Add [PostCSS Private Rule] to your project:

```bash
npm install postcss @csstools/postcss-private-rule --save-dev
```

Use it as a [PostCSS] plugin:

```js
const postcss = require('postcss');
const postcssPrivateRule = require('@csstools/postcss-private-rule');

postcss([
	postcssPrivateRule(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);
```



[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
[css-url]: https://cssdb.org/#private-rule
[discord]: https://discord.gg/bUadyRwkJS
[npm-url]: https://www.npmjs.com/package/@csstools/postcss-private-rule

[PostCSS]: https://github.com/postcss/postcss
[PostCSS Private Rule]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-private-rule
[CSS Mixins Specification]: https://drafts.csswg.org/css-mixins-1/#private

---
_Source: https://npm.io/package/@csstools/postcss-private-rule · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
