Every component generated byDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/davesnx/styled-ppx/llms.txt
Use this file to discover all available pages before exploring further.
%styled.* exposes an innerRef prop that is forwarded to the underlying DOM element. Use it wherever you would normally use ref — for focus management, scroll position, measuring dimensions, or integrating with third-party libraries that need a direct DOM node.
The prop is named
innerRef, not ref. React’s built-in ref prop is reserved and cannot be passed through components; styled-ppx uses innerRef as its forwarding mechanism.Complete example
The example below creates a styledInput component and uses innerRef with React.useRef to programmatically focus the input when a button is clicked:
- Create a ref with
React.useRef(Js.Nullable.null). - Pass it to the styled component as
innerRef={ReactDOM.Ref.domRef(input)}. - Access the DOM node via
input.currentto call imperative DOM APIs.
Further reading
Forwarding Refs — ReScript React docs
Full documentation on how React refs work in ReScript, including
forwardRef components and callback refs.