Skip to content

Commit cc1b418

Browse files
committed
update docs
1 parent 31d3779 commit cc1b418

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

lib/phoenix_live_view/colocated_css.ex

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,11 @@ defmodule Phoenix.LiveView.ColocatedCSS do
4242
4343
## Scoped CSS
4444
45-
By default, Colocated CSS is not scoped. This means that the styles defined in a Colocated CSS block are extracted as is.
46-
However, LiveView supports scoping Colocated CSS by defining a `:scoper` module implementing the `Phoenix.LiveView.ColocatedCSS.Scoper`
47-
behaviour. When a `:scoper` is configured, Colocated CSS that is not defined with the `global` attribute will be scoped
48-
according to the configured scoper.
45+
The idea behind scoped CSS is to restrict the elements that CSS rules apply to
46+
to only the elements of the current template / component.
4947
50-
An example scoper using CSS `@scope` can be implemented like this:
48+
One way to scope CSS is to use [CSS `@scope` rules](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@scope).
49+
A scoped `ColocatedCSS` module using CSS `@scope` can be implemented like this:
5150
5251
```elixir
5352
defmodule MyAppWeb.ColocatedScopedCSS do
@@ -155,8 +154,7 @@ defmodule Phoenix.LiveView.ColocatedCSS do
155154
}
156155
```
157156
158-
This uses [CSS donut scoping](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@scope) to
159-
apply any styles defined in the colocated CSS block to any element between a local root and a component.
157+
This applies any styles defined in the colocated CSS block to any element between a local root and a component.
160158
It relies on LiveView's global `:root_tag_attribute`, which is an attribute that LiveView adds to all root tags,
161159
no matter if colocated CSS is used or not. When the browser encounters a `phx-r` attribute, which in this case
162160
is assumed to be the configured global `:root_tag_attribute`, it stops the scoped CSS rule.

0 commit comments

Comments
 (0)