vovaexpress.blogg.se

Na element state
Na element state






na element state

With a relational CSS selector, developers would be able to write content checks directly in CSS and styles would be applied automatically. Depending on the number of variations, component styles can get out of hand quickly and become difficult to manage and maintain leading to bugs, so developers would need to document all variations and use-cases by using tools like Storybook.

na element state

( Large preview)Įven when using CSS naming methodology like BEM, developers need to keep track of the various CSS classes and make sure to apply them correctly to the parent element and, optionally, to affected child elements. Parent card container layout depends on the content and the card image container is styled differently depending on if the image container has an image caption present or not. Four card variations depending on the content. In those cases, we usually create multiple CSS classes to cover all the possible variations and apply them manually or with JavaScript, depending on the approach and tech stack. Some UI elements can have multiple variations based on various aspects - content, location on the page, child state, etc. Let’s take a look at a few specific examples to help us illustrate the variety of potential use-cases. Upcoming relational selector prototype could extend the range and use-cases for existing selectors, improve the quality and robustness of CSS and reduce the need for using JavaScript to apply styles and CSS classes for those use-cases. The relational selector would be useful for conditionally applying styles to UI components based on the content or state of its children or its succeeding elements in a DOM tree.

na element state

What makes relational selector one of the most requested features in the past few years and how are the developers working around the missing selector? In this article, we’re going to answer those questions and check out the early spec of :has selector and see how it should improve the styling workflow once it’s released. The team at Igalia has worked on some notable web engine features like CSS grid and container queries, so there is a chance for :has selector to see the light of day, but there is still a long way to go. A more fitting name would be a relational selector or relational pseudo-class as per specification, so I’ll be referring to :has as such from now on in the article. The developer community refers to it as a “parent selector” and some developers have pointed out that the name isn’t very accurate. The rendering process has been optimized to the point that browsers can effectively determine what needs to be rendered or updated and what doesn’t, opening the way for a new and exciting set of features.īrian Kardell has recently announced that his team at Igalia is currently prototyping a :has selector that will serve as a parent selector, but it could have a much wider range of use-cases beyond it. The same was being said about the container queries and those are currently being added to beta versions of browsers, so those performance seems to be no longer an issue.īrowser render engines have improved quite a bit since then. The main reason this feature wasn’t implemented all this time seems to be due to performance concerns. Parent selector has been on developers’ wishlist for more than 10 years and it has become one of the most requested CSS features alongside container queries ever since. What makes relational selector one of the most requested features and how are we, as developers, working around not having it? In this article, we’re going to check the early spec of the :has selector, and see how it should improve the CSS workflow once it’s released.








Na element state