{"name":"@csstools/postcss-random-function","version":"4.0.3","keywords":["css","postcss-plugin","random"],"license":"MIT-0","_id":"@csstools/postcss-random-function@4.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":"cbcaed62922a51fd35766bcbd3097170014e04e5","tarball":"http://registry-npm.ywwl.com/@csstools/postcss-random-function/download/@csstools/postcss-random-function-4.0.3.tgz","fileCount":6,"integrity":"sha512-iKjQ2mQ/OE7T09pZGk0B/F83GzFZR4Fva+PwPBPRStcQ72clZ8HBKLidIhZhrcqgHxoxXSm5dgkLaBLPAMqL8Q==","signatures":[{"sig":"MEUCIEuBCoqnDNuRE+q7agpAfLjDt1yRy7k6a8tvos2WR7UIAiEAwVQUi5z31D0s5t/kNw3yUBZTVvlvljnK5VsTAbO5SWo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEUCIEjikxM0fxRYdhrQXGClKiytgnU/aktB7dbddUD3zWH2AiEAsJhWAwFrPfk3gAg9IBC7MA+uYi9tjGHnU/JAmT/CFeU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":7688,"size":3128,"noattachment":false,"key":"/@csstools/postcss-random-function/-/@csstools/postcss-random-function-4.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":"74d5677d1b12278797eb801cf468f79ef46fc907","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.4.1","@csstools/css-tokenizer":"^4.0.2","@csstools/css-parser-algorithms":"^4.0.1"},"_hasShrinkwrap":false,"peerDependencies":{"postcss":"^8.4"},"_npmOperationalInternal":{"tmp":"tmp/postcss-random-function_4.0.3_1790347604843_0.7322185416819766","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 calc(166.80407deg));\n}\n\ndiv {\n\tcolor: oklch(0.7 0.2 calc(169deg));\n}\n\ndiv {\n\tmargin: calc(45.10305px) calc(45.10305px);\n\tpadding: calc(73.36206px) calc(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 calc(166.80407deg));\n\tcolor: oklch(0.7 0.2 random(120deg, 240deg));\n}\n\ndiv {\n\tcolor: oklch(0.7 0.2 calc(169deg));\n\tcolor: oklch(0.7 0.2 random(120deg, 240deg, 7deg));\n}\n\ndiv {\n\tmargin: calc(45.10305px) calc(45.10305px);\n\tmargin: random(10px, 100px) random(10px, 100px);\n\tpadding: calc(73.36206px) calc(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":1790347604941,"_cnpm_publish_time":1790347604941,"dist-tags":{"latest":"4.0.6"}}