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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Themes & Styling

Tailwindcss on grav

Started by Jonathan Smith 6 years ago · 4 replies · 3935 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
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/ 🎉

3 years ago

As this post is pretty high in search results for grav and tailwindcss, recent grav version and the devtools support the creation of new themes with tailwindcss or tailwindcss-mix (laravel). It lets you chose on new-theme command. That's pretty neat :)

👍 1

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by Pedro M, 2 months ago
4 197 2 months ago
Themes & Styling · by Ian, 2 months ago
3 92 2 months ago
Themes & Styling · by Norbert, 2 years ago
11 454 3 months ago
Themes & Styling · by Lukáš Findeis, 3 months ago
0 47 3 months ago
Themes & Styling · by Sebadamus, 4 months ago
5 127 3 months ago