SandboxedOnClick
A container that prevents the click event from bubbling out of it. In the example, a click on a table row calls window.alert(), but the icon button inside SandboxedOnClick only opens the ngrok docs.
When to use
- Stop a click inside a region, such as a menu or a button in a clickable table row, from reaching a click handler on an ancestor.
Polymorphism
SandboxedOnClick accepts an asChild prop. When true, it renders its single child instead of its default <div>, forwarding the sandboxed onClick handler and the ref onto that child. The child keeps its own role: the default <div> carries role="presentation" because it exists only to catch bubbled clicks, but a presentational role on a link or button is a conflict that user agents ignore. Reach for this when the sandboxed click behavior should live directly on a semantic element such as an anchor, without an extra wrapper <div>.
API Reference
SandboxedOnClick
A container that prevents the click event from bubbling out of it. Good to use when you want action buttons inside of a table row or list item that navigates on click.
All props from div, plus:
sandboxedOnClickProps
sandboxedOnClickProps({ allowClickEventDefault?, onClick? }) returns the role="presentation" and onClick props the default <div> uses. When the component does not fit, apply them to your own element. If that element already has a role, take only onClick: role="presentation" on a <td> removes the cell from the table.