Sort Tailwind and Twin classes based on recommended class order of Tailwind using Prettier.
Installations
npm install prettier-plugin-twin.macro
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
12.22.12
NPM Version
6.14.16
Score
73
Supply Chain
90.3
Quality
75.5
Maintenance
100
Vulnerability
99.6
License
Releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (73.53%)
JavaScript (26.47%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
mohammadsiyou
Download Statistics
Total Downloads
35,154
Last Day
42
Last Week
325
Last Month
1,131
Last Year
16,711
GitHub Statistics
11 Stars
59 Commits
1 Forks
3 Watchers
3 Branches
2 Contributors
Updated on Nov 05, 2023
Bundle Size
1.02 MB
Minified
265.27 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.0.14
Package Id
prettier-plugin-twin.macro@1.0.14
Unpacked Size
1.06 MB
Size
289.59 kB
File Count
5
NPM Version
6.14.16
Node Version
12.22.12
Published on
Jun 04, 2023
Total Downloads
Cumulative downloads
Total Downloads
35,154
Last Day
31.3%
42
Compared to previous day
Last Week
46.4%
325
Compared to previous week
Last Month
-2.3%
1,131
Compared to previous month
Last Year
20.4%
16,711
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Prettier for twin.macro
Sort your Tailwind and twin.macro classes based on recommended class order of Tailwind using Prettier.
Features
- Format inline Tailwind CSS classes
- Format twin.macro template literals inside all style-components
- Support JavaScript, Flow, Typescript and JSX
- Ascend parent directories from current directory to find tailwind.config.js
- Groupify classes with bracket group
- Add !important to bracket groups
How to install
Install prettier-plugin-twin.macro
as a dev-dependency:
1npm i --save-dev prettier-plugin-twin.macro prettier
or
1yarn add -D prettier-plugin-twin.macro prettier
How to use
Create a prettier.config.js file in the root directory and add the plugin.
1module.exports = { 2 plugins: [require("prettier-plugin-twin.macro")], 3};
Then format your code using Prettier CLI.
prettier --write ./src/index.js
Examples
Short CSS and arbitrary classes should have their position preserved
1<div tw="display[block] inline inline1 [display:block]" /> 2// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ 3<div tw="inline1 inline display[block] [display:block]" />
Groupify classes based on their variant with bracket group
1<div tw="sm:bg-red-100 sm:[display:inline] sm:hover:w-10 sm:hover:mt-4 sm:hover:before:p-4" /> 2// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ 3<div tw="sm:(bg-red-100 [display:inline] hover:(mt-4 w-10 before:p-4))" />
Add !important sign to bracket groups
1<div tw="!display[block] !inline" /> 2// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ 3<div tw="(inline display[block])!" />

No vulnerabilities found.

No security vulnerabilities found.