{"name":"@csstools/postcss-light-dark-function","version":"3.0.0","keywords":["postcss-plugin"],"license":"MIT-0","_id":"@csstools/postcss-light-dark-function@3.0.0","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-light-dark-function#readme","bugs":{"url":"https://github.com/csstools/postcss-plugins/issues"},"dist":{"shasum":"5f35f34381f79d4f13e3c27368eae24521692d60","tarball":"http://registry-npm.ywwl.com/@csstools/postcss-light-dark-function/download/@csstools/postcss-light-dark-function-3.0.0.tgz","fileCount":6,"integrity":"sha512-s++V5/hYazeRUCYIn2lsBVzUsxdeC46gtwpgW6lu5U/GlPOS5UTDT14kkEyPgXmFbCvaWLREqV7YTMJq1K3G6w==","signatures":[{"sig":"MEUCID8h6897aUxWftdDBUgTOjbjvl+8xxi11OUqSRph/YNZAiEAhdm2u+rP/NWST4ludyTl+rnVzPvEBkLluge7hlJXDvk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":12609,"size":4489,"noattachment":false,"key":"/@csstools/postcss-light-dark-function/-/@csstools/postcss-light-dark-function-3.0.0.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":"d74e0e861d45a670578074ccc5b4595d50a52bad","scripts":{},"_npmUser":{"name":"romainmenke","email":"romainmenke@gmail.com"},"repository":{"url":"git+https://github.com/csstools/postcss-plugins.git","type":"git","directory":"plugins/postcss-light-dark-function"},"_npmVersion":"11.6.2","description":"Use the light-dark() color function in CSS","directories":{},"_nodeVersion":"25.1.0","dependencies":{"@csstools/utilities":"^3.0.0","@csstools/css-tokenizer":"^4.0.0","@csstools/css-parser-algorithms":"^4.0.0","@csstools/postcss-progressive-custom-properties":"^5.0.0"},"_hasShrinkwrap":false,"peerDependencies":{"postcss":"^8.4"},"_npmOperationalInternal":{"tmp":"tmp/postcss-light-dark-function_3.0.0_1768375750845_0.010198797929519277","host":"s3://npm-registry-packages-npm-production"},"readme":"# PostCSS Light Dark 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-light-dark-function --save-dev`\n\n[PostCSS Light Dark Function] lets you use the `light-dark` color function in\nCSS, following the [CSS Color 5 Specification].\n\nRead more about this feature on mdn:\n- define the colors for light and dark with [`light-dark()`](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/light-dark)\n- define which elements support light and/or dark with [`color-scheme`](https://developer.mozilla.org/en-US/docs/Web/CSS/color-scheme)\n\nWith both features combined you can mix and match color schemes in a single document, while also respecting the user's preferences.\n\n```css\n.foo {\n\tcolor: light-dark(pink, magenta);\n}\n\n.bar {\n\t--bar: light-dark(cyan, deepskyblue);\n}\n\n/* becomes */\n\n.foo {\n\t--csstools-light-dark-toggle--0: var(--csstools-color-scheme--light) magenta;\n\tcolor: var(--csstools-light-dark-toggle--0, pink);\n\tcolor: light-dark(pink, magenta);\n}\n\n.bar {\n\t--csstools-light-dark-toggle--1: var(--csstools-color-scheme--light) deepskyblue;\n\t--bar: var(--csstools-light-dark-toggle--1, cyan);\n\t@supports not (color: light-dark(tan, tan)) {\n\n\t\t& * {\n\t--csstools-light-dark-toggle--1: var(--csstools-color-scheme--light) deepskyblue;\n\t--bar: var(--csstools-light-dark-toggle--1, cyan);\n\t\t}\n\t}\n}\n\n@supports (color: light-dark(red, red)) {\n.bar {\n\t--bar: light-dark(cyan, deepskyblue);\n}\n}\n```\n\nDeclare that your document supports both light and dark mode:\n\n```css\n:root {\n\tcolor-scheme: light dark;\n}\n\n/* becomes */\n\n:root {\n\t--csstools-color-scheme--light: initial;\n\tcolor-scheme: light dark;\n}@media (prefers-color-scheme: dark) {:root {\n\t--csstools-color-scheme--light:  ;\n}\n}\n```\n\nDynamically alter the supported color scheme for some elements:\n\n```css\n:root {\n\t/* Root only supports light mode */\n\tcolor-scheme: light;\n}\n\n.foo {\n\t/* This element and its children only support dark mode */\n\tcolor-scheme: dark;\n}\n\n/* becomes */\n\n:root {\n\t/* Root only supports light mode */\n\t--csstools-color-scheme--light: initial;\n\tcolor-scheme: light;\n}\n\n.foo {\n\t/* This element and its children only support dark mode */\n\t--csstools-color-scheme--light:  ;\n\tcolor-scheme: dark;\n}\n```\n\n## Usage\n\nAdd [PostCSS Light Dark Function] to your project:\n\n```bash\nnpm install postcss @csstools/postcss-light-dark-function --save-dev\n```\n\nUse it as a [PostCSS] plugin:\n\n```js\nconst postcss = require('postcss');\nconst postcssLightDarkFunction = require('@csstools/postcss-light-dark-function');\n\npostcss([\n\tpostcssLightDarkFunction(/* pluginOptions */)\n]).process(YOUR_CSS /*, processOptions */);\n```\n\n\n\n## Options\n\n### preserve\n\nThe `preserve` option determines whether the original notation\nis preserved. By default, it is preserved.\n\n```js\npostcssLightDarkFunction({ preserve: false })\n```\n\n```css\n.foo {\n\tcolor: light-dark(pink, magenta);\n}\n\n.bar {\n\t--bar: light-dark(cyan, deepskyblue);\n}\n\n/* becomes */\n\n.foo {\n\t--csstools-light-dark-toggle--0: var(--csstools-color-scheme--light) magenta;\n\tcolor: var(--csstools-light-dark-toggle--0, pink);\n}\n\n.bar {\n\t--csstools-light-dark-toggle--1: var(--csstools-color-scheme--light) deepskyblue;\n\t--bar: var(--csstools-light-dark-toggle--1, cyan);\n\t& * {\n\t--csstools-light-dark-toggle--1: var(--csstools-color-scheme--light) deepskyblue;\n\t--bar: var(--csstools-light-dark-toggle--1, cyan);\n\t}\n}\n```\n\n### enableProgressiveCustomProperties\n\nThe `enableProgressiveCustomProperties` option determines whether the original notation\nis wrapped with `@supports` when used in Custom Properties. By default, it is enabled.\n\n> [!NOTE]\n> We only recommend disabling this when you set `preserve` to `false` or if you bring your own fix for Custom Properties.  \n> See what the plugin does in its [README](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties#readme).\n\n```js\npostcssLightDarkFunction({ enableProgressiveCustomProperties: false })\n```\n\n[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test\n[css-url]: https://cssdb.org/#light-dark-function\n[discord]: https://discord.gg/bUadyRwkJS\n[npm-url]: https://www.npmjs.com/package/@csstools/postcss-light-dark-function\n\n[PostCSS]: https://github.com/postcss/postcss\n[PostCSS Light Dark Function]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-light-dark-function\n[CSS Color 5 Specification]: https://drafts.csswg.org/css-color-5/#light-dark\n","publish_time":1768375751019,"_cnpm_publish_time":1768375751019,"dist-tags":{"latest":"3.0.9"}}