| 1 | # PostCSS Gap Properties [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][postcss]
|
|---|
| 2 |
|
|---|
| 3 | [![NPM Version][npm-img]][npm-url]
|
|---|
| 4 | [![CSS Standard Status][css-img]][css-url]
|
|---|
| 5 | [![Build Status][cli-img]][cli-url]
|
|---|
| 6 | [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
|
|---|
| 7 |
|
|---|
| 8 | [PostCSS Gap Properties] lets you use the `gap`, `column-gap`, and `row-gap`
|
|---|
| 9 | shorthand properties in CSS, following the [CSS Grid Layout] specification.
|
|---|
| 10 |
|
|---|
| 11 | ```pcss
|
|---|
| 12 | .standard-grid {
|
|---|
| 13 | gap: 20px;
|
|---|
| 14 | }
|
|---|
| 15 |
|
|---|
| 16 | .spaced-grid {
|
|---|
| 17 | column-gap: 40px;
|
|---|
| 18 | row-gap: 20px;
|
|---|
| 19 | }
|
|---|
| 20 |
|
|---|
| 21 | /* becomes */
|
|---|
| 22 |
|
|---|
| 23 | .standard-grid {
|
|---|
| 24 | grid-gap: 20px;
|
|---|
| 25 | gap: 20px;
|
|---|
| 26 | }
|
|---|
| 27 |
|
|---|
| 28 | .spaced-grid {
|
|---|
| 29 | grid-column-gap: 40px;
|
|---|
| 30 | column-gap: 40px;
|
|---|
| 31 | grid-row-gap: 20px;
|
|---|
| 32 | row-gap: 20px;
|
|---|
| 33 | }
|
|---|
| 34 | ```
|
|---|
| 35 |
|
|---|
| 36 | ## Usage
|
|---|
| 37 |
|
|---|
| 38 | Add [PostCSS Gap Properties] to your project:
|
|---|
| 39 |
|
|---|
| 40 | ```bash
|
|---|
| 41 | npm install postcss postcss-gap-properties --save-dev
|
|---|
| 42 | ```
|
|---|
| 43 |
|
|---|
| 44 | Use [PostCSS Gap Properties] as a [PostCSS] plugin:
|
|---|
| 45 |
|
|---|
| 46 | ```js
|
|---|
| 47 | import postcss from 'postcss';
|
|---|
| 48 | import postcssGapProperties from 'postcss-gap-properties';
|
|---|
| 49 |
|
|---|
| 50 | postcss([
|
|---|
| 51 | postcssGapProperties(/* pluginOptions */)
|
|---|
| 52 | ]).process(YOUR_CSS /*, processOptions */);
|
|---|
| 53 | ```
|
|---|
| 54 |
|
|---|
| 55 | [PostCSS Gap Properties] runs in all Node environments, with special instructions for:
|
|---|
| 56 |
|
|---|
| 57 | | [Node](INSTALL.md#node) | [Webpack](INSTALL.md#webpack) | [Create React App](INSTALL.md#create-react-app) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) |
|
|---|
| 58 | | --- | --- | --- | --- | --- |
|
|---|
| 59 |
|
|---|
| 60 | ## Options
|
|---|
| 61 |
|
|---|
| 62 | ### preserve
|
|---|
| 63 |
|
|---|
| 64 | The `preserve` option determines whether the original `gap` declaration should
|
|---|
| 65 | remain in the CSS. By default, the original declaration is preserved.
|
|---|
| 66 |
|
|---|
| 67 | [css-img]: https://cssdb.org/images/badges/gap-properties.svg
|
|---|
| 68 | [css-url]: https://cssdb.org/#gap-properties
|
|---|
| 69 | [cli-img]: https://github.com/csstools/postcss-plugins/workflows/test/badge.svg
|
|---|
| 70 | [cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
|
|---|
| 71 | [discord]: https://discord.gg/bUadyRwkJS
|
|---|
| 72 | [npm-img]: https://img.shields.io/npm/v/postcss-gap-properties.svg
|
|---|
| 73 | [npm-url]: https://www.npmjs.com/package/postcss-gap-properties
|
|---|
| 74 |
|
|---|
| 75 | [CSS Grid Layout]: https://www.w3.org/TR/css-grid-1/#gutters
|
|---|
| 76 | [Gulp PostCSS]: https://github.com/postcss/gulp-postcss
|
|---|
| 77 | [Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
|
|---|
| 78 | [PostCSS]: https://github.com/postcss/postcss
|
|---|
| 79 | [PostCSS Loader]: https://github.com/postcss/postcss-loader
|
|---|
| 80 | [PostCSS Gap Properties]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-gap-properties
|
|---|