Skip to content
Grav 2.0 is officially stable. Read the announcement →
Themes & Styling

Tailwindcss on grav

Started by Jonathan Smith 6 years ago · 4 replies · 4152 views
6 years ago

Hi. I'm new to Grav and I was wondering if there was a way to install Tailwind Css in order to use it for responsive design. Thanks!

6 years ago

Sure. You can use e.g. the Shortcode Assets Plugin. This example shows you the different variants of adding a CSS file:

TXT
[assets=css]
custom-style.css
/blog/some-blog/post/style.css
//cdnjs.cloudflare.com/ajax/libs/1140/2.0/1140.css
http://somesite.com/js/cookies.min.css
[/assets]

Documentation here:
https://github.com/getgrav/grav-plugin-shortcode-assets

Or use this plugin for site wide CSS injection:
https://github.com/getgrav/grav-plugin-custom-css/blob/master/README.md

last edited 02/22/20 by Harald Schneider
6 years ago

@planetoid127, I took a quick look at Tailwind Css and did some playing using the installation guide.

The following steps will add css generated by Tailwind to your site:

  • Create fresh Grav installation
  • Install the Devtools plugin. In the root of your site, run:
    $ bin/gpm install devtools
  • Create your own theme using the devtools plugin:
    $ bin/plugin devtools newtheme
    • I named the theme 'mytheme'
    • In the wizard when asked 'Please choose an option', choose 'pure-blank' as theme.
  • Tell Grav to use the new theme. Set the following in '/user/config/system.yam':
    YAML
    pages:
     theme: mytheme
    
  • Create folder '/themes/mytheme/build'
  • Inside folder '/themes/mytheme/build' run:
    $ npm install tailwindcss
  • Create file '/themes/mytheme/css-tailwind/custom.css' with the following content:
    TXT
    @tailwind base;
    @tailwind components;
    @tailwind utilities;
    
  • Inside folder 'build', run the following command:
    $ npx tailwindcss build ../css-tailwind/custom.css -o ../css/custom.css
    Note: Template '/user/themes/mytheme/templates/partials/base.html.twig' loads '/css/custom.css' by default. If you want a different filename, change it in above scripts and in 'base.html.twig'.
  • Point the browser to your site. No, it doesn't look pretty...
    I did not research how Tailwind should be customized. I'll leave that up to you.. ;-)
  • Next: Customize your new theme and Tailwind to your liking...

Hope this helps..

👍 2
1 reply
last edited 02/22/20 by pamtbaau
6 years ago

Hi @planetoid127, there will be big news related to a Grav Tailwind-based theme soon(ish) with Grav Premium… maybe even in just a few weeks at https://getgrav.org/ 🎉

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by stuart young, 2 weeks ago
3 251 2 weeks ago
Themes & Styling · by Sebadamus, 3 weeks ago
5 317 2 weeks ago
Themes & Styling · by martynfoster735, 4 weeks ago
1 310 4 weeks ago
Themes & Styling · by Justin Young, 1 month ago
1 348 1 month ago
Themes & Styling · by Slebeig, 2 months ago
4 474 2 months ago