Skip to main content
/
/
/
useFloatingMessage()

useFloatingMessage()

import useFloatingMessage from "@intility/bifrost-react/hooks/useFloatingMessage";

Only available inside components wrapped in the <FloatingMessage> provider component.

The useFloatingMessage() hook returns an object with a single method named showFloatingMessage.

The showFloatingMessage(message, options)method accepts two parameters:

  • message simple string or JSX
  • options optional object, forwarded as props for <Message>
import useFloatingMessage from "@intility/bifrost-react/hooks/useFloatingMessage";

// inside a component nested inside <FloatingMessage>
const { showFloatingMessage } = useFloatingMessage();

// show a simple message
showFloatingMessage("Hello world!");

// show a formatted warning message
showFloatingMessage(
  <>
    Goodbye <em>cruel</em> world!
  </>,
  { state: "warning" },
);

See <FloatingMessage> docs for more information, live demo and sandbox.