Popover
A non-modal popup anchored to the button that opens it.
import { Popover } from '@iffday/ui';Example
Popover uses the same surface as Menu: white, a 10px radius and the popup shadow. Unlike a menu it is not a list of actions, so it can hold anything. Festival directory cards use it for the tags that do not fit: +4 shows them all.
FIAPFCompetitive
import { useT } from '@iffday/i18n';
import { Button, Pill, Popover } from '@iffday/ui';
export default function Example() {
const t = useT();
const tags = ['FIAPF', 'Competitive', 'Asia', 'Market', 'Short films', 'Documentary'];
return (
<div className="pill-row">
{tags.slice(0, 2).map((tag) => (
<Pill key={tag}>{tag}</Pill>
))}
<Popover
align="start"
label={t('festival.directory.allTags')}
trigger={
<Button
type="button"
className="button small soft"
aria-label={t('festival.directory.showAllTagsLabel', { 0: tags.length })}
>
+{tags.length - 2}
</Button>
}
>
<div className="pill-row" style={{ padding: 6, maxWidth: 260 }}>
{tags.map((tag) => (
<Pill key={tag}>{tag}</Pill>
))}
</div>
</Popover>
</div>
);
}Usage
For a list of actions use Menu; when the reader has to finish something before going on, use Dialog. label names the popup for screen readers.
Props
A non-modal popover anchored to its trigger.
| Prop | Type | Default |
|---|---|---|
trigger* | ReactElement<Record<string, unknown>> | |
children* | ReactNode | |
side | Side | 'bottom' |
align | Align | 'center' |
label | string |