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.