@@ -127,59 +127,17 @@ export function MyApp({ children }: PropsWithChildren) {
127
127
}
128
128
```
129
129
130
- ## Component strategy example
131
-
132
- Sometimes you might want only specific components to be styled (nothing else) to put them together with some other UI library components (and to have them completely unaffected).
133
- In this case ` isolateForComponents ` strategy might be what you need.
134
-
135
- ``` javascript
136
- // tailwind.config.js
137
-
138
- import { scopedPreflightStyles , isolateForComponents } from ' tailwindcss-scoped-preflight' ;
139
-
140
- /** @type {import("tailwindcss").Config} */
141
- const config = {
142
- // ...
143
- plugins: [
144
- // ...
145
- scopedPreflightStyles ({
146
- isolationStrategy: isolateForComponents (' .comp' ),
147
- }),
148
- ],
149
- };
150
-
151
- exports .default = config;
152
- ```
153
-
154
- ``` tsx
155
- // MyTailwindButton.tsx
156
-
157
- import { type PropsWithChildren } from ' react' ;
158
-
159
- export function MyTailwindButton({ children }: PropsWithChildren ): ReactElement {
160
- return (
161
- <button className = { ' comp' } >
162
- { /* this button won't have a default border and background
163
- because of Tailwind CSS preflight styles applied to the elements
164
- with the .comp class immediately (as per the configuration).
165
- All the other buttons around will have their original/default styles */ }
166
- { children }
167
- </button >
168
- );
169
- }
170
- ```
171
-
172
130
# Configuration examples
173
131
174
132
### Using the strategy for multiple selectors
175
133
176
134
``` diff
177
135
scopedPreflightStyles({
178
- isolationStrategy: isolateForComponents (
179
- - '.comp ',
136
+ isolationStrategy: isolateInsideOfContainer (
137
+ - '.twp ',
180
138
+ [
181
- + '.comp',
182
139
+ '.twp',
140
+ + '[twp]',
183
141
+ ],
184
142
),
185
143
})
@@ -191,8 +149,8 @@ scopedPreflightStyles({
191
149
192
150
``` diff
193
151
scopedPreflightStyles({
194
- isolationStrategy: isolateForComponents (
195
- '.comp ',
152
+ isolationStrategy: isolateInsideOfContainer (
153
+ '.twp ',
196
154
// every strategy provides some base options to fine tune the transformation
197
155
+ {
198
156
+ ignore: ["html", ":host", "*"],
@@ -205,8 +163,8 @@ scopedPreflightStyles({
205
163
206
164
``` diff
207
165
scopedPreflightStyles({
208
- isolationStrategy: isolateForComponents (
209
- '.comp ',
166
+ isolationStrategy: isolateInsideOfContainer (
167
+ '.twp ',
210
168
+ {
211
169
+ remove: ["body", ":before", ":after"],
212
170
+ },
@@ -256,8 +214,8 @@ const config = {
256
214
// Caution! Don't forget to return the value,
257
215
// falsy/nullish result will remove the rule.
258
216
// Either return the original ruleSelector, or inject some of existing strategies,
259
- // let's fallback to the isolateForComponents strategy for this demo:
260
- return isolateForComponents (' .twp' )({ ruleSelector, ... whateverElse });
217
+ // let's fallback to the isolateInsideOfContainer strategy for this demo:
218
+ return isolateInsideOfContainer (' .twp' )({ ruleSelector, ... whateverElse });
261
219
},
262
220
}),
263
221
],
@@ -277,7 +235,7 @@ You may configure the modifications in a declarative manner (as an object) or pr
277
235
278
236
``` javascript
279
237
scopedPreflightStyles ({
280
- isolationStrategy: isolateForComponents (' .comp ' ), // whatever
238
+ isolationStrategy: isolateInsideOfContainer (' .twp ' ), // whatever
281
239
modifyPreflightStyles: {
282
240
html: {
283
241
// removes the line-height for the html selector
@@ -299,7 +257,7 @@ scopedPreflightStyles({
299
257
300
258
``` javascript
301
259
scopedPreflightStyles ({
302
- isolationStrategy: isolateForComponents (' .comp ' ), // whatever
260
+ isolationStrategy: isolateInsideOfContainer (' .twp ' ), // whatever
303
261
modifyPreflightStyles : ({ selectorSet, property, value }) => {
304
262
// let's say you want to override the font family (no matter what the rule selector is)
305
263
if (property === ' font-family' && value !== ' inherit' ) {
@@ -341,8 +299,6 @@ import {
341
299
}),
342
300
```
343
301
344
- Is some cases you may have to pick the isolateForComponents strategy - try which works best for you.
345
-
346
302
#### for 'except matched' mode users
347
303
348
304
``` diff
0 commit comments