A ref gives component code access to a rendered DOM element. Use one when a custom element exposes a property that you need to read or change, such as a selected value or a display color. section 9.7 section 9.5
Set a custom element’s color in Vue
Declare `const helloWorldElement = ref(null)`, then render `<hello-world ref="helloWorldElement"></hello-world>`. After rendering, an `onMounted` callback can set `helloWorldElement.value.color = "red"` when the reference has a value. The template’s `ref` attribute connects the rendered element to the variable. section 9.7
The access pattern varies by framework:
- React uses `useRef`; the element is available through the ref object’s `current` property. An effect reads a radio-group’s initial value and uses it to update another custom element. section 9.4
- Solid assigns a rendered element to a ref variable. `onMount` reads the radio-group’s value; an event handler responds to later changes. section 9.5
- In wrec, a `ref` attribute can capture a rendered element in a property named by the attribute’s value. section 8.13
When using custom elements in React or Solid JSX, declare `ref` as an optional attribute in each element’s JSX type. Capture the element first, then read or update its properties after rendering. section 9.4 section 9.5



