Golang Tutorials - Learn Go Programming with Easy Step-by-Step Guides

Explore comprehensive Golang tutorials for beginners and advanced programmers. Learn Go programming with easy-to-follow, step-by-step guides, examples, and practical tips to master Go language quickly.

Adding Custom Styles in TailwindCSS

Adding Custom Styles in TailwindCSS

If you're using Tailwind CSS, you can apply custom styles using utility classes directly in your HTML output. Here's how to add Tailwind classes in PHP:


? Example with Tailwind Classes in PHP

$nameRow = '<a ' . $hrefAttr . ' class="text-blue-600 font-semibold hover:underline">' . htmlspecialchars($aRow['name']) . '</a>';

? Breakdown of Tailwind Classes Used:

  • text-blue-600: Blue text color

  • font-semibold: Semi-bold font

  • hover:underline: Underline on hover


? Conditional Tailwind Classes in PHP

$extraClass = $isActive ? 'bg-green-100' : 'bg-gray-100';$nameRow = '<a ' . $hrefAttr . ' class="p-2 rounded ' . $extraClass . '">' . htmlspecialchars($aRow['name']) . '</a>';

? Tip:

You don't use inline style="..." with Tailwind. Just compose utility classes for layout, spacing, colors, fonts, etc.


Let me know if you're rendering inside a Blade view or want to reuse classes!

Disclaimer for AI-Generated Content:
The content provided in these tutorials is generated using artificial intelligence and is intended for educational purposes only.
html
docker
php
kubernetes
golang
mysql
postgresql
mariaDB
sql