Can You See the Box?
Perhaps the most important feature of any DOM element is whether the user can see it. By manipulating this feature with a little JavaScript, you can add interaction cheaply. A common pattern is to load a lot of potential DOM elements at the initial page load but have many of them start off as hidden, manipulating visibility to change the page without needing to call the server for more data.
Most of the time when you want to have a DOM element the user can’t see, you’ll want to use the hidden Tailwind utility, which wraps the CSS property, display: none. In Tailwind, the opposite of hidden is usually block. While many other potential values for display are available, Tailwind’s Preflight makes a lot of elements use the
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access