# postcss-substitute-optional-required

> PostCSS plugin to shim the pseudo-selectors :required and :optional by using negation (:not) and therefore increase their browser support.

Latest version **1.0.1** (published 2016-05-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install postcss-substitute-optional-required
pnpm add postcss-substitute-optional-required
yarn add postcss-substitute-optional-required
bun add postcss-substitute-optional-required
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2016-05-20 |
| First published | 2016-05-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Matthias Müller |
| Maintainers | mattdimu |
| Keywords | postcss, css, postcss-plugin, required, optional, shim, fix, browser-support |

## Links

- npm: https://www.npmjs.com/package/postcss-substitute-optional-required
- Repository: https://github.com/mattdimu/postcss-substitute-optional-required
- Homepage: https://github.com/MattDiMu/postcss-substitute-optional-required
- Issues: https://github.com/MattDiMu/postcss-substitute-optional-required/issues
- npm.io page: https://npm.io/package/postcss-substitute-optional-required

## Dependencies (1)

- [postcss](https://npm.io/package/postcss.md) ^5.0.16

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2016-05-20

## README

# PostCSS Substitute Optional Required [![Build Status][ci-img]][ci] [![dependencies](https://david-dm.org/MattDiMu/postcss-substitute-optional-required.svg)] (https://david-dm.org/MattDiMu/postcss-substitute-optional-required) [![devDependencies](https://david-dm.org/MattDiMu/postcss-substitute-optional-required/dev-status.svg)](https://david-dm.org/MattDiMu/postcss-substitute-optional-required)

[PostCSS] plugin to shim the pseudo-selectors :required and :optional by using negation (:not) and therefore slightly increase their browser support.

[PostCSS]: https://github.com/postcss/postcss
[ci-img]:  https://travis-ci.org/MattDiMu/postcss-substitute-optional-required.svg
[ci]:      https://travis-ci.org/MattDiMu/postcss-substitute-optional-required

```css
/* input */
input:required::after {
    content: '*'
}
textarea:optional::after {
    content: '(optional)';
}

/* output */
input:not(:optional),
input:required::after {
    content: '*'
}

textarea:not(:required)::after,
textarea:optional::after {
    content: '(optional)';
}
```

```css
/* input, option { method: 'shim-required' } */
:required {
    color: hotpink;
}
:optional {
    color: indianred;
}
/* output, option { method: 'shim-required' } */
:not(:optional),
:required {
    color: hotpink;
}
:optional {
    color: indianred;
}
```

```css
/* input, option { method: 'shim-optional' } */
:required {
    color: hotpink;
}
:optional {
    color: indianred;
}
/* output, option { method: 'shim-optional' } */
:required {
    color: hotpink;
}
:not(:required),
:optional {
    color: indianred;
}
```

##Options
The only available option is `method`, with the possible values `shim-all` (default), `shim-optional` and `shim-required`:


## Usage
```js
postcss([ require('postcss-substitute-optional-required') ])
```
```js
postcss([ require('postcss-substitute-optional-required') ])({ method: 'shim-required' }) //shim only the :required selector
```
See [PostCSS] docs for examples for your environment.

---
_Source: https://npm.io/package/postcss-substitute-optional-required · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
