githubEdit

PostCSS Focus Within

NPM Versionarrow-up-right CSS Standard Statusarrow-up-right Build Statusarrow-up-right Gitter Chatarrow-up-right

PostCSS Focus Withinarrow-up-right lets you use the :focus-within pseudo-class in CSS, following the Selectors Level 4 specificationarrow-up-right.

It is the companion to the focus-within polyfillarrow-up-right.

.my-form-field:focus-within label {
  background-color: yellow;
}

/* becomes */

.my-form-field[focus-within] label {
  background-color: yellow;
}

.my-form-field:focus-within label {
  background-color: yellow;
}

PostCSS Focus Withinarrow-up-right duplicates rules using the :focus-within pseudo-class with a [focus-within] attribute selector, the same selector used by the focus-within polyfillarrow-up-right. This replacement selector can be changed using the replaceWith option. Also, the preservation of the original :focus-within rule can be disabled using the preserve option.

Usage

Add PostCSS Focus Withinarrow-up-right to your project:

Use PostCSS Focus Withinarrow-up-right to process your CSS:

Or use it as a PostCSSarrow-up-right plugin:

PostCSS Focus Withinarrow-up-right runs in all Node environments, with special instructions for:

Options

preserve

The preserve option defines whether the original selector should remain. By default, the original selector is preserved.

replaceWith

The replaceWith option defines the selector to replace :focus-within. By default, the replacement selector is [focus-within].

Last updated