DEV Community: bob.ts · Oct 25, 2024
CSS' only-child instead of Conditional Logic
0Sign in to vote or save
This site does not allow itself to be embedded. You can still read it on the original site — the toolbar below keeps your place in the directory.
In many of the frontend frameworks that I work with, there are options for ternaries or if-branches injected into the HTML logic. This is logic I use a lot. One particular case is to show when there is no data. I just stumbled on a CSS pattern that makes my life much easier: the :only-child pseudo-class. React In React, I would do "something" like this ... { data.length === 0 ? <div> Nothing to…
Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.