atomico-hooks-dom

Observe slotted nodes and light DOM children in Atomico components.

1.3k|44|Updated Aug 25, 2018
One-click install
npx skills add https://github.com/atomicojs/atomico --skill atomico-hooks-dom
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: atomico-hooks-dom
Source: https://github.com/atomicojs/atomico/tree/main/.agents/skills/atomico-hooks-dom
Command: npx skills add https://github.com/atomicojs/atomico --skill atomico-hooks-dom

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Many Atomico web components need reliable ways to observe and interact with slotted content, light DOM children, and parent components while operating from inside a shadow DOM; manual DOM bookkeeping and inconsistent slot management make these tasks error-prone and fragile. This Skill centralizes reactive DOM observation and traversal into expressive hooks so components can respond to slot changes, track host children, render into the light DOM, and locate ancestor elements safely.

Core Features & Use Cases

  • useSlot: Reactively observe assigned nodes of a slot and filter by type for typed, slotted content handling (e.g., dynamic card lists).
  • useNodes: Observe light DOM children via MutationObserver for manual slot assignment workflows or when working with fragment markers and text nodes.
  • useRender: Render virtual DOM into the light DOM from a shadow-rooted component to improve SEO, enable external styling, or place native form controls.
  • useParent: Traverse composed or non-composed ancestor chains to locate parent components or elements for cross-component communication.
  • Use Case: Build a card list that types and filters slotted items, renders a mirrored summary into the light DOM for SEO, and finds a containing form element across shadow boundaries to attach listeners.

Quick Start

Use the atomico-hooks-dom hooks to observe slot changes with useSlot, track host children with useNodes, render content into the light DOM with useRender, and locate ancestor components with useParent.

Frequently Asked Questions about atomico-hooks-dom

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I observe slotted nodes in web components built with Atomico?

You can observe slotted nodes in Atomico web components by using the useSlot hook to reactively track assigned slot nodes and filter them by type. This allows your component to dynamically respond to changes in slotted content.

What is the best way to track light DOM children from inside a shadow DOM component?

Tracking light DOM children from inside a shadow DOM component is best handled by using MutationObserver-based hooks like useNodes. This approach allows shadow-rooted Atomico components to monitor host children, including fragment markers and text nodes, for manual slot assignment.

Can I render virtual DOM into the light DOM to improve SEO in Atomico?

Yes, you can render virtual DOM into the light DOM to improve SEO in Atomico by using the useRender hook. This allows shadow-rooted components to project content externally, enabling search engine indexing and external styling.

How do I find a parent element across shadow DOM boundaries in web components?

To find a parent element across shadow DOM boundaries, you can use the useParent hook to traverse composed or non-composed ancestor chains. This enables safe cross-component communication and locating containing elements like forms.

Does Atomico support manual slot assignment workflows for light DOM children?

Atomico supports manual slot assignment workflows by using the useNodes hook to observe light DOM children via MutationObserver. This provides reliable tracking of host children for manual assignment and fragment marker management.

What are the limitations of using MutationObserver for light DOM tracking in Atomico?

When using MutationObserver for light DOM tracking in Atomico, you must ensure proper cleanup on unmount to avoid memory leaks. The observation is limited to tracking host children, fragment markers, and text nodes within the light DOM structure.