You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -95,6 +99,7 @@ import phosphorIcons from "phosphor-icons-tailwindcss";
95
99
exportdefault {
96
100
plugins: [phosphorIcons({
97
101
prefix:'ph', // for the icon classes
102
+
layer:'icons', // for the CSS layer
98
103
customProperty:'--ph-url',
99
104
})],
100
105
};
@@ -106,6 +111,7 @@ Similarly, for Tailwind 4:
106
111
@import'tailwindcss';
107
112
@plugin 'phosphor-icons-tailwindcss' {
108
113
prefix: ph;
114
+
layer: icons;
109
115
custom-property: --ph-url; /* use the kebab-case alias to avoid auto-format by stylelint / prettier */
110
116
}
111
117
```
@@ -114,6 +120,36 @@ Similarly, for Tailwind 4:
114
120
115
121
You may notice this library utilizes Tailwind's support for [arbitrary value](https://tailwindcss.com/docs/adding-custom-styles#using-arbitrary-values), i.e `ph-[info]` instead of `ph-info` to map to the regular info icon. This is to avoid unnecessary parsing during development, especially for [Taliwind language server](https://github.com/tailwindlabs/tailwindcss-intellisense). Arbitrary value syntax allows parsing ad-hoc only the icons actually being used. Otherwise, parsing 9000+ icons may cause slow-down that negatively impacts developer experience.
116
122
123
+
## CSS layer
124
+
125
+
By default, the plugin generates CSS in the `icons`[layer](https://developer.mozilla.org/en-US/docs/Web/CSS/@layer). This is to ensure the generated CSS is
126
+
isolated and can be easily overridden by other utility classes, or extended upon. You can change the
127
+
layer by specifying `layer` option in the config object, as discussed in [Configuration](#configuration),
128
+
or passing `null` to skip any layering.
129
+
130
+
### Tailwind 4
131
+
132
+
Sorting works differently in Tailwind 4, so the generated CSS is nested inside `@layer utilities`, that is:
133
+
134
+
```css
135
+
@layer utilities {
136
+
@layer icons.base {
137
+
.ph {
138
+
/* truncated base rule */
139
+
}
140
+
}
141
+
@layer icons {
142
+
.ph-[info] {
143
+
/* truncated specifier rule */
144
+
}
145
+
}
146
+
}
147
+
```
148
+
149
+
> [!NOTE]
150
+
> Notice the base rule is inside a sub-layer: this is to ensure specifier classes always have higher
151
+
> specificity, no matter if they are declare before or after the base rule in your CSS source.
152
+
117
153
## Usage with Tailwind `@apply` directive
118
154
119
155
You may utilize `@apply` to extend your use case beyond just for icons. This is helpful if you want
0 commit comments