{"name":"@csstools/postcss-random-function","version":"3.0.3","keywords":["css","postcss-plugin","random"],"license":"MIT-0","_id":"@csstools/postcss-random-function@3.0.3","maintainers":[{"name":"jonathantneal","email":"jonathantneal@hotmail.com"},{"name":"alaguna","email":"sombragriselros@gmail.com"},{"name":"romainmenke","email":"romainmenke@gmail.com"}],"contributors":[{"url":"https://antonio.laguna.es","name":"Antonio Laguna","email":"antonio@laguna.es"},{"name":"Romain Menke","email":"romainmenke@gmail.com"}],"homepage":"https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-random-function#readme","bugs":{"url":"https://github.com/csstools/postcss-plugins/issues"},"dist":{"shasum":"9eb18f39fe92388503d9accfb9f85b2c76e9f025","tarball":"http://registry-npm.ywwl.com/@csstools/postcss-random-function/download/@csstools/postcss-random-function-3.0.3.tgz","fileCount":6,"integrity":"sha512-0EScyKxscGonwpi30Hj9DEAr0X8D2eDhOqqayQXE91gIqGli9UT+deLYqoogZLOy5GT+ncqltMqztc/q+0UkhA==","signatures":[{"sig":"MEUCIQCZzyV+/6Mv4QjZx/4k7eTzyso0jeD1EScnGa1fzk3YDwIgZvIOnkaUHXOS3ui0NG1e5pJGTThb/uOZMh/2Hm5Rd5Y=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":6786,"size":3025,"noattachment":false,"key":"/@csstools/postcss-random-function/-/@csstools/postcss-random-function-3.0.3.tgz"},"type":"module","engines":{"node":">=20.19.0"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.mjs"}},"funding":[{"url":"https://github.com/sponsors/csstools","type":"github"},{"url":"https://opencollective.com/csstools","type":"opencollective"}],"gitHead":"eb87d5e28a88514f5e239bcbb647fd985acd94a2","scripts":{},"_npmUser":{"name":"romainmenke","email":"romainmenke@gmail.com"},"repository":{"url":"git+https://github.com/csstools/postcss-plugins.git","type":"git","directory":"plugins/postcss-random-function"},"_npmVersion":"11.13.0","description":"Use the random function in CSS","directories":{},"_nodeVersion":"26.1.0","dependencies":{"@csstools/css-calc":"^3.2.1","@csstools/css-tokenizer":"^4.0.0","@csstools/css-parser-algorithms":"^4.0.0"},"_hasShrinkwrap":false,"peerDependencies":{"postcss":"^8.4"},"_npmOperationalInternal":{"tmp":"tmp/postcss-random-function_3.0.3_1778685154374_0.14199758761079462","host":"s3://npm-registry-packages-npm-production"},"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, 7deg));\n}\n\ndiv {\n\tmargin: random(10px, 100px) random(10px, 100px);\n\tpadding: random(--padding, 10px, 100px) random(--padding, 10px, 100px);\n}\n\n/* becomes */\n\ndiv {\n\tcolor: oklch(0.7 0.2 166.80407deg);\n}\n\ndiv {\n\tcolor: oklch(0.7 0.2 169deg);\n}\n\ndiv {\n\tmargin: 45.10305px 45.10305px;\n\tpadding: 73.36206px 73.36206px;\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, 7deg));\n}\n\ndiv {\n\tmargin: random(10px, 100px) random(10px, 100px);\n\tpadding: random(--padding, 10px, 100px) random(--padding, 10px, 100px);\n}\n\n/* becomes */\n\ndiv {\n\tcolor: oklch(0.7 0.2 166.80407deg);\n\tcolor: oklch(0.7 0.2 random(120deg, 240deg));\n}\n\ndiv {\n\tcolor: oklch(0.7 0.2 169deg);\n\tcolor: oklch(0.7 0.2 random(120deg, 240deg, 7deg));\n}\n\ndiv {\n\tmargin: 45.10305px 45.10305px;\n\tmargin: random(10px, 100px) random(10px, 100px);\n\tpadding: 73.36206px 73.36206px;\n\tpadding: random(--padding, 10px, 100px) random(--padding, 10px, 100px);\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":1778685154501,"_cnpm_publish_time":1778685154501,"dist-tags":{"latest":"4.0.6"}}