Skip to content

Commit e7910d8

Browse files
committed
fix: isolateForComponents cases removed from the docs
1 parent 88bda8a commit e7910d8

File tree

1 file changed

+11
-55
lines changed

1 file changed

+11
-55
lines changed

README.md

+11-55
Original file line numberDiff line numberDiff line change
@@ -127,59 +127,17 @@ export function MyApp({ children }: PropsWithChildren) {
127127
}
128128
```
129129

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-
172130
# Configuration examples
173131

174132
### Using the strategy for multiple selectors
175133

176134
```diff
177135
scopedPreflightStyles({
178-
isolationStrategy: isolateForComponents(
179-
- '.comp',
136+
isolationStrategy: isolateInsideOfContainer(
137+
- '.twp',
180138
+ [
181-
+ '.comp',
182139
+ '.twp',
140+
+ '[twp]',
183141
+ ],
184142
),
185143
})
@@ -191,8 +149,8 @@ scopedPreflightStyles({
191149

192150
```diff
193151
scopedPreflightStyles({
194-
isolationStrategy: isolateForComponents(
195-
'.comp',
152+
isolationStrategy: isolateInsideOfContainer(
153+
'.twp',
196154
// every strategy provides some base options to fine tune the transformation
197155
+ {
198156
+ ignore: ["html", ":host", "*"],
@@ -205,8 +163,8 @@ scopedPreflightStyles({
205163

206164
```diff
207165
scopedPreflightStyles({
208-
isolationStrategy: isolateForComponents(
209-
'.comp',
166+
isolationStrategy: isolateInsideOfContainer(
167+
'.twp',
210168
+ {
211169
+ remove: ["body", ":before", ":after"],
212170
+ },
@@ -256,8 +214,8 @@ const config = {
256214
// Caution! Don't forget to return the value,
257215
// falsy/nullish result will remove the rule.
258216
// 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 });
261219
},
262220
}),
263221
],
@@ -277,7 +235,7 @@ You may configure the modifications in a declarative manner (as an object) or pr
277235

278236
```javascript
279237
scopedPreflightStyles({
280-
isolationStrategy: isolateForComponents('.comp'), // whatever
238+
isolationStrategy: isolateInsideOfContainer('.twp'), // whatever
281239
modifyPreflightStyles: {
282240
html: {
283241
// removes the line-height for the html selector
@@ -299,7 +257,7 @@ scopedPreflightStyles({
299257

300258
```javascript
301259
scopedPreflightStyles({
302-
isolationStrategy: isolateForComponents('.comp'), // whatever
260+
isolationStrategy: isolateInsideOfContainer('.twp'), // whatever
303261
modifyPreflightStyles: ({ selectorSet, property, value }) => {
304262
// let's say you want to override the font family (no matter what the rule selector is)
305263
if (property === 'font-family' && value !== 'inherit') {
@@ -341,8 +299,6 @@ import {
341299
}),
342300
```
343301

344-
Is some cases you may have to pick the isolateForComponents strategy - try which works best for you.
345-
346302
#### for 'except matched' mode users
347303

348304
```diff

0 commit comments

Comments
 (0)