https://sebastiandedeyne.com/empty-states-with-css-and-the-only-child-selector https://sebastiandedeyne.com/tags/css https://sebastiandedeyne.com/tags/tailwind https://sebastiandedeyne.com/tags/laravel https://sebastiandedeyne.com/tags/blade When you're rendering a list, I often wrap a loop in an if/else statement to display an empty state when the list is empty.

If you want to reduce nesting and drop the conditional, here's a smart trick with the :only-child selector to display the message when there are no events. @foreach($events as $event) {{ $event->name }} @endforeach

We hide the message, but when it's the only child in the section, we'll display it.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners