Skip to content
Mosaic
On this page

useAccessibleDescriptionWarning

Warns in development when an alert dialog has no accessible description. Call it as useAccessibleDescriptionWarning(node, component, descriptionPart?). Does nothing in production or while node is null.

Use for

  • a dev warning when an alert dialog renders without a description
  • checking that aria-describedby points at an element with text

Practices

GuidancePractice
DoPass null as node for an ordinary dialog. Only an alert dialog needs a description.
DoPass descriptionPart when the description comes from a part other than <component>.Description, as Dialog does with Card.Description.

Examples

Only for an alert dialog

TSX
useAccessibleDescriptionWarning(isAlert ? node : null, 'Dialog', 'Card.Description');