krakero/tailwind-fieldtype
A Statamic fieldtype for selecting Tailwind CSS classes in the control panel. Give editors a searchable, configurable list of utilities so they can style content without memorizing class names or hand-typing long strings.
This is the Statamic 6 / Tailwind 4 compatible line, currently in beta. Treat it as a deliberate upgrade target rather than a drop-in patch.
Minimal setup:
composer require krakero/tailwind-fieldtype:^3.0@beta
Then:
CHANGELOG.md and UPGRADE.md before touching an existing site. The beta is explicitly scoped to Statamic 6 + Tailwind 4, so check those constraints against your app first.php artisan config:clear
php artisan view:clear
php artisan statamic:stache:clear
First use case: add the field to a page or collection blueprint so editors can choose Tailwind utility classes in the Control Panel, then render the saved value in your Antlers or Blade template and confirm the classes appear in the compiled Tailwind 4 CSS. That last step is the real smoke test — the field saving a value is only half the job.
Where to look first:
UPGRADE.md for breaking changes from the 2.x line.Blueprint-first reuse. Define the field once in a reusable fieldset and include it across collections. This keeps editor experience consistent and avoids drift between sections of the site.
# resources/fieldsets/tailwind_classes.yaml
title: Tailwind Classes
fields:
-
handle: tailwind_classes
field:
type: tailwind # verify exact handle in the package README
display: Tailwind Classes
Render with a fallback. Never assume the field is populated:
<div class="{{ tailwind_classes ?? 'p-4' }}">
{{ content }}
</div>
<div class="{{ $page->tailwind_classes ?: 'p-4' }}">
{{ $content }}
</div>
Pair with structured content. The fieldtype is most useful alongside Bard/Replicator sets, where each set can carry its own utility classes. Keep the allowed class vocabulary narrow per set so editors do not turn every block into a snowflake.
Use defaults for new entries. Set a sensible default in the blueprint so new pages render correctly before an editor touches the field. This reduces “blank page” support tickets during rollout.
Integration with Tailwind 4. Tailwind 4 uses CSS-first configuration and automatic content detection. If your class values live in YAML/content rather than source templates, verify they are being discovered. You may need explicit @source directives or an inline safelist for dynamic class values:
@import "tailwindcss";
@source "../../resources/views";
/* Add explicit sources or inline safelist entries for stored class values */
Upgrade workflow. Create a branch, upgrade Statamic and Tailwind first, then install the beta fieldtype. Exercise every blueprint that uses the field, rebuild CSS, and compare the generated stylesheet before and after. Do not combine the fieldtype upgrade with unrelated template refactors.
^3.0@beta can resolve to a different beta over time. Pin the exact version in composer.lock and avoid unattended updates in production until a stable 3.x is available.config:clear, view:clear, and statamic:stache:clear. Also rebuild front-end assets; stale compiled CSS is frequently mistaken for a fieldtype bug.composer show krakero/tailwind-fieldtype; confirm field handle matches the blueprint; inspect saved entry data; check compiled CSS for the class; clear caches and rebuild assets; then reproduce on a clean entry.UPGRADE.md for any data or config migrations before rolling forward.How can I help you explore Laravel packages today?