百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
H

headwind

> 前端框架
开源

一个针对 Visual Studio Code 打造的具有主观观点的 Tailwind CSS 类别排序器

1.4K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

一个针对 Visual Studio Code 打造的具有主观观点的 Tailwind CSS 类别排序器

Headwind

Headwind is an opinionated Tailwind CSS class sorter for Visual Studio Code. It enforces consistent ordering of classes by parsing your code and reprinting class tags to follow a given order.

Headwind runs on save, will remove duplicate classes and can even sort entire workspaces.


Get it from the VS Code Marketplace →

Use PHPStorm? Get @WalrusSoup's Headwind port →

Usage

You can install Headwind via the VS Code Marketplace, or package it yourself using vsce. Headwind works globally once installed and will run on save if a tailwind.config.js file is present within your working directory.

You can also trigger Headwind by:

  • Pressing ALT + Shift + T on Mac
  • Pressing CTRL + ALT + T on Windows
  • Pressing CTRL + ALT + T on Linux

Headwind can sort individual files by running 'Sort Tailwind CSS Classes' via the Command Palette. Workspaces can also be sorted by running 'Sort Tailwind CSS Classes on Entire Workspace'.

Any breakpoints or unknown classes will be moved to the end of the class list, whilst duplicate classes will be removed.

Customisation

Headwind ships with a default class order (located in package.json). You can edit this (and other settings) to your liking on the extension settings page.

headwind.classRegex:

An object with language IDs as keys and their values determining the regex to search for Tailwind CSS classes. The default is located in package.json but this can be customized to suit your needs.

There can be multiple capturing groups, that should only contain a string with Tailwind CSS classes (without any apostrophies etc.). If a new group, which doesn't contain the class string, is created, ensure that it is non-capturing by using (?:).

Example from package.json:

"headwind.classRegex": {
    "html": "\\bclass\\s*=\\s*[\\\"\\']([_a-zA-Z0-9\\s\\-\\:\\/]+)[\\\"\\']",
    "javascriptreact": "(?:\\bclassName\\s*=\\s*[\\\"\\']([_a-zA-Z0-9\\s\\-\\:\\/]+)[\\\"\\'])|(?:\\btw\\s*`([_a-zA-Z0-9\\s\\-\\:\\/]*)`)"
}

Multi-step Regex

A multi-step regex can be specified by using an array of regexes to be executed in order.

Example from package.json:

"headwind.classRegex": {
    "javascript": [
        "(?:\\bclass(?:Name)?\\s*=\\s*(?:{([\\w\\d\\s_\\-:/${}()[\\]\"'`,]+)})|([\"'`][\\w\\d\\s_\\-:/]+[\"'`]))|(?:\\btw\\s*(`[\\w\\d\\s_\\-:/]+`))",
        "(?:[\"'`]([\\w\\d\\s_\\-:/${}()[\\]\"']+)[\"'`])"
    ],
}

The first regex will look for JSX class or className attributes or twin.macro usage.

The second regex will then look for class names to be sorted within these matches.

Configuration Object

Optionally a configuration object can be passed to specify additional options for sorting class names.

  • regex - specifies the regex to be used to find class names
  • separator - regex pattern that is used to separate class names (default: "\\s+")
  • replacement - string used to replace separator matches (default: " ")

Example from package.json:

"headwind.classRegex": {
    "jade": [
        {
            "regex": "\\.([\\._a-zA-Z0-9\\-]+)",
            "separator": "\\.",
            "replacement": "."
        },
        "\\bclass\\s*=\\s*[\\\"\\']([_a-zA-Z0-9\\s\\-\\:\\/]+)[\\\"\\']"
    ],
}

Debugging Custom Regex:

To debug custom classRegex, you can use the code below:

…

The result of valueMatch should be the class text exactly, with no other characters.

Good example value: valueMatch w-64 h-full bg-blue-400 relative

Note: Changes made to Headwind's JSON configuration options may not take effect immediately. When experimenting with custom classRegex, after each change you should open the control pallete (Ctrl/Cmd + Shift + P) and run Developer: Reload Window to ensure changes are applied.


headwind.defaultSortOrder:

An array that determines Headwind's default sort order.

headwind.removeDuplicates:

Headwind will remove duplicate class names by default. This can be toggled on or off.

"headwind.removeDuplicates": false

headwind.prependCustomClasses:

Headwind will append custom class names by default. They can be prepended instead.

"headwind.prependCustomClasses": true

headwind.runOnSave:

Headwind will run on save by default (if a tailwind.config.js file is present within your working directory). This can be toggled on or off.

"headwind.runOnSave": false

Contributing

Headwind is open-source and contributions are always welcome. If you're interested in submitting a pull request, please take a moment to review CONTRIBUTING.md.

Contributors

Code Contributors

This project exists thanks to all the people who contribute. [Contribute].

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute]

Individuals

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

GitHub Issues· 87 开放

在 GitHub 查看全部
  • #77

    Redo history is lost after saving and automatically reordering classes

    bug更新于 2026年1月8日
  • #213

    TailwindCSS v4

    更新于 2025年6月13日
  • #196

    Support for the class-variance-authority package

    更新于 2024年12月27日
  • #212

    Unable to use with Rails helpers

    更新于 2024年10月24日
  • #183

    Class sorting is not working when arbitrary value is used

    更新于 2024年7月8日
  • #203

    headwind and Solidjs class support?

    更新于 2024年6月3日
  • #211

    Unmaintained Repo Active Fork (sortwind)

    更新于 2024年5月29日
  • #78

    Support for slim templates

    enhancement更新于 2024年5月26日
  • #210

    headwind.prependCustomClasses not respected in "sort workspace" command

    更新于 2024年5月7日
  • #206

    Seemingly Unmaintained, I have forked this and updated it to work in much the same way as the prettier plugin.

    更新于 2023年12月31日

核心特点

  • •Pressing ALT + Shift + T on Mac
  • •Pressing CTRL + ALT + T on Windows
  • •Pressing CTRL + ALT + T on Linux
  • •regex - specifies the regex to be used to find class names
  • •separator - regex pattern that is used to separate class names (default: "\\s+")
  • •replacement - string used to replace separator matches (default: " ")

> 标签

TypeScriptcssformattersortertailwind-css

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架