Explore $el, $refs, and $root through an interactive photography studio.
Analogy: The Current Shot. Actions using $el affect the element that triggered the action, like applying a unique filter to a single photograph as you take it.
Click a button to apply an effect directly to that specific "shot".
<button @click="$el.classList.add('active')">
Activate Me
</button>
Analogy: Named Lighting. Use $refs to target and control specific, named elements from anywhere within the component, like a remote control for your studio lights.
<div x-ref="myElement"></div>
<button @click="$refs.myElement.focus()">
Focus Element
</button>
Analogy: The Entire Setup. The $root magic variable refers to the component's top-level element. Use it for actions that affect the entire scene, like turning on the main power or changing the backdrop.
These controls affect the container of all three demos.
Change Backdrop:
<div x-data="{...}">
<!-- $root refers to this div -->
<button @click="$root.style.display = 'none'">
Hide Everything
</button>
</div>