Skip to content
Mosaic
On this page

useAccessibleNameWarning

Warns in development when an element with role="dialog" or role="alertdialog" has no accessible name. Call it as useAccessibleNameWarning(node, component, titlePart?). Does nothing in production.

Use for

  • a dev warning when an overlay part renders a dialog without a title
  • checking that aria-labelledby points at an element with text

Practices

GuidancePractice
DoPass titlePart when the name comes from a part other than <component>.Title, as Dialog does with Card.Title.
DoPass the mounted node, such as from a callback ref held in state, so the check runs once the element exists.

Examples

In an overlay popup

TSX
useAccessibleNameWarning(node, 'Popover');