Hook that manages aria live announcements for toast notifications.
// Source: https://github.com/microsoft/fluentui | License: MIT | Copyright Microsoft Corporation
// Provided via justclaw.it.com; keep this notice with the code.
'use client';
import * as React from 'react';
import type { Announce } from '../AriaLive';
import { isHTMLElement } from '@fluentui/react-utilities';
/**
* Wraps an aria live announcement function.
* Aria live announcements can be detrimental once the user is already navigating
* multiple toasts. Once the user is focused inside the toaster, the announecments should be disabled.
* @param announce - The aria live announcement function to wrap
* @returns A function to announce a toast and a ref to attach to the toaster element
*/
export function useToastAnnounce(announce: Announce): {
announceToast: Announce;
toasterRef:
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key