Skip to content

Commit

Permalink
Update directives-reference.mdx with optional root margin
Browse files Browse the repository at this point in the history
Documentation for optional root margin on client visible.
This documents this pr withastro/astro#9363
  • Loading branch information
3ddyBoi authored Jan 2, 2024
1 parent 324228a commit 8dbac81
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/content/docs/en/reference/directives-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ Load and hydrate the component JavaScript once the component has entered the use
<HeavyImageCarousel client:visible />
```

🆕 **New Feature - Optional rootMargin:** This feature allows for earlier component hydration in scenarios like slow internet connections or when components alter the page layout after loading. By setting a rootMargin, hydration is initiated when this specified margin around the component enters the viewport, rather than the component itself.
```astro
<HeavyImageCarousel client:visible="200px" />
```
Implementing a rootMargin, such as "200px", is beneficial for reducing layout shifts(CLS) and ensuring components are interactively ready sooner, enhancing the stability and responsiveness of the page.

### `client:media`

- **Priority:** Low
Expand Down

0 comments on commit 8dbac81

Please sign in to comment.