66 * class prefixes (e.g., "mx-auto") and documentation titles (e.g., "Margin").
77 */
88
9- /** Regex to detect Tailwind class names: hyphenated lowercase tokens like text-lg, grid-cols-3 */
10- const TAILWIND_CLASS_RE = / \b [ a - z ] + (?: - [ a - z 0 - 9 ] + ) + \b / g;
9+ /** Regex to detect Tailwind class names: hyphenated lowercase tokens like text-lg, grid-cols-3, -mx-4 */
10+ const TAILWIND_CLASS_RE = / \b - ? [ a - z ] + (?: - [ a - z 0 - 9 ] + ) + \b / g;
1111
1212/** Font size suffixes used by Tailwind's text-{size} utilities */
1313const TEXT_SIZE_RE = / ^ t e x t - ( x s | s m | b a s e | l g | x l | \d + x l ) $ / ;
@@ -27,9 +27,15 @@ const PREFIX_MAP = new Map<string, string>([
2727 [ "auto-cols" , "grid auto columns" ] ,
2828 [ "auto-rows" , "grid auto rows" ] ,
2929 [ "col-span" , "grid column" ] ,
30+ [ "col-start" , "grid column" ] ,
31+ [ "col-end" , "grid column" ] ,
3032 [ "row-span" , "grid row" ] ,
33+ [ "row-start" , "grid row" ] ,
34+ [ "row-end" , "grid row" ] ,
3135 [ "space-x" , "space between horizontal" ] ,
3236 [ "space-y" , "space between vertical" ] ,
37+ [ "gap-x" , "gap horizontal" ] ,
38+ [ "gap-y" , "gap vertical" ] ,
3339 [ "min-w" , "min-width" ] ,
3440 [ "max-w" , "max-width" ] ,
3541 [ "min-h" , "min-height" ] ,
@@ -39,6 +45,8 @@ const PREFIX_MAP = new Map<string, string>([
3945 [ "snap-start" , "scroll snap align" ] ,
4046 [ "snap-end" , "scroll snap align" ] ,
4147 [ "snap-center" , "scroll snap align" ] ,
48+ [ "line-clamp" , "line clamp" ] ,
49+ [ "will-change" , "will-change" ] ,
4250
4351 // ── Single-segment prefixes ────────────────────────────────────
4452 // Spacing
@@ -63,8 +71,11 @@ const PREFIX_MAP = new Map<string, string>([
6371 [ "font" , "font" ] ,
6472 [ "tracking" , "letter spacing" ] ,
6573 [ "leading" , "line height" ] ,
74+ [ "decoration" , "text decoration" ] ,
75+ [ "whitespace" , "whitespace" ] ,
6676
6777 // Flex & Grid
78+ [ "flex" , "flex" ] ,
6879 [ "gap" , "gap" ] ,
6980 [ "justify" , "justify content" ] ,
7081 [ "items" , "align items" ] ,
@@ -107,6 +118,13 @@ const PREFIX_MAP = new Map<string, string>([
107118 [ "clear" , "clear" ] ,
108119 [ "object" , "object fit" ] ,
109120 [ "overflow" , "overflow" ] ,
121+ [ "break" , "word break" ] ,
122+
123+ // Position
124+ [ "top" , "position" ] ,
125+ [ "right" , "position" ] ,
126+ [ "bottom" , "position" ] ,
127+ [ "left" , "position" ] ,
110128
111129 // Transforms
112130 [ "scale" , "scale transform" ] ,
@@ -135,9 +153,15 @@ const PREFIX_MAP = new Map<string, string>([
135153 [ "accent" , "accent color" ] ,
136154 [ "caret" , "caret color" ] ,
137155
138- // Position
156+ // Position (z-index, inset)
139157 [ "z" , "z-index" ] ,
140158 [ "inset" , "position" ] ,
159+
160+ // Animation
161+ [ "animate" , "animation" ] ,
162+
163+ // Accessibility
164+ [ "sr" , "screen reader" ] ,
141165] ) ;
142166
143167/** text- variants that map to text-align */
@@ -224,7 +248,9 @@ export function expandQuery(query: string): string {
224248 const expansionTerms : string [ ] = [ ] ;
225249
226250 for ( const className of classNames ) {
227- const terms = resolveExpansion ( className ) ;
251+ // Strip leading `-` from negative utilities (e.g., -mx-4 → mx-4)
252+ const normalized = className . startsWith ( "-" ) ? className . slice ( 1 ) : className ;
253+ const terms = resolveExpansion ( normalized ) ;
228254 if ( ! terms ) continue ;
229255
230256 for ( const term of terms . split ( / \s + / ) ) {
0 commit comments