{"_id":"postcss-custom-selectors@9.0.3","bugs":{"url":"https://github.com/csstools/postcss-plugins/issues"},"dist":{"shasum":"ef9ff966741a51a3e153741f5be8ef03c125d6e8","tarball":"http://registry-npm.ywwl.com/postcss-custom-selectors/download/postcss-custom-selectors-9.0.3.tgz","fileCount":6,"integrity":"sha512-FlYMQTjrazt70kXReUDrNW83ZNdmDzGEJ/fiTYgvvCROWaU0E/ahhJiEmI8eM2mahFt8kQ66bFwN95DTvn2dQw==","signatures":[{"sig":"MEQCICsFYLD+Q1JInGNqsJNGyUijsGUdNKBpT5CpCXtzSYHWAiAq/7sPpDMpxVKs2wISOP5ZUV7Y9agBH5Fedv5CZ7lidA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHuXri4Ujrm//i1cFH7t0O2yC3xo+ke4obxMfF+JERI6AiEAmFWNh9A6hnDIZHPccACKxmZ06P4I2H5AgJjEVhy0nL8="}],"unpackedSize":10237,"size":4156,"noattachment":false,"key":"/postcss-custom-selectors/-/postcss-custom-selectors-9.0.3.tgz"},"name":"postcss-custom-selectors","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":"1fc17a3350bdf9176e1353e4a73103b89892046d","license":"MIT","scripts":{},"version":"9.0.3","_npmUser":{"name":"romainmenke","email":"romainmenke@gmail.com"},"homepage":"https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-custom-selectors#readme","keywords":["at-rule","css","csswg","custom","declarative","extension","postcss","postcss-plugin","selector","specification","w3c"],"repository":{"url":"git+https://github.com/csstools/postcss-plugins.git","type":"git","directory":"plugins/postcss-custom-selectors"},"_npmVersion":"11.13.0","description":"Use Custom Selectors in CSS","directories":{},"maintainers":[{"name":"jonathantneal","email":"jonathantneal@hotmail.com"},{"name":"alaguna","email":"sombragriselros@gmail.com"},{"name":"romainmenke","email":"romainmenke@gmail.com"},{"name":"yisi","email":"yiorsi@gmail.com"},{"name":"moox","email":"npm@moox.io"},{"name":"semigradsky","email":"semigradskyd@gmail.com"}],"_nodeVersion":"26.1.0","contributors":[{"url":"https://antonio.laguna.es","name":"Antonio Laguna","email":"antonio@laguna.es"},{"name":"Romain Menke","email":"romainmenke@gmail.com"},{"name":"Jonathan Neal","email":"jonathantneal@hotmail.com"},{"name":"Maxime Thirouin"},{"name":"yisi"}],"dependencies":{"@csstools/css-tokenizer":"^4.0.2","postcss-selector-parser":"^7.1.1","@csstools/css-parser-algorithms":"^4.0.2","@csstools/cascade-layer-name-parser":"^3.0.2"},"_hasShrinkwrap":false,"peerDependencies":{"postcss":"^8.4"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/postcss-custom-selectors_9.0.3_1790835492212_0.19476300355147558"},"readme":"# PostCSS Custom Selectors [<img src=\"https://postcss.github.io/postcss/logo.svg\" alt=\"PostCSS Logo\" width=\"90\" height=\"90\" align=\"right\">][PostCSS]\n\n`npm install postcss-custom-selectors --save-dev`\n\n[PostCSS Custom Selectors] lets you define `@custom-selector` in CSS following the [Custom Selectors Specification].\n\n```css\n@custom-selector :--heading h1, h2, h3;\n\narticle :--heading + p {\n\tmargin-top: 0;\n}\n\n/* becomes */\n\narticle :is(h1, h2, h3) + p {\n\tmargin-top: 0;\n}\n```\n\n## Usage\n\nAdd [PostCSS Custom Selectors] to your project:\n\n```bash\nnpm install postcss postcss-custom-selectors --save-dev\n```\n\nUse it as a [PostCSS] plugin:\n\n```js\nconst postcss = require('postcss');\nconst postcssCustomSelectors = require('postcss-custom-selectors');\n\npostcss([\n\tpostcssCustomSelectors(/* 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 not preserved.\n\n```js\npostcssCustomSelectors({ preserve: true })\n```\n\n```css\n@custom-selector :--heading h1, h2, h3;\n\narticle :--heading + p {\n\tmargin-top: 0;\n}\n\n/* becomes */\n\n@custom-selector :--heading h1, h2, h3;\n\narticle :is(h1, h2, h3) + p {\n\tmargin-top: 0;\n}\n\narticle :--heading + p {\n\tmargin-top: 0;\n}\n```\n\n## Modular CSS Processing\n\nIf you're using Modular CSS such as, CSS Modules, `postcss-loader` or `vanilla-extract` to name a few, you'll probably\nnotice that custom selectors are not being resolved. This happens because each file is processed separately so\nunless you import the custom selector definitions in each file, they won't be resolved.\n\nTo overcome this, we recommend using the [PostCSS Global Data](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-global-data#readme)\nplugin which allows you to pass a list of files that will be globally available. The plugin won't inject any extra code\nin the output but will provide the context needed to resolve custom selectors.\n\nFor it to run it needs to be placed before the [PostCSS Custom Selectors] plugin.\n\n```js\nconst postcss = require('postcss');\nconst postcssCustomSelectors = require('postcss-custom-selectors');\nconst postcssGlobalData = require('@csstools/postcss-global-data');\n\npostcss([\n\tpostcssGlobalData({\n\t\tfiles: [\n\t\t\t'path/to/your/custom-selectors.css'\n\t\t]\n\t}),\n\tpostcssCustomSelectors(/* pluginOptions */)\n]).process(YOUR_CSS /*, processOptions */);\n```\n\n[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test\n[css-url]: https://cssdb.org/#custom-selectors\n[discord]: https://discord.gg/bUadyRwkJS\n[npm-url]: https://www.npmjs.com/package/postcss-custom-selectors\n\n[PostCSS]: https://github.com/postcss/postcss\n[PostCSS Custom Selectors]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-custom-selectors\n[Custom Selectors Specification]: https://drafts.csswg.org/css-extensions/#custom-selectors\n","publish_time":1790835492293,"_cnpm_publish_time":1790835492293,"dist-tags":{"latest":"9.0.5"}}