{"id":27320302,"url":"https://github.com/arccoza/postcss-if-media","last_synced_at":"2025-07-08T06:06:07.107Z","repository":{"id":57328111,"uuid":"50865854","full_name":"arccoza/postcss-if-media","owner":"arccoza","description":"A PostCSS plugin to inline or nest media queries within CSS rules \u0026 properties.","archived":false,"fork":false,"pushed_at":"2017-06-09T07:11:54.000Z","size":33,"stargazers_count":35,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-20T05:07:11.291Z","etag":null,"topics":["css","media-queries","postcss","postcss-plugins"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arccoza.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-01T19:44:17.000Z","updated_at":"2022-07-18T10:49:42.000Z","dependencies_parsed_at":"2022-08-23T14:00:58.322Z","dependency_job_id":null,"html_url":"https://github.com/arccoza/postcss-if-media","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/arccoza/postcss-if-media","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arccoza%2Fpostcss-if-media","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arccoza%2Fpostcss-if-media/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arccoza%2Fpostcss-if-media/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arccoza%2Fpostcss-if-media/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arccoza","download_url":"https://codeload.github.com/arccoza/postcss-if-media/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arccoza%2Fpostcss-if-media/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261211685,"owners_count":23125543,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css","media-queries","postcss","postcss-plugins"],"created_at":"2025-04-12T09:46:34.542Z","updated_at":"2025-07-08T06:06:07.087Z","avatar_url":"https://github.com/arccoza.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[travis]:               https://travis-ci.org/arccoza/postcss-if-media\n[travis-img]:           https://img.shields.io/travis/arccoza/postcss-if-media.svg\n[postcss-custom-media]: https://github.com/postcss/postcss-custom-media\n[postcss-media-minmax]: https://github.com/postcss/postcss-media-minmax\n# PostCSS ?If Media [![Travis Build Status][travis-img]][travis]\n\nA PostCSS plugin for adding `?if media` queries inside rules and inline with property values.\nA great way to keep style values for different media queries neatly organized and grouped together under their natural rules.\nUse with [PostCSS Media Minmax][postcss-media-minmax] and [PostCSS Custom Media][postcss-custom-media] for best effect (be sure to place postcss-if-media before postcss-media-minmax, and postcss-custom-media, or any other media query plugins).\n\n## Explanation\nThe plugin provides `?if media QUERY` as an inline declaration and a nested block, where `QUERY` is any valid media query.\n\nAny properties with the `?if media QUERY` declaration following their value, or any properties inside an `?if media QUERY { }` block will be extracted from their rule and placed in their own rule under an `@media QUERY` query.\n\nThe generated `@media` queries are placed directly after the original rule to maintain specificity.\n\n## Install\n`npm install postcss-if-media --save`\n\n## Example 1\nAn inline declaration example.\n\n```css\n/* Input. */\n.test {\n  position: relative;\n  margin: 0 1em ?if media (min-width: 1025px);\n  margin: 0 0.5em ?if media (min-width: 641px) and (max-width: 1024px);\n  margin: 0 0.3em ?if media (max-width: 640px);\n}\n\n/* Output. */\n.test {\n  position: relative;\n}\n\n@media (min-width: 1025px) {\n  .test {\n     margin: 0 1em;\n  }\n}\n@media (min-width: 641px) and (max-width: 1024px) {\n  .test {\n     margin: 0 0.5em;\n  }\n}\n@media (max-width: 640px) {\n  .test {\n     margin: 0 0.3em;\n  }\n}\n```\n\n## Example 2\nA nested block example.\n\n```css\n/* Input. */\n.test {\n  position: relative;\n  ?if media (min-width: 1025px) {\n    color: red;\n    margin: 0 1em;\n  }\n  ?if media (min-width: 641px) and (max-width: 1024px) {\n    color: green;\n    margin: 0 0.5em;\n  }\n  ?if media (max-width: 640px) {\n    color: blue;\n    margin: 0 0.3em;\n  }\n}\n\n/* Output. */\n.test {\n  position: relative;\n}\n\n@media (min-width: 1025px) {\n  .test {\n    color: red;\n    margin: 0 1em;\n  }\n}\n@media (min-width: 641px) and (max-width: 1024px) {\n  .test {\n    color: green;\n    margin: 0 0.5em;\n  }\n}\n@media (max-width: 640px) {\n  .test {\n    color: blue;\n    margin: 0 0.3em;\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farccoza%2Fpostcss-if-media","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farccoza%2Fpostcss-if-media","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farccoza%2Fpostcss-if-media/lists"}