Socket
Socket
Sign inDemoInstall

postcss-focus-within

Package Overview
Dependencies
9
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    postcss-focus-within

[![NPM Version][npm-img]][npm-url] [![Build Status][cli-img]][cli-url] [![Windows Build Status][win-img]][win-url] [![Gitter Chat][git-img]][git-url]


Version published
Maintainers
1
Install size
1.50 MB
Created

Readme

Source

PostCSS Focus Within PostCSS Logo

NPM Version Build Status Windows Build Status Gitter Chat

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-dev
Node

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-dev

Use 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-dev

Use 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-dev

Use 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-dev

Use 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;
}

Keywords

FAQs

Last updated on 17 Feb 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc