{"id":13564600,"url":"https://github.com/csstools/postcss-focus-within","last_synced_at":"2025-04-03T21:31:14.526Z","repository":{"id":47009164,"uuid":"121896918","full_name":"csstools/postcss-focus-within","owner":"csstools","description":"Use the :focus-within pseudo-selector in CSS","archived":true,"fork":false,"pushed_at":"2021-12-16T16:37:49.000Z","size":335,"stargazers_count":31,"open_issues_count":0,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-20T03:48:32.211Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-focus-within","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/csstools.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-17T22:11:30.000Z","updated_at":"2025-02-07T12:32:44.000Z","dependencies_parsed_at":"2022-09-13T08:40:49.892Z","dependency_job_id":null,"html_url":"https://github.com/csstools/postcss-focus-within","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csstools%2Fpostcss-focus-within","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csstools%2Fpostcss-focus-within/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csstools%2Fpostcss-focus-within/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csstools%2Fpostcss-focus-within/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/csstools","download_url":"https://codeload.github.com/csstools/postcss-focus-within/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245980036,"owners_count":20704048,"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":[],"created_at":"2024-08-01T13:01:33.454Z","updated_at":"2025-04-03T21:31:11.493Z","avatar_url":"https://github.com/csstools.png","language":"CSS","funding_links":[],"categories":["CSS"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e⚠️ PostCSS Focus Within was moved to \u003ca href=\"https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-focus-within\"\u003e@csstools/postcss-plugins\u003c/a\u003e. ⚠️ \u003cbr\u003e\n\u003ca href=\"https://github.com/csstools/postcss-plugins/discussions/75\"\u003eRead the announcement\u003c/a\u003e\u003c/div\u003e\n\n# PostCSS Focus Within [\u003cimg src=\"https://postcss.github.io/postcss/logo.svg\" alt=\"PostCSS Logo\" width=\"90\" height=\"90\" align=\"right\"\u003e][postcss]\n\n[\u003cimg alt=\"npm version\" src=\"https://img.shields.io/npm/v/postcss-focus-within.svg\" height=\"20\"\u003e][npm-url]\n[\u003cimg alt=\"CSS Standard Status\" src=\"https://cssdb.org/badge/focus-within-pseudo-class.svg\" height=\"20\"\u003e][css-url]\n[\u003cimg alt=\"Build Status\" src=\"https://github.com/csstools/postcss-focus-within/workflows/test/badge.svg\" height=\"20\"\u003e][cli-url]\n[\u003cimg alt=\"support chat\" src=\"https://img.shields.io/badge/support-chat-blue.svg\" height=\"20\"\u003e][git-url]\n\n[PostCSS Focus Within] lets you use the `:focus-within` pseudo-class in CSS,\nfollowing the [Selectors Level 4 specification].\n\nIt is the companion to the [focus-within polyfill].\n\n[!['Can I use' table](https://caniuse.bitsofco.de/image/css-focus-within.png)](https://caniuse.com/#feat=css-focus-within)\n\n```css\n.my-form-field:focus-within label {\n  background-color: yellow;\n}\n\n/* becomes */\n\n.my-form-field[focus-within] label {\n  background-color: yellow;\n}\n\n.my-form-field:focus-within label {\n  background-color: yellow;\n}\n```\n\n[PostCSS Focus Within] duplicates rules using the `:focus-within` pseudo-class\nwith a `[focus-within]` attribute selector, the same selector used by the\n[focus-within polyfill]. This replacement selector can be changed using the\n`replaceWith` option. Also, the preservation of the original `:focus-within`\nrule can be disabled using the `preserve` option.\n\n## Usage\n\nAdd [PostCSS Focus Within] to your project:\n\n```bash\nnpm install postcss postcss-focus-within --save-dev\n```\n\nUse [PostCSS Focus Within] to process your CSS:\n\n```js\nconst postcssFocusWithin = require('postcss-focus-within');\n\npostcssFocusWithin.process(YOUR_CSS /*, processOptions, pluginOptions */);\n```\n\nOr use it as a [PostCSS] plugin:\n\n```js\nconst postcss = require('postcss');\nconst postcssFocusWithin = require('postcss-focus-within');\n\npostcss([\n  postcssFocusWithin(/* pluginOptions */)\n]).process(YOUR_CSS /*, processOptions */);\n```\n\n[PostCSS Focus Within] runs in all Node environments, with special\ninstructions for:\n\n| [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Create React App](INSTALL.md#create-react-app) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) |\n| --- | --- | --- | --- | --- | --- |\n\n## Options\n\n### preserve\n\nThe `preserve` option defines whether the original selector should remain. By\ndefault, the original selector is preserved.\n\n```js\nfocusWithin({ preserve: false });\n```\n\n```css\n.my-form-field:focus-within label {\n  background-color: yellow;\n}\n\n/* becomes */\n\n.my-form-field[focus-within] label {\n  background-color: yellow;\n}\n```\n\n### replaceWith\n\nThe `replaceWith` option defines the selector to replace `:focus-within`. By\ndefault, the replacement selector is `[focus-within]`.\n\n```js\nfocusWithin({ replaceWith: '.focus-within' });\n```\n\n```css\n.my-form-field:focus-within label {\n  background-color: yellow;\n}\n\n/* becomes */\n\n.my-form-field.focus-within label {\n  background-color: yellow;\n}\n\n.my-form-field:focus-within label {\n  background-color: yellow;\n}\n```\n\n[css-url]: https://cssdb.org/#focus-within-pseudo-class\n[cli-url]: https://github.com/csstools/postcss-focus-within/actions/workflows/test.yml?query=workflow/test\n[git-url]: https://gitter.im/postcss/postcss\n[npm-url]: https://www.npmjs.com/package/postcss-focus-within\n\n[focus-within polyfill]: https://github.com/jsxtools/focus-within\n[Gulp PostCSS]: https://github.com/postcss/gulp-postcss\n[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss\n[PostCSS]: https://github.com/postcss/postcss\n[PostCSS Focus Within]: https://github.com/csstools/postcss-focus-within\n[PostCSS Loader]: https://github.com/postcss/postcss-loader\n[Selectors Level 4 specification]: https://www.w3.org/TR/selectors-4/#the-focus-within-pseudo\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsstools%2Fpostcss-focus-within","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcsstools%2Fpostcss-focus-within","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsstools%2Fpostcss-focus-within/lists"}