-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi @wfwf1997, in general it's only recommended to add tooltips to items that can be keyboard-focused. Otherwise, the tooltip content is inaccessible to keyboard and touch users. You may want to consider using one of the text slots of the Persona to add extra information instead. That said, one option to achieve what you're asking is to add a tooltip around the entire Persona, and then have it positioned above the Avatar, as shown in the Tooltip's Target story: https://react.fluentui.dev/?path=/docs/components-tooltip--docs#target Here's a stackblitz showing that: https://stackblitz.com/edit/b7edwo?file=src%2Fexample.tsx import * as React from 'react';
import { Persona, Tooltip } from '@fluentui/react-components';
export const PersonaWithTooltipExample = () => {
const [avatarRef, setAvatarRef] = React.useState<HTMLSpanElement | null>(
null
);
return (
<Tooltip
relationship="description"
content="The BOSS"
positioning={{ target: avatarRef }}
>
<Persona
name="Kevin Sturgis"
secondaryText="Available"
presence={{ status: 'available' }}
avatar={{
image: {
src: 'https://res-1.cdn.office.net/files/fabric-cdn-prod_20230815.002/office-ui-fabric-react-assets/persona-male.png',
},
ref: setAvatarRef,
}}
/>
</Tooltip>
);
}; |
Beta Was this translation helpful? Give feedback.
-
Another option is to use a render function for the Here's a stackblitz showing that: https://stackblitz.com/edit/b7edwo-fhd4jz?file=src%2Fexample.tsx import * as React from 'react';
import {
Persona,
Tooltip,
Avatar,
AvatarProps,
} from '@fluentui/react-components';
export const PersonaWithTooltipExample = () => {
return (
<Persona
name="Kevin Sturgis"
secondaryText="Available"
presence={{ status: 'available' }}
avatar={{
image: {
src: 'https://res-1.cdn.office.net/files/fabric-cdn-prod_20230815.002/office-ui-fabric-react-assets/persona-male.png',
},
children: (AvatarSlot: typeof Avatar, props: AvatarProps) => (
<Tooltip relationship="description" content="The BOSS">
<AvatarSlot {...props} />
</Tooltip>
),
}}
/>
);
}; |
Beta Was this translation helpful? Give feedback.
Another option is to use a render function for the
avatar
slot. See the documentation for how to do that here: https://react.fluentui.dev/?path=/docs/concepts-developer-customizing-components-with-slots--docs#replacing-the-entire-slotHere's a stackblitz showing that: https://stackblitz.com/edit/b7edwo-fhd4jz?file=src%2Fexample.tsx