Hover card
A preview card that appears on hover or focus.
Left out of Accessible first Touch screens have no hover, and public services are used on any device. A person with a tremor completes a form on a tablet. Use instead: Collapsible
See it live
npm run storybookWhen to use it
- Use it when: A quick look at a person or link for people with a mouse, with the same detail reachable on click.
- Not when: The only way to see the content: touch screens have no hover.
Instead:
Words
- Use common words. Explain any term you must use.
- One idea per sentence. Put the action first.
- Never blame the person.
- Use: Continue, Change, Start, You. Avoid: Invalid, Utilise, Submit, Error code.
The labels components use, from the voice tokens:
content.action.commit: Continuecontent.action.cancel: Go backcontent.action.destroy: Deletecontent.action.retry: Try againcontent.action.empty-action: Start a new application
See Voice and tone for the whole voice.
Use it in code
npx open-ds add hover-card
The component reads only component keys and semantic tokens, so it follows the brand and mode on <html>.
Tokens it reads
Hover card reads 6 tokens of its own, each an alias of a semantic token. Each row is one part: its own token, the semantic it aliases, and the value it ends at. Change a semantic and every component that reads it follows; override one of Hover card's tokens to change Hover card alone.
Accessible first decides what changes when you switch theme. Here a switch changes colors only, so the marked rows differ between light and dark; everything else holds steady.
| Part | Its token and the semantic it aliases | Value |
|---|---|---|
| Shared | ||
| Transition panels duration | component.transition.panels-durationmotion.duration.panelsvar(--transition-panels-duration) | duration.moderate:200ms |
| Content | ||
| Corner | component.hover-card.content.radiusradius.controlvar(--hover-card-content-radius) | radius.6:0.375rem |
| Fill Changes with theme | component.hover-card.content.backgroundcolor.surface.raisedvar(--hover-card-content-background) | Lightgray.light.0:#FFFFFFDarkgray.dark.100:#222222 |
| Padding | component.hover-card.content.paddingspace.inset.containervar(--hover-card-content-padding) | space.24:1.5rem |
| Text Changes with theme | component.hover-card.content.labelcolor.text.primaryvar(--hover-card-content-label) | Lightgray.light.900:#141414Darkgray.dark.900:#F7F7F7 |
| Shadow | component.hover-card.content.shadowelevation.overlayvar(--hover-card-content-shadow) | shadow.none |
| From the system | ||
| Edge Changes with theme | color.border.default straight from the system, through --border | Lightgray.light.200 · #D6D6D6Darkgray.dark.100 · #222222 |