source: frontend/node_modules/postcss-focus-within/README.md

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 3.9 KB
Line 
1# PostCSS Focus Within [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][postcss]
2
3[<img alt="npm version" src="https://img.shields.io/npm/v/postcss-focus-within.svg" height="20">][npm-url]
4[<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/focus-within-pseudo-class.svg" height="20">][css-url]
5[<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/tree/main/postcss-focus-within/workflows/test/badge.svg" height="20">][cli-url]
6[<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
7
8[PostCSS Focus Within] lets you use the `:focus-within` pseudo-class in CSS,
9following the [Selectors Level 4 specification].
10
11It is the companion to the [focus-within polyfill].
12
13[!['Can I use' table](https://caniuse.bitsofco.de/image/css-focus-within.png)](https://caniuse.com/#feat=css-focus-within)
14
15```css
16.my-form-field:focus-within label {
17 background-color: yellow;
18}
19
20/* becomes */
21
22.my-form-field[focus-within] label {
23 background-color: yellow;
24}
25
26.my-form-field:focus-within label {
27 background-color: yellow;
28}
29```
30
31[PostCSS Focus Within] duplicates rules using the `:focus-within` pseudo-class
32with a `[focus-within]` attribute selector, the same selector used by the
33[focus-within polyfill]. This replacement selector can be changed using the
34`replaceWith` option. Also, the preservation of the original `:focus-within`
35rule can be disabled using the `preserve` option.
36
37## Usage
38
39Add [PostCSS Focus Within] to your project:
40
41```bash
42npm install postcss postcss-focus-within --save-dev
43```
44
45Use [PostCSS Focus Within] to process your CSS:
46
47```js
48const postcssFocusWithin = require('postcss-focus-within');
49
50postcssFocusWithin.process(YOUR_CSS /*, processOptions, pluginOptions */);
51```
52
53Or use it as a [PostCSS] plugin:
54
55```js
56const postcss = require('postcss');
57const postcssFocusWithin = require('postcss-focus-within');
58
59postcss([
60 postcssFocusWithin(/* pluginOptions */)
61]).process(YOUR_CSS /*, processOptions */);
62```
63
64[PostCSS Focus Within] runs in all Node environments, with special
65instructions for:
66
67| [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) |
68| --- | --- | --- | --- | --- | --- |
69
70## Options
71
72### preserve
73
74The `preserve` option defines whether the original selector should remain. By
75default, the original selector is preserved.
76
77```js
78focusWithin({ preserve: false });
79```
80
81```css
82.my-form-field:focus-within label {
83 background-color: yellow;
84}
85
86/* becomes */
87
88.my-form-field[focus-within] label {
89 background-color: yellow;
90}
91```
92
93### replaceWith
94
95The `replaceWith` option defines the selector to replace `:focus-within`. By
96default, the replacement selector is `[focus-within]`.
97
98```js
99focusWithin({ replaceWith: '.focus-within' });
100```
101
102```css
103.my-form-field:focus-within label {
104 background-color: yellow;
105}
106
107/* becomes */
108
109.my-form-field.focus-within label {
110 background-color: yellow;
111}
112
113.my-form-field:focus-within label {
114 background-color: yellow;
115}
116```
117
118[css-url]: https://cssdb.org/#focus-within-pseudo-class
119[cli-url]: https://github.com/csstools/postcss-plugins/tree/main/postcss-focus-within/actions/workflows/test.yml?query=workflow/test
120[discord]: https://discord.gg/bUadyRwkJS
121[npm-url]: https://www.npmjs.com/package/postcss-focus-within
122
123[focus-within polyfill]: https://github.com/jsxtools/focus-within
124[Gulp PostCSS]: https://github.com/postcss/gulp-postcss
125[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
126[PostCSS]: https://github.com/postcss/postcss
127[PostCSS Focus Within]: https://github.com/csstools/postcss-plugins/tree/main/postcss-focus-within
128[PostCSS Loader]: https://github.com/postcss/postcss-loader
129[Selectors Level 4 specification]: https://www.w3.org/TR/selectors-4/#the-focus-within-pseudo
Note: See TracBrowser for help on using the repository browser.