Prop Getters Pattern
Learn the prop getters pattern used by headless UI libraries to bundle correct accessibility and event-handling props onto elements.
A prop getter is a function returned by a hook (commonly used in 'headless UI' libraries) that computes and returns the full set of props — event handlers, ARIA attributes, refs — that need to be spread onto a specific DOM element for a component to work correctly. Instead of the consumer manually wiring up onClick, onKeyDown, aria-expanded, and other details themselves, they simply call getToggleButtonProps() and spread the result onto their button.
A prop getter is like a stagehand who hands an actor (the DOM element) a fully prepared prop bundle — including required safety gear (accessibility attributes) — but will happily tuck in any personal item you also want the actor carrying (your own onClick), rather than making you choose between the stagehand's setup and your own.