So in principle, using TailwindCSS v3 with Kirby is mostly a breeze and most cases can be solved using custom Tailwind CSS layers (e.g. Markdown, Blocks content). However, I now stumbled over an issue with Kirby Layout Blocks. They can output a grid which is fine but one thing remains:
This is my site/snippets/layouts.php
right now:
<?php // Tell TailwindCSS’ JIT engine that we need the col-span classes anyay. It doesn’t auto-collect it due to the dynamic PHP colspan setting. ?>
<div class="hidden md:col-span-1 md:col-span-2 md:col-span-3 md:col-span-4 md:col-span-5 md:col-span-6 md:col-span-7 md:col-span-8 md:col-span-9 md:col-span-10 md:col-span-11 md:col-span-12"></div>
<?php foreach ($field->toLayouts() as $layout): ?>
<section class="md:grid md:gap-6 md:grid-cols-12" id="<?= $layout->id() ?>">
<?php foreach ($layout->columns() as $column): ?>
<div class="md:col-span-<?= $column->span() ?>">
<div class="text">
<?= $column->blocks() ?>
</div>
</div>
<?php endforeach ?>
</section>
<?php endforeach ?>
Due to the fact that the JIT engine searches the php templates, it usually works fine until it comes to the point that it doesn’t interpret PHP. So stating $column->span()
isn’t useful for the JIT engine and now I’m trying to find a better solution than adding an empty hidden div with the required classnames in there.
Does anyone else have experience or ideas on this? Thanks in advance.
—Anselm