| 1 | # PostCSS Place Properties [<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-place.svg" height="20">][npm-url]
|
|---|
| 4 | [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/double-position-gradients.svg" height="20">][css-url]
|
|---|
| 5 | [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/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 Place Properties] lets you use `place-*` properties as shorthands for `align-*`
|
|---|
| 9 | and `justify-*`, following the [CSS Box Alignment] specification.
|
|---|
| 10 |
|
|---|
| 11 | ```pcss
|
|---|
| 12 | .example {
|
|---|
| 13 | place-self: center;
|
|---|
| 14 | place-content: space-between center;
|
|---|
| 15 | }
|
|---|
| 16 |
|
|---|
| 17 | /* becomes */
|
|---|
| 18 |
|
|---|
| 19 | .example {
|
|---|
| 20 | align-self: center;
|
|---|
| 21 | justify-self: center;
|
|---|
| 22 | place-self: center;
|
|---|
| 23 | align-content: space-between;
|
|---|
| 24 | justify-content: center;
|
|---|
| 25 | place-content: space-between center;
|
|---|
| 26 | }
|
|---|
| 27 | ```
|
|---|
| 28 |
|
|---|
| 29 | ## Usage
|
|---|
| 30 |
|
|---|
| 31 | Add [PostCSS Place Properties] to your project:
|
|---|
| 32 |
|
|---|
| 33 | ```bash
|
|---|
| 34 | npm install postcss postcss-place --save-dev
|
|---|
| 35 | ```
|
|---|
| 36 |
|
|---|
| 37 | Use it as a [PostCSS] plugin:
|
|---|
| 38 |
|
|---|
| 39 | ```js
|
|---|
| 40 | import postcss from 'postcss';
|
|---|
| 41 | import postcssPlace from 'postcss-place';
|
|---|
| 42 |
|
|---|
| 43 | postcss([
|
|---|
| 44 | postcssPlace(/* pluginOptions */)
|
|---|
| 45 | ]).process(YOUR_CSS /*, processOptions */);
|
|---|
| 46 | ```
|
|---|
| 47 |
|
|---|
| 48 | [PostCSS Place Properties] runs in all Node environments, with special instructions for:
|
|---|
| 49 |
|
|---|
| 50 | | [Node](INSTALL.md#node) | [Webpack](INSTALL.md#webpack) | [Create React App](INSTALL.md#create-react-app) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) |
|
|---|
| 51 | | --- | --- | --- | --- | --- |
|
|---|
| 52 |
|
|---|
| 53 | ## Options
|
|---|
| 54 |
|
|---|
| 55 | ### preserve
|
|---|
| 56 |
|
|---|
| 57 | The `preserve` option determines whether the original place declaration is
|
|---|
| 58 | preserved. By default, it is preserved.
|
|---|
| 59 |
|
|---|
| 60 | ```js
|
|---|
| 61 | postcssPlace({ preserve: false })
|
|---|
| 62 | ```
|
|---|
| 63 |
|
|---|
| 64 | ```pcss
|
|---|
| 65 | .example {
|
|---|
| 66 | place-self: center;
|
|---|
| 67 | place-content: space-between center;
|
|---|
| 68 | }
|
|---|
| 69 |
|
|---|
| 70 | /* becomes */
|
|---|
| 71 |
|
|---|
| 72 | .example {
|
|---|
| 73 | align-self: center;
|
|---|
| 74 | justify-self: center;
|
|---|
| 75 | align-content: space-between;
|
|---|
| 76 | justify-content: center;
|
|---|
| 77 | }
|
|---|
| 78 | ```
|
|---|
| 79 |
|
|---|
| 80 | [cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
|
|---|
| 81 | [css-url]: https://cssdb.org/#place-properties
|
|---|
| 82 | [discord]: https://discord.gg/bUadyRwkJS
|
|---|
| 83 | [npm-url]: https://www.npmjs.com/package/postcss-place
|
|---|
| 84 |
|
|---|
| 85 | [CSS Box Alignment]: https://www.w3.org/TR/css-align-3/#place-content
|
|---|
| 86 | [Gulp PostCSS]: https://github.com/postcss/gulp-postcss
|
|---|
| 87 | [Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
|
|---|
| 88 | [PostCSS]: https://github.com/postcss/postcss
|
|---|
| 89 | [PostCSS Loader]: https://github.com/postcss/postcss-loader
|
|---|
| 90 | [PostCSS Place Properties]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-place
|
|---|