# 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

- Do: Pass `titlePart` when the name comes from a part other than `<component>.Title`, as `Dialog` does with `Card.Title`.
- Do: Pass 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');
```

## Related

- [useAccessibleDescriptionWarning](/docs/hooks/use-accessible-description-warning.md)
- [Dialog](/docs/components/dialog.md)
- [Popover](/docs/components/popover.md)
