Skip to content

useInteractiveRole

@astryxdesign/core v0.7.1 · useInteractiveRole

Parameters ​

NameTypeDefaultDescription
options.hrefstring | undefined, or a ref / getter of it—URL for navigation. Highest priority: with a non-empty href the component is a link.
options.hasOnClickboolean, or a ref / getter of itfalseWhether the component has a click handler. Resolves to a button, ahead of anything else after the href. Upstream takes the handler itself; a boolean keeps a handler and a getter apart.
options.isDisabledboolean, or a ref / getter of itfalseWhen true, href is ignored for role resolution (a disabled link is an anti-pattern), so the role comes from the click handler, then inert.

Returns ​

NameTypeDescription
roleComputedRef<'link' | 'button' | 'inert'>The element the component should render: an anchor, a button, or a non-interactive span / div.