Skip to content

Commit b888cab

Browse files
rozsazoltanjessarchertaylorotwell
authored
[12.x] Updating the Pulse Card TailwindCSS v3 configuration to TailwindCSS v4 (#10926)
* Updating the Pulse Card TailwindCSS v3 configuration to TailwindCSS v4 Instead of `@tailwind`, a single `@import` is used. But because of the previous "important strategy" (v3), a long import was required (with CSS selector - v4). The "important strategy" has been removed; only an appropriate CSS selector is needed. `@source` requires a fallback value (to ensure that the card view is included in the automatic source detection). * Added dark mode with `@custom-variant` instead of `darkMode: 'class'` * Disable preflight (`preflight: false`) * Update pulse.md Co-authored-by: Jess Archer <jess@jessarcher.com> * Update pulse.md Co-authored-by: Jess Archer <jess@jessarcher.com> * Update pulse.md Co-authored-by: Jess Archer <jess@jessarcher.com> * remove layers; disable automatic source detection Reference: * #10926 (comment) * formatting --------- Co-authored-by: Jess Archer <jess@jessarcher.com> Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent 396891b commit b888cab

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

pulse.md

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -650,31 +650,24 @@ When this card is included on the dashboard, Pulse will automatically include th
650650
<a name="custom-card-styling-tailwind"></a>
651651
#### Tailwind CSS
652652

653-
When using Tailwind CSS, you should create a dedicated Tailwind configuration file to avoid loading unnecessary CSS or conflicting with Pulse's Tailwind classes:
653+
When using Tailwind CSS, you should create a dedicated CSS entrypoint. The following example excludes Tailwind's [preflight](https://tailwindcss.com/docs/preflight) base styles which are already included by Pulse, and scopes Tailwind using a CSS selector to avoid conflicts with Pulse's Tailwind classes:
654654

655-
```js
656-
export default {
657-
darkMode: 'class',
658-
important: '#top-sellers',
659-
content: [
660-
'./resources/views/livewire/pulse/top-sellers.blade.php',
661-
],
662-
corePlugins: {
663-
preflight: false,
664-
},
665-
};
666-
```
655+
```css
656+
@import "tailwindcss/theme.css";
667657

668-
You may then specify the configuration file in your CSS entrypoint:
658+
@custom-variant dark (&:where(.dark, .dark *));
659+
@source "./../../views/livewire/pulse/top-sellers.blade.php";
669660

670-
```css
671-
@config "../../tailwind.top-sellers.config.js";
672-
@tailwind base;
673-
@tailwind components;
674-
@tailwind utilities;
661+
@theme {
662+
/* ... */
663+
}
664+
665+
#top-sellers {
666+
@import "tailwindcss/utilities.css" source(none);
667+
}
675668
```
676669

677-
You will also need to include an `id` or `class` attribute in your card's view that matches the selector passed to Tailwind's [important selector strategy](https://tailwindcss.com/docs/configuration#selector-strategy):
670+
You will also need to include an `id` or `class` attribute in your card's view that matches the CSS selector in your entrypoint:
678671

679672
```blade
680673
<x-pulse::card id="top-sellers" :cols="$cols" :rows="$rows" class="$class">

0 commit comments

Comments
 (0)