{"name":"@csstools/postcss-random-function","description":"Use the random function in CSS","version":"1.0.1","contributors":[{"name":"Antonio Laguna","email":"antonio@laguna.es","url":"https://antonio.laguna.es"},{"name":"Romain Menke","email":"romainmenke@gmail.com"}],"license":"MIT-0","funding":[{"type":"github","url":"https://github.com/sponsors/csstools"},{"type":"opencollective","url":"https://opencollective.com/csstools"}],"engines":{"node":">=18"},"type":"module","main":"dist/index.cjs","module":"dist/index.mjs","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.mjs"},"require":{"default":"./dist/index.cjs"}}},"dependencies":{"@csstools/css-calc":"^2.1.0","@csstools/css-parser-algorithms":"^3.0.4","@csstools/css-tokenizer":"^3.0.3"},"peerDependencies":{"postcss":"^8.4"},"scripts":{},"homepage":"https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-random-function#readme","repository":{"type":"git","url":"git+https://github.com/csstools/postcss-plugins.git","directory":"plugins/postcss-random-function"},"bugs":{"url":"https://github.com/csstools/postcss-plugins/issues"},"keywords":["css","postcss-plugin","random"],"_id":"@csstools/postcss-random-function@1.0.1","gitHead":"7efa9f66b5c90715fb77415a7c591a2346a0dd2c","types":"./dist/index.d.ts","_nodeVersion":"22.11.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-Ab/tF8/RXktQlFwVhiC70UNfpFQRhtE5fQQoP2pO+KCPGLsLdWFiOuHgSRtBOqEshCVAzR4H6o38nhvRZq8deA==","shasum":"73a0b62b5dbbc03c25a28f085235eb61b09a2fb0","tarball":"http://registry-npm.ywwl.com/@csstools/postcss-random-function/download/@csstools/postcss-random-function-1.0.1.tgz","fileCount":7,"unpackedSize":6801,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCLOt+5t4cSqmiVr9raiYSZTnaybQkoXQgt/dntbCtRmgIgGv2v2juE0d8mnDVRlbOBtyvlD/XUa4ev/9HobwtCHP0="}],"size":2888,"noattachment":false,"key":"/@csstools/postcss-random-function/-/@csstools/postcss-random-function-1.0.1.tgz"},"_npmUser":{"name":"romainmenke","email":"romainmenke@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/postcss-random-function_1.0.1_1731325413455_0.1518854309615787"},"_hasShrinkwrap":false,"readme":"# PostCSS Random Function [<img src=\"https://postcss.github.io/postcss/logo.svg\" alt=\"PostCSS Logo\" width=\"90\" height=\"90\" align=\"right\">][PostCSS]\n\n`npm install @csstools/postcss-random-function --save-dev`\n\n[PostCSS Random Function] lets you use the `random` function, following the [CSS Values 5] specification.\n\n```css\ndiv {\n\tcolor: oklch(0.7, 0.2, random(120deg, 240deg));\n}\n\ndiv {\n\tcolor: oklch(0.7, 0.2, random(120deg, 240deg, by 7deg));\n}\n\ndiv {\n\tcolor: oklch(0.7, 0.2, random(--text, 120deg, 240deg));\n\tborder-color: oklch(0.7, 0.2, random(--border, 120deg, 240deg));\n}\n\n/* becomes */\n\ndiv {\n\tcolor: oklch(0.7, 0.2, 238.66036deg);\n}\n\ndiv {\n\tcolor: oklch(0.7, 0.2, 134deg);\n}\n\ndiv {\n\tcolor: oklch(0.7, 0.2, 226.47057deg);\n\tborder-color: oklch(0.7, 0.2, 157.76966deg);\n}\n```\n\n> [!NOTE]\n> Generated values are deterministic pseudo random numbers.\n> Generating values twice with the same input will give the same result.\n> The input length of the CSS source file is used as a random seed.\n\n## Usage\n\nAdd [PostCSS Random Function] to your project:\n\n```bash\nnpm install postcss @csstools/postcss-random-function --save-dev\n```\n\nUse it as a [PostCSS] plugin:\n\n```js\nconst postcss = require('postcss');\nconst postcssRandomFunction = require('@csstools/postcss-random-function');\n\npostcss([\n\tpostcssRandomFunction(/* pluginOptions */)\n]).process(YOUR_CSS /*, processOptions */);\n```\n\n\n\n## ⚠️ About custom properties\n\nGiven the dynamic nature of custom properties it's impossible to know what the variable value is, which means the plugin can't compute a final value for the stylesheet. \n\nBecause of that, any usage that contains a `var` is skipped.\n\n## Options\n\n### preserve\n\nThe `preserve` option determines whether the original notation\nis preserved. By default, it is not preserved.\n\n```js\npostcssRandomFunction({ preserve: true })\n```\n\n```css\ndiv {\n\tcolor: oklch(0.7, 0.2, random(120deg, 240deg));\n}\n\ndiv {\n\tcolor: oklch(0.7, 0.2, random(120deg, 240deg, by 7deg));\n}\n\ndiv {\n\tcolor: oklch(0.7, 0.2, random(--text, 120deg, 240deg));\n\tborder-color: oklch(0.7, 0.2, random(--border, 120deg, 240deg));\n}\n\n/* becomes */\n\ndiv {\n\tcolor: oklch(0.7, 0.2, 238.66036deg);\n\tcolor: oklch(0.7, 0.2, random(120deg, 240deg));\n}\n\ndiv {\n\tcolor: oklch(0.7, 0.2, 134deg);\n\tcolor: oklch(0.7, 0.2, random(120deg, 240deg, by 7deg));\n}\n\ndiv {\n\tcolor: oklch(0.7, 0.2, 226.47057deg);\n\tcolor: oklch(0.7, 0.2, random(--text, 120deg, 240deg));\n\tborder-color: oklch(0.7, 0.2, 157.76966deg);\n\tborder-color: oklch(0.7, 0.2, random(--border, 120deg, 240deg));\n}\n```\n\n[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test\n[css-url]: https://cssdb.org/#random-function\n[discord]: https://discord.gg/bUadyRwkJS\n[npm-url]: https://www.npmjs.com/package/@csstools/postcss-random-function\n\n[PostCSS]: https://github.com/postcss/postcss\n[PostCSS Random Function]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-random-function\n[CSS Values 5]: https://drafts.csswg.org/css-values-5/#random\n","publish_time":1731325413632,"maintainers":[{"name":"romainmenke","email":"romainmenke@gmail.com"},{"name":"alaguna","email":"sombragriselros@gmail.com"},{"name":"jonathantneal","email":"jonathantneal@hotmail.com"}],"_cnpm_publish_time":1731325413632,"dist-tags":{"latest":"4.0.6"}}