I recently switched to using TailwindCSS for all my projects in Ghost and it has been an excellent experience.
Although the initial setup required a bit of effort to resolve some minor issues, it was well worth it. I’ve created a guide that covers the basics of getting started and also includes tips on how to avoid the additional research that I had to do to make everything run smoothly. Check it out below:
In this guide, we’ll take an in-depth look at TailwindCSS, a powerful utility-first CSS framework that allows developers to quickly create custom, extensible, and beautiful Ghost themes without writing a line of CSS.
Hope this helps someone out there!
14 Likes
RyanF
January 20, 2023, 4:38pm
2
Very cool! Thanks for creating this.
1 Like
This guide is amazing! Thank you for doing it I would never have got it up and running without this.
Once gotcha was that the screen.css
uses imports, which isn’t compatible with the @tailwind
directive.
Instead, you need to use the bundled @import
that comes with the latest Tailwind.
The section in your article: The Complete Guide for Developing Ghost Themes with TailwindCSS | LayeredCraft
Tailwind docs: Using with Preprocessors - Tailwind CSS
Hope this saves someone a few mins of head-scratching
2 Likes
@ericalli Thanks for sharing, but… since Ghost 5 this guide is not working anymore. Can you please look into it and perhaps share an updated guide…?
RyanF
May 1, 2023, 8:25pm
5
This is related to the update to the Starter theme, most likely. Check out this thread for a way to use Tailwind: How to add Tailwindcss to the Starter theme · Issue #61 · TryGhost/Starter · GitHub
1 Like
Thanks @RyanF !
I just updated the guide with your solution to getting Tailwind working with the updated Starter theme.
2 Likes
RyanF
May 4, 2023, 2:38pm
7
That’s great. Thanks! I haven’t used the @apply
directive that much. How does it work for styling cards?
1 Like
I just completed my first theme using tailwind and it was just seemless
3 Likes
It’s actually really simple and I find it particularly useful for times when you can’t access the HTML for a specific element to add Tailwind classes too. For example:
.kg-card.kg-button-card a.kg-btn {
@apply rounded-full bg-sky-500;
}
You can also use any custom Tailwind configs you have defined for custom colors, fonts, etc.
3 Likes
diomed
June 4, 2023, 4:37pm
12
what do you think about recreating ghost’s default casper theme in tailwind?
1 Like
Just jumping in to say thanks! I followed the guide this morning and it worked perfectly. Appreciate you putting it together!
1 Like