| 1 | # PostCSS Text Decoration Shorthand [<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/@csstools/postcss-text-decoration-shorthand.svg" height="20">][npm-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/text-decoration-shorthand.svg" height="20">][css-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
|
|---|
| 4 |
|
|---|
| 5 | [PostCSS Text Decoration Shorthand] lets you use `text-decoration` as a shorthand following the [Text Decoration Specification].
|
|---|
| 6 |
|
|---|
| 7 | ```pcss
|
|---|
| 8 | .example {
|
|---|
| 9 | text-decoration: wavy underline purple 25%;
|
|---|
| 10 | }
|
|---|
| 11 |
|
|---|
| 12 | /* becomes */
|
|---|
| 13 |
|
|---|
| 14 | .example {
|
|---|
| 15 | text-decoration: underline;
|
|---|
| 16 | text-decoration: underline wavy purple;
|
|---|
| 17 | text-decoration-thickness: calc(0.01em * 25);
|
|---|
| 18 | }
|
|---|
| 19 | ```
|
|---|
| 20 |
|
|---|
| 21 | ## Usage
|
|---|
| 22 |
|
|---|
| 23 | Add [PostCSS Text Decoration Shorthand] to your project:
|
|---|
| 24 |
|
|---|
| 25 | ```bash
|
|---|
| 26 | npm install postcss @csstools/postcss-text-decoration-shorthand --save-dev
|
|---|
| 27 | ```
|
|---|
| 28 |
|
|---|
| 29 | Use it as a [PostCSS] plugin:
|
|---|
| 30 |
|
|---|
| 31 | ```js
|
|---|
| 32 | const postcss = require('postcss');
|
|---|
| 33 | const postcssTextDecorationShorthand = require('@csstools/postcss-text-decoration-shorthand');
|
|---|
| 34 |
|
|---|
| 35 | postcss([
|
|---|
| 36 | postcssTextDecorationShorthand(/* pluginOptions */)
|
|---|
| 37 | ]).process(YOUR_CSS /*, processOptions */);
|
|---|
| 38 | ```
|
|---|
| 39 |
|
|---|
| 40 | [PostCSS Text Decoration Shorthand] runs in all Node environments, with special
|
|---|
| 41 | instructions for:
|
|---|
| 42 |
|
|---|
| 43 | | [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Create React App](INSTALL.md#create-react-app) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) |
|
|---|
| 44 | | --- | --- | --- | --- | --- | --- |
|
|---|
| 45 |
|
|---|
| 46 | ## Options
|
|---|
| 47 |
|
|---|
| 48 | ### preserve
|
|---|
| 49 |
|
|---|
| 50 | The `preserve` option determines whether the original notation
|
|---|
| 51 | is preserved. By default, it is not preserved.
|
|---|
| 52 |
|
|---|
| 53 | ```js
|
|---|
| 54 | postcssTextDecorationShorthand({ preserve: true })
|
|---|
| 55 | ```
|
|---|
| 56 |
|
|---|
| 57 | ```pcss
|
|---|
| 58 | .example {
|
|---|
| 59 | text-decoration: wavy underline purple 25%;
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | /* becomes */
|
|---|
| 63 |
|
|---|
| 64 | .example {
|
|---|
| 65 | text-decoration: underline;
|
|---|
| 66 | text-decoration: underline wavy purple;
|
|---|
| 67 | text-decoration-thickness: calc(0.01em * 25);
|
|---|
| 68 | text-decoration: wavy underline purple 25%;
|
|---|
| 69 | }
|
|---|
| 70 | ```
|
|---|
| 71 |
|
|---|
| 72 | [cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
|
|---|
| 73 | [css-url]: https://cssdb.org/#text-decoration-shorthand
|
|---|
| 74 | [discord]: https://discord.gg/bUadyRwkJS
|
|---|
| 75 | [npm-url]: https://www.npmjs.com/package/@csstools/postcss-text-decoration-shorthand
|
|---|
| 76 |
|
|---|
| 77 | [Gulp PostCSS]: https://github.com/postcss/gulp-postcss
|
|---|
| 78 | [Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
|
|---|
| 79 | [PostCSS]: https://github.com/postcss/postcss
|
|---|
| 80 | [PostCSS Loader]: https://github.com/postcss/postcss-loader
|
|---|
| 81 | [PostCSS Text Decoration Shorthand]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-text-decoration-shorthand
|
|---|
| 82 | [Text Decoration Specification]: https://drafts.csswg.org/css-text-decor-4/#text-decoration-property
|
|---|