Hover Card
---import { Avatar, AvatarFallback, AvatarImage } from "@/components/starwind/avatar";import { Button } from "@/components/starwind/button";import { HoverCard, HoverCardContent, HoverCardTrigger } from "@/components/starwind/hover-card";---
<HoverCard> <HoverCardTrigger asChild> <Button variant="outline">@starwind</Button> </HoverCardTrigger> <HoverCardContent class="w-80" align="start"> <div class="flex justify-between gap-4"> <Avatar class="shrink-0"> <AvatarImage src="https://i.pravatar.cc/150?u=starwind" alt="Starwind UI" /> <AvatarFallback>SW</AvatarFallback> </Avatar> <div class="space-y-1"> <h4 class="text-sm font-semibold">Starwind UI</h4> <p class="text-muted-foreground text-sm"> Accessible Astro components styled with Tailwind CSS. </p> <span class="text-muted-foreground block pt-2 text-xs">Built for Astro developers</span> </div> </div> </HoverCardContent></HoverCard>import { Avatar, AvatarFallback, AvatarImage } from "@/components/starwind/avatar";import { Button } from "@/components/starwind/button";import { HoverCard, HoverCardContent, HoverCardTrigger } from "@/components/starwind/hover-card";
export function Example() { return ( <HoverCard> <HoverCardTrigger asChild> <Button variant="outline">@starwind</Button> </HoverCardTrigger> <HoverCardContent className="w-80" align="start"> <div className="flex justify-between gap-4"> <Avatar className="shrink-0"> <AvatarImage src="https://i.pravatar.cc/150?u=starwind" alt="Starwind UI" /> <AvatarFallback>SW</AvatarFallback> </Avatar> <div className="space-y-1"> <h4 className="text-sm font-semibold">Starwind UI</h4> <p className="text-muted-foreground text-sm"> Accessible Astro components styled with Tailwind CSS. </p> <span className="text-muted-foreground block pt-2 text-xs">Built for Astro developers</span> </div> </div> </HoverCardContent> </HoverCard> );}<script setup lang="ts">import { ButtonVariants } from "@/components/starwind/button";import { Avatar, AvatarFallback, AvatarImage } from "@/components/starwind/avatar";import { Button } from "@/components/starwind/button";import { HoverCard, HoverCardContent, HoverCardTrigger } from "@/components/starwind/hover-card";</script>
<template> <HoverCard> <HoverCardTrigger asChild> <button type="button" :class="ButtonVariants.button({ variant: 'outline' })"> @starwind </button> </HoverCardTrigger> <HoverCardContent class="w-80" align="start"> <div class="flex justify-between gap-4"> <Avatar class="shrink-0"> <AvatarImage src="https://i.pravatar.cc/150?u=starwind" alt="Starwind UI" /> <AvatarFallback>SW</AvatarFallback> </Avatar> <div class="space-y-1"> <h4 class="text-sm font-semibold">Starwind UI</h4> <p class="text-muted-foreground text-sm"> Accessible Astro components styled with Tailwind CSS. </p> <span class="text-muted-foreground block pt-2 text-xs">Built for Astro developers</span> </div> </div> </HoverCardContent> </HoverCard></template><script lang="ts"> import { Avatar, AvatarFallback, AvatarImage } from "@/components/starwind/avatar"; import { ButtonVariants } from "@/components/starwind/button"; import { HoverCard, HoverCardContent, HoverCardTrigger } from "@/components/starwind/hover-card";</script>
<div class="flex items-center justify-center py-6"> <HoverCard> <HoverCardTrigger href="https://starwind.dev"> {#snippet child({ props, children })} <a {...props} class={[ButtonVariants.button({ variant: "outline" }), props.class]} >{@render children?.()}</a > {/snippet} @starwind </HoverCardTrigger> <HoverCardContent class="w-80" align="start"> <div class="flex justify-between gap-4"> <Avatar class="shrink-0"> <AvatarImage src="https://i.pravatar.cc/150?u=starwind" alt="Starwind UI" /> <AvatarFallback>SW</AvatarFallback> </Avatar> <div class="space-y-1"> <h4 class="text-sm font-semibold">Starwind UI</h4> <p class="text-muted-foreground text-sm"> Accessible Astro components styled with Tailwind CSS. </p> <span class="text-muted-foreground block pt-2 text-xs">Built for Astro developers</span> </div> </div> </HoverCardContent> </HoverCard></div>Installation
pnpx starwind@latest add hover-card --framework astronpx starwind@latest add hover-card --framework astroyarn dlx starwind@latest add hover-card --framework astropnpx starwind@latest add hover-card --framework reactnpx starwind@latest add hover-card --framework reactyarn dlx starwind@latest add hover-card --framework reactpnpx starwind@latest add hover-card --framework vuenpx starwind@latest add hover-card --framework vueyarn dlx starwind@latest add hover-card --framework vuepnpx starwind@latest add hover-card --framework sveltenpx starwind@latest add hover-card --framework svelteyarn dlx starwind@latest add hover-card --framework svelteUsage
---import { Avatar, AvatarFallback, AvatarImage } from "@/components/starwind/avatar";import { Button } from "@/components/starwind/button";import { HoverCard, HoverCardContent, HoverCardTrigger } from "@/components/starwind/hover-card";---
<HoverCard> <HoverCardTrigger asChild> <Button variant="outline">@starwind</Button> </HoverCardTrigger> <HoverCardContent class="w-80" align="start"> <div class="flex justify-between gap-4"> <Avatar class="shrink-0"> <AvatarImage src="https://i.pravatar.cc/150?u=starwind" alt="Starwind UI" /> <AvatarFallback>SW</AvatarFallback> </Avatar> <div class="space-y-1"> <h4 class="text-sm font-semibold">Starwind UI</h4> <p class="text-muted-foreground text-sm"> Accessible Astro components styled with Tailwind CSS. </p> <span class="text-muted-foreground block pt-2 text-xs">Built for Astro developers</span> </div> </div> </HoverCardContent></HoverCard>import { Avatar, AvatarFallback, AvatarImage } from "@/components/starwind/avatar";import { Button } from "@/components/starwind/button";import { HoverCard, HoverCardContent, HoverCardTrigger } from "@/components/starwind/hover-card";
export function Example() { return ( <HoverCard> <HoverCardTrigger asChild> <Button variant="outline">@starwind</Button> </HoverCardTrigger> <HoverCardContent className="w-80" align="start"> <div className="flex justify-between gap-4"> <Avatar className="shrink-0"> <AvatarImage src="https://i.pravatar.cc/150?u=starwind" alt="Starwind UI" /> <AvatarFallback>SW</AvatarFallback> </Avatar> <div className="space-y-1"> <h4 className="text-sm font-semibold">Starwind UI</h4> <p className="text-muted-foreground text-sm"> Accessible Astro components styled with Tailwind CSS. </p> <span className="text-muted-foreground block pt-2 text-xs">Built for Astro developers</span> </div> </div> </HoverCardContent> </HoverCard> );}<script setup lang="ts">import { ButtonVariants } from "@/components/starwind/button";import { Avatar, AvatarFallback, AvatarImage } from "@/components/starwind/avatar";import { Button } from "@/components/starwind/button";import { HoverCard, HoverCardContent, HoverCardTrigger } from "@/components/starwind/hover-card";</script>
<template> <HoverCard> <HoverCardTrigger asChild> <button type="button" :class="ButtonVariants.button({ variant: 'outline' })"> @starwind </button> </HoverCardTrigger> <HoverCardContent class="w-80" align="start"> <div class="flex justify-between gap-4"> <Avatar class="shrink-0"> <AvatarImage src="https://i.pravatar.cc/150?u=starwind" alt="Starwind UI" /> <AvatarFallback>SW</AvatarFallback> </Avatar> <div class="space-y-1"> <h4 class="text-sm font-semibold">Starwind UI</h4> <p class="text-muted-foreground text-sm"> Accessible Astro components styled with Tailwind CSS. </p> <span class="text-muted-foreground block pt-2 text-xs">Built for Astro developers</span> </div> </div> </HoverCardContent> </HoverCard></template><script lang="ts"> import { ButtonVariants } from "@/components/starwind/button"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/starwind/avatar"; import { Button } from "@/components/starwind/button"; import { HoverCard, HoverCardContent, HoverCardTrigger, } from "@/components/starwind/hover-card";</script>
<HoverCard> <HoverCardTrigger> {#snippet child({ props })} <a {...props} class={ButtonVariants.button({ variant: "outline" })}>@starwind</a> {/snippet} </HoverCardTrigger> <HoverCardContent class="w-80" align="start"> <div class="flex justify-between gap-4"> <Avatar class="shrink-0"> <AvatarImage src="https://i.pravatar.cc/150?u=starwind" alt="Starwind UI" /> <AvatarFallback>SW</AvatarFallback> </Avatar> <div class="space-y-1"> <h4 class="text-sm font-semibold">Starwind UI</h4> <p class="text-muted-foreground text-sm"> Accessible Astro components styled with Tailwind CSS. </p> <span class="text-muted-foreground block pt-2 text-xs"> Built for Astro developers </span> </div> </div> </HoverCardContent></HoverCard>Composition
Use a trigger and content inside the root:
HoverCard├── HoverCardTrigger└── HoverCardContentWhen to Use
Use Hover Card for optional context that appears when a trigger receives hover or keyboard focus.
Profile Preview
Use asChild on the trigger when you want to reuse an existing interactive component like Button.
---import { Avatar, AvatarFallback, AvatarImage } from "@/components/starwind/avatar";import { Button } from "@/components/starwind/button";import { HoverCard, HoverCardContent, HoverCardTrigger } from "@/components/starwind/hover-card";---
<div class="flex flex-wrap items-center gap-4"> <HoverCard> <HoverCardTrigger asChild> <Button variant="outline">@starwind</Button> </HoverCardTrigger> <HoverCardContent align="start" class="w-80"> <div class="flex justify-between gap-4"> <Avatar class="shrink-0"> <AvatarImage src="https://i.pravatar.cc/150?u=starwind" alt="Starwind UI" /> <AvatarFallback>SW</AvatarFallback> </Avatar> <div class="space-y-1"> <h4 class="text-sm font-semibold">Starwind UI</h4> <p class="text-muted-foreground text-sm"> Accessible Astro components styled with Tailwind CSS. </p> <div class="flex items-center pt-2"> <span class="text-muted-foreground text-xs">Built for Astro developers</span> </div> </div> </div> </HoverCardContent> </HoverCard>
<HoverCard openDelay={200} closeDelay={200}> <HoverCardTrigger asChild> <Button href="https://astro.build" variant="ghost">Astro</Button> </HoverCardTrigger> <HoverCardContent side="right" align="start" class="w-80"> <div class="space-y-2"> <h4 class="text-sm font-semibold">Astro</h4> <p class="text-muted-foreground text-sm"> A web framework for content-driven sites with fast-by-default performance. </p> </div> </HoverCardContent> </HoverCard></div>import { Avatar, AvatarFallback, AvatarImage } from "@/components/starwind/avatar";import { Button } from "@/components/starwind/button";import { HoverCard, HoverCardContent, HoverCardTrigger } from "@/components/starwind/hover-card";
export function Example() { return ( <> <div className="flex flex-wrap items-center gap-4"> <HoverCard> <HoverCardTrigger asChild> <Button variant="outline">@starwind</Button> </HoverCardTrigger> <HoverCardContent align="start" className="w-80"> <div className="flex justify-between gap-4"> <Avatar className="shrink-0"> <AvatarImage src="https://i.pravatar.cc/150?u=starwind" alt="Starwind UI" /> <AvatarFallback>SW</AvatarFallback> </Avatar> <div className="space-y-1"> <h4 className="text-sm font-semibold">Starwind UI</h4> <p className="text-muted-foreground text-sm"> Accessible Astro components styled with Tailwind CSS. </p> <div className="flex items-center pt-2"> <span className="text-muted-foreground text-xs">Built for Astro developers</span> </div> </div> </div> </HoverCardContent> </HoverCard>
<HoverCard openDelay={200} closeDelay={200}> <HoverCardTrigger asChild> <Button href="https://astro.build" variant="ghost">Astro</Button> </HoverCardTrigger> <HoverCardContent side="right" align="start" className="w-80"> <div className="space-y-2"> <h4 className="text-sm font-semibold">Astro</h4> <p className="text-muted-foreground text-sm"> A web framework for content-driven sites with fast-by-default performance. </p> </div> </HoverCardContent> </HoverCard> </div> </> );}<script setup lang="ts">import { ButtonVariants } from "@/components/starwind/button";import { Avatar, AvatarFallback, AvatarImage } from "@/components/starwind/avatar";import { Button } from "@/components/starwind/button";import { HoverCard, HoverCardContent, HoverCardTrigger } from "@/components/starwind/hover-card";</script>
<template> <div class="flex flex-wrap items-center gap-4"> <HoverCard> <HoverCardTrigger asChild> <button type="button" :class="ButtonVariants.button({ variant: 'outline' })"> @starwind </button> </HoverCardTrigger> <HoverCardContent align="start" class="w-80"> <div class="flex justify-between gap-4"> <Avatar class="shrink-0"> <AvatarImage src="https://i.pravatar.cc/150?u=starwind" alt="Starwind UI" /> <AvatarFallback>SW</AvatarFallback> </Avatar> <div class="space-y-1"> <h4 class="text-sm font-semibold">Starwind UI</h4> <p class="text-muted-foreground text-sm"> Accessible Astro components styled with Tailwind CSS. </p> <div class="flex items-center pt-2"> <span class="text-muted-foreground text-xs">Built for Astro developers</span> </div> </div> </div> </HoverCardContent> </HoverCard>
<HoverCard :openDelay="200" :closeDelay="200"> <HoverCardTrigger asChild> <a href="https://astro.build" :class="ButtonVariants.button({ variant: 'ghost' })">Astro</a> </HoverCardTrigger> <HoverCardContent side="right" align="start" class="w-80"> <div class="space-y-2"> <h4 class="text-sm font-semibold">Astro</h4> <p class="text-muted-foreground text-sm"> A web framework for content-driven sites with fast-by-default performance. </p> </div> </HoverCardContent> </HoverCard> </div></template><script lang="ts"> import { ButtonVariants } from "@/components/starwind/button"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/starwind/avatar"; import { Button } from "@/components/starwind/button"; import { HoverCard, HoverCardContent, HoverCardTrigger, } from "@/components/starwind/hover-card";</script>
<div class="flex flex-wrap items-center gap-4"> <HoverCard> <HoverCardTrigger> {#snippet child({ props })} <a {...props} class={ButtonVariants.button({ variant: "outline" })}>@starwind</a> {/snippet} </HoverCardTrigger> <HoverCardContent align="start" class="w-80"> <div class="flex justify-between gap-4"> <Avatar class="shrink-0"> <AvatarImage src="https://i.pravatar.cc/150?u=starwind" alt="Starwind UI" /> <AvatarFallback>SW</AvatarFallback> </Avatar> <div class="space-y-1"> <h4 class="text-sm font-semibold">Starwind UI</h4> <p class="text-muted-foreground text-sm"> Accessible Astro components styled with Tailwind CSS. </p> <div class="flex items-center pt-2"> <span class="text-muted-foreground text-xs">Built for Astro developers</span> </div> </div> </div> </HoverCardContent> </HoverCard> <HoverCard openDelay={200} closeDelay={200}> <HoverCardTrigger> {#snippet child({ props })} <a {...props} href="https://astro.build" class={ButtonVariants.button({ variant: "ghost" })} > Astro </a> {/snippet} </HoverCardTrigger> <HoverCardContent side="right" align="start" class="w-80"> <div class="space-y-2"> <h4 class="text-sm font-semibold">Astro</h4> <p class="text-muted-foreground text-sm"> A web framework for content-driven sites with fast-by-default performance. </p> </div> </HoverCardContent> </HoverCard></div>Side and Alignment
Use side, align, and sideOffset on HoverCardContent to control placement.
---import { Button } from "@/components/starwind/button";import { HoverCard, HoverCardContent, HoverCardTrigger } from "@/components/starwind/hover-card";---
<div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-4"> <HoverCard openDelay={150}> <HoverCardTrigger asChild> <Button variant="outline" class="w-full">Top</Button> </HoverCardTrigger> <HoverCardContent side="top" sideOffset={8}>Appears above the trigger.</HoverCardContent> </HoverCard>
<HoverCard openDelay={150}> <HoverCardTrigger asChild> <Button variant="outline" class="w-full">Right</Button> </HoverCardTrigger> <HoverCardContent side="right" align="start" sideOffset={8}> Appears to the right and aligns to the start. </HoverCardContent> </HoverCard>
<HoverCard openDelay={150}> <HoverCardTrigger asChild> <Button variant="outline" class="w-full">Bottom</Button> </HoverCardTrigger> <HoverCardContent side="bottom" align="end" sideOffset={8}> Appears below and aligns to the end. </HoverCardContent> </HoverCard>
<HoverCard openDelay={150}> <HoverCardTrigger asChild> <Button variant="outline" class="w-full">Left</Button> </HoverCardTrigger> <HoverCardContent side="left" sideOffset={8}>Appears to the left.</HoverCardContent> </HoverCard></div>import { Button } from "@/components/starwind/button";import { HoverCard, HoverCardContent, HoverCardTrigger } from "@/components/starwind/hover-card";
export function Example() { return ( <> <div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4"> <HoverCard openDelay={150}> <HoverCardTrigger asChild> <Button variant="outline" className="w-full">Top</Button> </HoverCardTrigger> <HoverCardContent side="top" sideOffset={8}>Appears above the trigger.</HoverCardContent> </HoverCard>
<HoverCard openDelay={150}> <HoverCardTrigger asChild> <Button variant="outline" className="w-full">Right</Button> </HoverCardTrigger> <HoverCardContent side="right" align="start" sideOffset={8}> Appears to the right and aligns to the start. </HoverCardContent> </HoverCard>
<HoverCard openDelay={150}> <HoverCardTrigger asChild> <Button variant="outline" className="w-full">Bottom</Button> </HoverCardTrigger> <HoverCardContent side="bottom" align="end" sideOffset={8}> Appears below and aligns to the end. </HoverCardContent> </HoverCard>
<HoverCard openDelay={150}> <HoverCardTrigger asChild> <Button variant="outline" className="w-full">Left</Button> </HoverCardTrigger> <HoverCardContent side="left" sideOffset={8}>Appears to the left.</HoverCardContent> </HoverCard> </div> </> );}<script setup lang="ts">import { ButtonVariants } from "@/components/starwind/button";import { Button } from "@/components/starwind/button";import { HoverCard, HoverCardContent, HoverCardTrigger } from "@/components/starwind/hover-card";</script>
<template> <div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-4"> <HoverCard :openDelay="150"> <HoverCardTrigger asChild> <button type="button" :class="ButtonVariants.button({ variant: 'outline', class: 'w-full' })" > Top </button> </HoverCardTrigger> <HoverCardContent side="top" :sideOffset="8">Appears above the trigger.</HoverCardContent> </HoverCard>
<HoverCard :openDelay="150"> <HoverCardTrigger asChild> <button type="button" :class="ButtonVariants.button({ variant: 'outline', class: 'w-full' })" > Right </button> </HoverCardTrigger> <HoverCardContent side="right" align="start" :sideOffset="8"> Appears to the right and aligns to the start. </HoverCardContent> </HoverCard>
<HoverCard :openDelay="150"> <HoverCardTrigger asChild> <button type="button" :class="ButtonVariants.button({ variant: 'outline', class: 'w-full' })" > Bottom </button> </HoverCardTrigger> <HoverCardContent side="bottom" align="end" :sideOffset="8"> Appears below and aligns to the end. </HoverCardContent> </HoverCard>
<HoverCard :openDelay="150"> <HoverCardTrigger asChild> <button type="button" :class="ButtonVariants.button({ variant: 'outline', class: 'w-full' })" > Left </button> </HoverCardTrigger> <HoverCardContent side="left" :sideOffset="8">Appears to the left.</HoverCardContent> </HoverCard> </div></template><script lang="ts"> import { ButtonVariants } from "@/components/starwind/button"; import { Button } from "@/components/starwind/button"; import { HoverCard, HoverCardContent, HoverCardTrigger, } from "@/components/starwind/hover-card";</script>
<div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-4"> <HoverCard openDelay={150}> <HoverCardTrigger> {#snippet child({ props })} <a {...props} class={ButtonVariants.button({ variant: "outline", class: "w-full" })} > Top </a> {/snippet} </HoverCardTrigger> <HoverCardContent side="top" sideOffset={8}> Appears above the trigger. </HoverCardContent> </HoverCard> <HoverCard openDelay={150}> <HoverCardTrigger> {#snippet child({ props })} <a {...props} class={ButtonVariants.button({ variant: "outline", class: "w-full" })} > Right </a> {/snippet} </HoverCardTrigger> <HoverCardContent side="right" align="start" sideOffset={8}> Appears to the right and aligns to the start. </HoverCardContent> </HoverCard> <HoverCard openDelay={150}> <HoverCardTrigger> {#snippet child({ props })} <a {...props} class={ButtonVariants.button({ variant: "outline", class: "w-full" })} > Bottom </a> {/snippet} </HoverCardTrigger> <HoverCardContent side="bottom" align="end" sideOffset={8}> Appears below and aligns to the end. </HoverCardContent> </HoverCard> <HoverCard openDelay={150}> <HoverCardTrigger> {#snippet child({ props })} <a {...props} class={ButtonVariants.button({ variant: "outline", class: "w-full" })} > Left </a> {/snippet} </HoverCardTrigger> <HoverCardContent side="left" sideOffset={8}>Appears to the left.</HoverCardContent> </HoverCard></div>Non-hoverable Content
By default, moving the pointer from trigger to content keeps the card open. Set disableHoverableContent to close immediately when leaving the trigger.
---import { Button } from "@/components/starwind/button";import { HoverCard, HoverCardContent, HoverCardTrigger } from "@/components/starwind/hover-card";---
<HoverCard> <HoverCardTrigger asChild> <Button variant="outline">Hoverable content (default)</Button> </HoverCardTrigger> <HoverCardContent class="max-w-[220px]"> You can move your pointer into this card without closing it. </HoverCardContent></HoverCard>
<HoverCard disableHoverableContent> <HoverCardTrigger asChild> <Button variant="outline">Trigger-only hover</Button> </HoverCardTrigger> <HoverCardContent class="max-w-[220px]"> This card closes when the pointer leaves the trigger. </HoverCardContent></HoverCard>import { Button } from "@/components/starwind/button";import { HoverCard, HoverCardContent, HoverCardTrigger } from "@/components/starwind/hover-card";
export function Example() { return ( <> <HoverCard> <HoverCardTrigger asChild> <Button variant="outline">Hoverable content (default)</Button> </HoverCardTrigger> <HoverCardContent className="max-w-[220px]"> You can move your pointer into this card without closing it. </HoverCardContent> </HoverCard>
<HoverCard disableHoverableContent> <HoverCardTrigger asChild> <Button variant="outline">Trigger-only hover</Button> </HoverCardTrigger> <HoverCardContent className="max-w-[220px]"> This card closes when the pointer leaves the trigger. </HoverCardContent> </HoverCard> </> );}<script setup lang="ts">import { ButtonVariants } from "@/components/starwind/button";import { Button } from "@/components/starwind/button";import { HoverCard, HoverCardContent, HoverCardTrigger } from "@/components/starwind/hover-card";</script>
<template> <HoverCard> <HoverCardTrigger asChild> <button type="button" :class="ButtonVariants.button({ variant: 'outline' })"> Hoverable content (default) </button> </HoverCardTrigger> <HoverCardContent class="max-w-[220px]"> You can move your pointer into this card without closing it. </HoverCardContent> </HoverCard>
<HoverCard disableHoverableContent> <HoverCardTrigger asChild> <button type="button" :class="ButtonVariants.button({ variant: 'outline' })"> Trigger-only hover </button> </HoverCardTrigger> <HoverCardContent class="max-w-[220px]"> This card closes when the pointer leaves the trigger. </HoverCardContent> </HoverCard></template><script lang="ts"> import { ButtonVariants } from "@/components/starwind/button"; import { Button } from "@/components/starwind/button"; import { HoverCard, HoverCardContent, HoverCardTrigger, } from "@/components/starwind/hover-card";</script>
<HoverCard> <HoverCardTrigger> {#snippet child({ props })} <a {...props} class={ButtonVariants.button({ variant: "outline" })}> Hoverable content (default) </a> {/snippet} </HoverCardTrigger> <HoverCardContent class="max-w-[220px]"> You can move your pointer into this card without closing it. </HoverCardContent></HoverCard><HoverCard disableHoverableContent> <HoverCardTrigger> {#snippet child({ props })} <a {...props} class={ButtonVariants.button({ variant: "outline" })}> Trigger-only hover </a> {/snippet} </HoverCardTrigger> <HoverCardContent class="max-w-[220px]"> This card closes when the pointer leaves the trigger. </HoverCardContent></HoverCard>API Reference
Styled Component API
These props are added or materially changed by the installed styled component. Standard HTML attributes remain available through the inherited interfaces noted below. Expand a prop to see named type definitions and framework-specific imports. Follow the Primitive and Runtime links for lower-level behavior props.
Hover Card Trigger
Inherits a attributes.
Contains the following additional props:
asChild boolean false
- Description
- Merges the component behavior and props into its child element.
- Classification
- Primitive override
- Primitive prop
- preview-card.Trigger.asChild
closeDelay number —
- Description
- Sets the delay in milliseconds before closing.
- Classification
- Primitive override
- Primitive prop
- preview-card.Trigger.closeDelay
openDelay number —
- Description
- Sets the delay in milliseconds before opening.
- Classification
- Primitive override
- Primitive prop
- preview-card.Trigger.openDelay
Hover Card Content
Inherits div attributes.
Contains the following additional props:
disablePortal boolean false
- Description
- Keeps the public Portal wrapper inline instead of moving it to a target.
- Classification
- Wrapper prop
portalContainer string —
- Description
- Sets the CSS selector for the public Portal wrapper target.
- Classification
- Wrapper prop
positionerClass string —
- Description
- Adds classes to the generated floating positioner element.
- Classification
- Wrapper prop
sideOffset number 4
- Description
- Sets the distance in pixels between floating content and its anchor.
- Classification
- Primitive override
- Primitive prop
- preview-card.Popup.sideOffset
Primitive And Runtime API
Use these references when you need the lower-level behavior APIs behind Hover Card.
Primitive API
Runtime API
- Preview Card primitive
createPreviewCardfrom@starwind-ui/runtime/preview-card
Changelog
View version history v2.3.0 6 releases
v2.3.0
- In Svelte, a defined
openthat you pass when HoverCard mounts now stays under your control, as in React and Vue. To change it, usebind:or update your state in the change callback. A form reset keeps it. If you passundefinedat mount, HoverCard keeps its own state. - Fixed Hover Card in Vue and Svelte staying hidden when its popup is replaced while open, for example when the
keyon the content changes. - Fixed a HoverCard trigger on a link or span that stayed disabled when a framework wrote
disabled="false". On a native form control, anydisabledattribute still disables it.
v2.2.1
- Vue Preview Card keeps its previous open state when an open or close action is canceled.
- Reduced background work when a React page uses multiple menus, tooltips, or other portals.
- Fixed nested Svelte overlays inside a dialog appearing behind their parent or failing to receive clicks.
- Fixed open content losing its position at the trigger when the React or Vue component updates.
- Fixed nested overlays appearing behind their parent in Vue and Svelte. Overlays can now render under the document body; if custom CSS or DOM queries require them to stay inside a parent, set a portal container or add
data-floating-rootto that parent. - Fixed React 18 retaining removed popup elements when the parent component stays mounted.
v2.2.0
- Added
portalContaineranddisablePortaltoHoverCardContentfor custom portal targets and inline rendering.
v2.1.0
- Added
positionerClasstoHoverCardContentso the floating positioner can be styled directly. - The default
z-indexis now on the positioner. Before, it was on the content.
v2.0.2
- The default export in
index.tsnow has a name,HoverCardParts, so framework tools show a clear name.
v2.0.0
- Hover Card now gets its behavior from Starwind Runtime. Runtime handles opening on hover and focus, placement next to the trigger, and closing.
- See the Preview Card Primitive for the unstyled parts and the behavior API.