Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

christopher's avatar

Laravel-Markdown - How to format output with tailwindcss

So i am using the markdown package from Graham: https://github.com/GrahamCampbell/Laravel-Markdown

@markdown($post->content)

The output is of course plain markup.

<p>my text</p>

Is there a way to add classes to specific elements? Something to

<p class=" font-serif text-gray-800">my text</p>
0 likes
9 replies
christopher's avatar

I don't just need the p tag. It was just an example. Also other elements like h2, h3, code etc.

Nakov's avatar

You can wrap a markdown in all those elements..

Having said that, I don't understand why you would use a markdown then at all :)

christopher's avatar

Hae? I just want to format the HTML classes, why shouldn't i use markdown?

For example: I am coming from Craft and there is this super helpful plugin to format the output of your content within twig => https://github.com/mmikkel/Retcon-Craft like

{{ entry.body | retconAttr('img', { class: 'image' }) }}

Maybe now you know what i mean? :)

Nakov's avatar

I don't see it documented nor available in the package :) maybe you can submit a PR to the package :)

christopher's avatar

That's the problem and the question: The question is, if there's a way to archive it or a plugin like this twig package for Laravel.

It has not to be the plugin itself, maybe also another package to format any output :)

baumgars's avatar

I still don´t see a way to get tailwind into laravel mails. There are a couple of tutorials out there claiming it works but at the end of the day they don´t. If someone finds a working solution please put it on github as a project. Disucssing about snippets without the overall context just leads nowhere.

There is markup and that can be combined with inline style attributes. But thats messy and gets unmaintainable fast.

Please or to participate in this conversation.