Skip to content

Conversation

tesar-tech
Copy link
Contributor

Description

Closes #5951

Upgrade to the newest versions of Flowbite and Tailwind.

The Flowbite update now uses v4 of Tailwind. The update was primarily about changing the versions of the JavaScript and CSS files. Everything should be working fine, and I haven’t noticed any issues so far.

Tailwind now has a cleaner way of being included. We no longer distinguish between testing and production—there is now a single blazorise.tailwind.min.css file that should be used in both cases. However, for testing purposes, it is still possible to use the Tailwind CDN.

Files used exclusively for the build process are now placed in a separate folder to distinguish them from user-facing CSS (in wwwroot).

Users can still customize Blazorise's Tailwind-related styles to keep their CSS as small as possible. This should also be mentioned in the integration guide.

Safe classes are now stored in a .txt file, as Tailwind v4 scans everything by default. There are many invalid Tailwind classes that need correction, such as:

  • !lg:b-5 and similar isn't even valid.
  • b-accordion and other b- prefixed classes will be included via the import of blazorise.tailwind.css.

I think the safelist and resulting CSS is unnecessary large. We need the safelist just for the "computed" classes, like:

public override string TextEditColor( Color color ) => color?.Name?.Length > 0 ? $"text-{ToColor( color )}" : null;

the rest is taken from scanning through the TailwindClassProvider.cs. I am not sure how the safe list generation was approached before.

The Tailwind demo now uses the production solution (no cdn)

There is a possibility to merge blazorise.tailwind.min.css with Flowbite’s CSS to save some kilobytes. Currently:

  • Flowbite: 192 KB
  • Blazorise: 132 KB
  • Merging could potentially reduce the total size to around 250 KB, but this needs further consideration.

To-Dos:

  • Update integration guides for Tailwind.
  • Check for outdated classes in the class provider.
  • Possibly update the blog post about Tailwind.
  • Purge the safelist.
  • Decide whether to merge CSS with Flowbite.
  • Document the build process (it's simple but should be mentioned somewhere).

@tesar-tech tesar-tech requested a review from stsrki March 10, 2025 18:24
@tesar-tech tesar-tech marked this pull request as draft March 10, 2025 18:25
Copy link
Collaborator

@stsrki stsrki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to document any migration notes. This should be done in 2025-01-15_MigrationTo2 blog post.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All files in tailwind-build must be in wwwroot. Otherwise, they will not end in the NuGet package and will not be able to be consumed by the users. I have just tested this by publishing NuGet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly, that's on purpose. users need just the one in wwwroot

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And how would they customize tailwind based on our settings?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before. They basically need to replicate our tw build process - with our safelist and input css files + with theirs own rules.
Having the safelist and base css inside nuget package doesn't really help, as these files are usually available through the _content only during runtime.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

God, this is a nightmare to work with. I cannot make TW CLI to work at all. Been trying it all morning.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's wrong? There is a simple Readme file in tailwind build folder

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something about broswer caniuse.. I've moved to other tasks now. Will try again later.

@stsrki
Copy link
Collaborator

stsrki commented Mar 11, 2025

Something happened with modal opacity

image

@stsrki
Copy link
Collaborator

stsrki commented Mar 11, 2025

It seems the class on backdrop should be

bg-gray-900/50

instead of

bg-gray-900 bg-opacity-50

@tesar-tech tesar-tech marked this pull request as ready for review March 13, 2025 12:45
@stsrki stsrki changed the title Flowbite and tailwind to the latest versions [2.0] Flowbite and tailwind to the latest versions May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants