prop getter

A function returned by a headless hook, such as getTriggerProps(), that gives back the attributes and event handlers an element needs.

In more detail

The consumer spreads the result onto their own element: <button {...getTriggerProps()}>. This wires up ARIA attributes and keyboard handlers declaratively while leaving the markup and styling free. It is an alternative to sharing state through compound components and context.

Example

getTriggerProps() returns { type: "button", "aria-expanded": open, "aria-controls": "panel-1" }.

Related terms

Taught in

References