{@description}
- {render_slot(@item)}
Hello World
<.my_list description="My List"> <:item>Item 1
<:item> Item 2 the unmodified rendered HTML would look something like this:Hello World
My List
-
Item 1
- Item 2
Hello World
My List
-
Item 1
- Item 2
Item 1
does not belong to my_list ‘s template, but to the caller instead. Therefore, it is also considered a “root” and gets a phx-r attribute. Then, because my_list uses scoped colocated CSS, its root elements (it only has a single one in this example) also get a unique phx-css-* attribute. Combined, this allows us to write the following CSS: @scope ([phx-css-foo]) to ([phx-r]) { p { font-weight: bold; } } With this rule, only p tags that belong to my_list ‘s template will be rendered bold, while any other p tags on the page are unaffected. LiveView does not automatically inject the phx-r attribute. Instead, it is opt-in with a new compile-time configuration: config :phoenix_live_view, # the attribute set on all root tags. Used for Phoenix.LiveView.ColocatedCSS. root_tag_attribute: "phx-r" When implementing colocated CSS, we stumbled across a problem that required us to revisit how HEEx templates are compiled. If you want to read more about this, we published a separate technical deep dive. tl;dr: To make colocated CSS work, we had to change how we compile HEEx templates by splitting compilation into a separate tokenization and parsing step, allowing us to handle macro components (colocated CSS and JS) without making the rest of the compilation more complex. It also allowed us to reuse code we previously had to duplicate between template compilation and formatting. We don’t ship scoping by default With all that effort for colocated CSS, you might be startled when you hear that we don’t actually ship scoping in LiveView 1.2. The reason is that the @scope rule is not yet well supported across browsers at the time of writing (June 2026). Instead, we ship a @behaviour you can implement to do custom scoping, which also allows you to use different strategies. We do have the @scope implementation in the docs if you decide to be an early adopter. Small improvements landing in 1.2 Apart from colocated CSS, LiveView 1.2 also includes some small improvements: - You can now implement a Phoenix.LiveView.HTMLFormatter.TagFormatter behaviour to format