import * as React from 'react'; import { HoverCard, IHoverCard, IPlainCardProps, HoverCardType, ThemeProvider, DefaultButton, mergeStyleSets, } from '@fluentui/react'; const classNames = mergeStyleSets({ plainCard: { width: 200, height: 200, display: 'flex', alignItems: 'center', justifyContent: 'center', }, target: { fontWeight: '600', display: 'inline-block', border: '1px dashed #605e5c', padding: 5, borderRadius: 2, }, }); const onCardHide = (): void => { console.log('I am now hidden'); }; export const HoverCardInstantDismissExample: React.FunctionComponent = () => { const hoverCard = React.useRef(null); const instantDismissCard = (): void => { if (hoverCard.current) { hoverCard.current.dismiss(); } }; const onRenderPlainCard = (): JSX.Element => { return (
); }; const plainCardProps: IPlainCardProps = { onRenderPlainCard: onRenderPlainCard, }; return (

In cases where an instant dismiss of the card is needed, public method dismiss() can be used through its componentRef prop.

Hover Over Me
); };