Hover card
In code: HoverCard
A small card that opens when a link is hovered or focused: a person, a record. Never the only way to reach the information.
Preview
Booked by Noor Haddad for Friday at 09:30.
Use
The code of the preview above
import { HoverCard, ItemText, PatternAvatar, Row } from '@/components/ui';
<p>
Booked by{' '}
<HoverCard
content={
<Row nowrap gap={3}>
<PatternAvatar name="Noor Haddad" />
<ItemText title="Noor Haddad" note="12 visits since March, usually on Fridays" />
</Row>
}
>
<a className="ui-link" href="#clients">Noor Haddad</a>
</HoverCard>{' '}
for Friday at 09:30.
</p>Options
| Option | Type | What it does |
|---|---|---|
children Needed | ReactElement<Record<string, unknown>, string | JSXElementConstructor<any>> | The link the card belongs to. |
content Needed | ReactNode | What shows in the card: a short summary of what the link leads to. |
Without React
With the CSS in parts (/ui/css/), it needs these, besides the ones every page loads:
components/button.csscomponents/card.csscomponents/table.csscomponents/tabs.csscomponents/popups.csscomponents/dialog.csscomponents/icons.csscomponents/input-group.csscomponents/calendar.csscomponents/button-group-toggle.csscomponents/code-input.csscomponents/tab-bar.csscomponents/command-palette.csscomponents/prose.csscomponents/carousel-arrows.csscomponents/page-transitions.cssparts/carousel.cssparts/calendar.cssparts/date-time-typed-part.cssparts/listbox.cssparts/date-picker.cssparts/board.cssIn the examples
Small screens made with it and the rest of the kit. They work: click, type and choose in them.
Saturday
Hover a name to see who it is
| 08:00 | Yuki Tanabe |
| 10:00 | Kofi Mensah |
| 13:00 | Ines Duarte |
On top of the page: states, do and don’t
A small card when a link is hovered or focused: a person, a record. Never the only way to the information.
States. Closed, opening (fades and rises), open, closing (fades before what it changed appears: afterClose). While open, focus is inside and Escape closes it; when it closes, focus goes back to what opened it.
Do
- Name every dialog, drawer and popover (
DialogTitle,DrawerTitle, oraria-label). - Use
AlertDialogfor anything that cannot be undone, with the action named on its button ("Delete 3 files"). - Use a
Draweron a phone for what aPopoverdoes on a computer.
Don't
- Don't open a dialog from a dialog; change what the open one shows instead.
- Don't put the only way to do something in a right-click menu or a tooltip.
- Don't use a toast for something the person must not miss: that is an
Alerton the page.