Package Exports
- postcss-focus-within
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (postcss-focus-within) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
PostCSS Focus Within 
PostCSS Focus Within lets you use the :focus-within pseudo-selector in
CSS, following the [Selectors Level 4 specification].
.my-form-field:focus-within label {
background-color: yellow;
}
/* becomes */
.my-form-field[focus-within] label {
background-color: yellow;
}PostCSS Focus Within replaces the :focus-within pseudo-selector with a
.focus-within class selector, the same selector used by the
focus-within polyfill. The replacement selector can be changed using the
replaceWith option.
Usage
Add PostCSS Focus Within to your build tool:
npm install postcss-focus-within --save-devNode
Use PostCSS Focus Within to process your CSS:
import focusWithin from 'postcss-focus-within';
focusWithin.process(YOUR_CSS);PostCSS
Add PostCSS to your build tool:
npm install postcss --save-devUse PostCSS Focus Within as a plugin:
import postcss from 'gulp-postcss';
import focusWithin from 'postcss-focus-within';
postcss([
focusWithin()
]).process(YOUR_CSS);Webpack
Add PostCSS Loader to your build tool:
npm install postcss-loader --save-devUse PostCSS Focus Within in your Gulpfile:
import focusWithin from 'postcss-focus-within';
module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: [
'style-loader',
{ loader: 'css-loader', options: { importLoaders: 1 } },
{ loader: 'postcss-loader', options: {
ident: 'postcss',
plugins: () => [ focusWithin() ]
} }
]
}
]
}
}Gulp
Add Gulp PostCSS to your build tool:
npm install gulp-postcss --save-devUse PostCSS Focus Within in your Gulpfile:
import postcss from 'gulp-postcss';
import focusWithin from 'postcss-focus-within';
gulp.task('css', () => gulp.src('./src/*.css').pipe(
postcss([
focusWithin()
])
).pipe(
gulp.dest('.')
));Grunt
Add Grunt PostCSS to your build tool:
npm install grunt-postcss --save-devUse PostCSS Focus Within in your Gruntfile:
import focusWithin from 'postcss-focus-within';
grunt.loadNpmTasks('grunt-postcss');
grunt.initConfig({
postcss: {
options: {
use: [
focusWithin()
]
},
dist: {
src: '*.css'
}
}
});Options
replaceWith
The replaceWith option defines the selector to replace :focus-within. By
default, the replacement selector is [focus-within].
focusWithin({ replaceWith: '.focus-within' });:focus:not(:focus-within) {
outline: none;
}
/* becomes */
:focus:not(.focus-within]) {
outline: none;
}