Skeleton v3 + Tailwind v4 - RC2 Migration Guide #3242
endigo9740
started this conversation in
General
Replies: 1 comment 1 reply
-
I migrated using this guide, thanks! One minor typo in the CSS Class Name Changes section, I think:
Based on the docs here: https://next.skeleton.dev/docs/tailwind/forms/#groups |
Beta Was this translation helpful? Give feedback.
1 reply
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
-
This guide covers the instruction for existing Skeleton v3 users to migrate to the latest release that supports Tailwind v4. This will require a manual migration to fully support the new configuration and feature changes.
As such, we'll utilize the following semantics to refer to the different versions of Skeleton v3:
Prerequisites
Create a Migration Branch
We recommend using standard Git workflows to handle all migration changes on a dedicated feature branch. This ensures you can easily drop or revert changes if something goes wrong.
git checkout -b migration
Migrate to Tailwind v4
Please follow the official Tailwind documentation for migrating to Tailwind v4. This includes using their dedicated migration CLI to automate much of the process.
However, before migrating to tailwind V4 there are some manual steps required:
skeleton
plugin from yourtailwind.config
file.app.postcss
orapp.pcss
toapp.css
.purgecss
(vite-plugin-tailwind-purgecss
) vite plugin from yourvite.config
(if installed).After doing these steps you can follow the Tailwind v4 Migration Guide
The most notable change comes from moving from Tailwind configuration in
tailwind.config
to the new CSS-based configuration in your app's global stylesheet. We recommend backing up yourtailwind.config
as reference for the upcoming steps.Migrate to the Tailwind Vite Plugin
In the past, Tailwind was provided via a PostCSS plugin. In Tailwind v4, there is now a first-class Vite plugin. We recommend this for all supported projects, including: SvelteKit, Vite/Svelte, Vite/React, and Astro.
Using the following steps to migrate to from PostCSS to the Vite plugin:
postcss.config.mjs
npm uninstall postcss @tailwindcss/postcss
npm install @tailwindcss/vite
astro.config
vite.config
import tailwindcss from '@tailwindcss/vite'
Migrate to Skeleton v3 RC2
Ensure both your core and component packages are updated for Skeleton.
For React Users:
For Svelte Users:
For most other frameworks:
Run
npm list
(or similar for other package managers) to list the installed dependencies. Each package should meet or exceed the following versions:Migrate Tailwind Configuration
The most critical step is to ensure your app replaces the configuration lost when
tailwind.config
was removed. Open your app's global stylesheet and ensure the following is appended at the top of the file:You may need to adjust these settings to your preference:
@plugin
line above.@source
path to resolve to yournode_modules
and set the proper component name:react
orsvelte
cerberus
please change that now.@custom-variant
line.@custom-variant
line.If you had additional custom configuration in your
tailwind.config
that is not represented above, you'll need to consult the Tailwind v4 documentation and implement directly. This includes additional plugins, expanded theme or utility classes, etc. This is beyond the scope of Skeleton and this migration guide though.CSS Class Name Changes
As part of updates to support the new and improved features in Tailwind v4, we've renamed and replaced a number of classes.
Mesh Gradients
If you're using CSS mesh gradient, you'll need to modify the syntax slightly to utilize the new color and transparency values.
Removing @apply
While this step is optional, we strongly encourage you take this opportunity to move away from any usage of
@apply
. Tailwind has long since advocated against this, and Tailwind v4 introduces new directives and functions that make this much easier to avoid. Here's a trivial example:<style>
blocks.Move the Date Theme Attribute
The
data-theme
attribute which indicates your custom theme has moved from the<body>
to the<html>
tag. If you're using a theme other thancerberus
then please change this accordingly.Migrating Custom Themes
This step is only required if you implemented one or more custom themes in your application.
Tap here to expand and view the Custom Theme migration.
Tailwind v4 now provides first-class support for themes. In RC2, all Skeleton themes have been converted from a Javascript-based format that was previously fed into the Skeleton Tailwind plugin in
tailwind.config
, to a pure CSS-based file that you simply import in your global stylesheet.You have two options for migrating your custom theme:
Convert the File Format
Rename the theme file from
.ts|.js
to.css
.Convert to the CSS Boilerplate
Remove all Javascript boilerplate surrounding the list of theme properties.
Update Theme Properties
Theme properties were previously stored in a Javascript object format, which included extra quotes and commas we no longer need. Edit each line to ensure they contain valid CSS custom property definitions:
Remove These Properties
Skeleton RC2 no long requires the following properties. These should be removed from your theme:
--type-scale-[1-13]
- Type Scale feature which is now implemented intotext-*
classes.--outline-width-default
- this is no longer controlled by the theme to avoid accessibility issues.Rename These Properties
Likewise RC2 has renamed a few properties to ensure consistency with Tailwind v4's namespace conventions:
--space-scale-factor
--spacing
--type-scale-factor
--text-scaling
--radii-default
--radius-base
--radii-container
--radius-container
--border-width-default
--default-border-width
--divide-width-default
--default-divide-width
--ring-width-default
--default-ring-width
Change Property Value Formats
--spacing
- should now be represented in arem
format; default is0.25rem
--text-scaling
- should be converted from a string to a float; default is1.0
--radius-[base|container]
- should be converted fromrem
topx
format--[base|heading|anchor]-font-family
- make sure you're using a valid font-family list.Update Color Formats
Finally, Tailwind v4 now supports color transparency with any format due to the use of color-mix(). As such the restriction to RGB can now be lifted. You may now convert the current (invalid) color format, to any valid CSS color format. However, Skeleton is aiming to standardize on OKLCH format
Here's an example of before/after conversion. If you are using VS Code, we recommend the hex-to-rgb or oklchanger extensions to aid in this process. Otherwise, any standard converter will work, such this one for OKLCH.
Register and Activate Theme
Once all above theme migrations are complete, make sure you've registered and set and active theme per our documented instructions.
Support
Have a question or need support? Reach out in the comment section below, or within the
#skeleton-next
channel on our Discord.Beta Was this translation helpful? Give feedback.
All reactions