Hover Card
Floating card that opens after a delay when its trigger is hovered or focused.
<arc-hover-card>Overview
Hover Card shows a floating card when someone hovers over or focuses its trigger. Tooltip shows a short text label. Hover Card holds any markup and opens without a click.
The card opens after open-delay (400ms by default) and closes close-delay (300ms by default) after the cursor leaves the trigger. Moving the cursor into the card cancels the close, so people can use links and buttons inside it. Escape closes it while focus is in the trigger or the card.
position sets the preferred side: bottom (default), top, left or right. If the card doesn't fit there, it flips to the opposite side and shifts along the edge to stay in the viewport. It opens with a fade and a scale from 0.96 to 1. Put the trigger in the default slot and the card's content in the content slot.
Guidelines
Do
- Keep the content short: a heading, a few lines of text, and at most a link or an action
- Raise `open-delay` in dense layouts so the card doesn't open as the cursor passes over
Don't
- Don't put anything people must see in a hover card. Touch screens have no hover
- Don't put forms in the card. Use Popover or Dialog
- Don't set `open-delay` to 0. The card flashes open on every passing hover
- Don't leave the `content` slot empty. The card opens as an empty panel
Features
- `arc-open` and `arc-close` fire when the card shows and hides
Preview
Usage
This component needs JavaScript. Use the Web Component or a framework wrapper.
<arc-hover-card>
<arc-button variant="secondary">Hover me</arc-button>
<div slot="content">Additional details on hover.</div>
</arc-hover-card>import { Button, HoverCard } from '@arclux/arc-ui-react';
export default function Example() {
return (
<HoverCard>
<Button variant="secondary">Hover me</Button>
<div slot="content">Additional details on hover.</div>
</HoverCard>
);
}<script setup>
import { Button, HoverCard } from '@arclux/arc-ui-vue';
</script>
<template>
<HoverCard>
<Button variant="secondary">Hover me</Button>
<div slot="content">Additional details on hover.</div>
</HoverCard>
</template><script>
import { Button, HoverCard } from '@arclux/arc-ui-svelte';
</script>
<HoverCard>
<Button variant="secondary">Hover me</Button>
<div slot="content">Additional details on hover.</div>
</HoverCard>import { Component } from '@angular/core';
import { Button, HoverCard } from '@arclux/arc-ui-angular';
@Component({
imports: [Button, HoverCard],
template: `
<arc-hover-card>
<arc-button variant="secondary">Hover me</arc-button>
<div slot="content">Additional details on hover.</div>
</arc-hover-card>
`,
})
export class MyComponent {}import { Button, HoverCard } from '@arclux/arc-ui-solid';
export default function Example() {
return (
<HoverCard>
<Button variant="secondary">Hover me</Button>
<div slot="content">Additional details on hover.</div>
</HoverCard>
);
}import { Button, HoverCard } from '@arclux/arc-ui-preact';
export default function Example() {
return (
<HoverCard>
<Button variant="secondary">Hover me</Button>
<div slot="content">Additional details on hover.</div>
</HoverCard>
);
}API
open-delaynumber400- Milliseconds to wait after hover/focus before showing the card. Prevents accidental activation during fast cursor movement.
close-delaynumber300- Milliseconds to wait after the cursor leaves the trigger before hiding the card. Moving into the card cancels this timer.
position'bottom' | 'top' | 'left' | 'right''bottom'- Controls which side of the trigger the card appears on. The card is centered along the perpendicular axis using CSS transforms.
Events
arc-open- Fired when the hover card becomes visible
arc-close- Fired when the hover card hides
See also
- TooltipA short text hint shown next to a control on hover or keyboard focus.
- PopoverA floating panel that opens when its trigger is clicked, placed on one of four sides and closed by an outside click or Escape.
- CardContent container with a border and hover effects. When it links somewhere, the whole surface is the link and the border turns to a gradient on hover.