bits

Link Preview

Enable sighted users to preview content behind a link.

Structure

	<script lang="ts">
  import { LinkPreview } from "bits-ui";
</script>
 
<LinkPreview.Root>
  <LinkPreview.Trigger />
  <LinkPreview.Content />
</LinkPreview.Root>
	<script lang="ts">
  import { LinkPreview } from "bits-ui";
</script>
 
<LinkPreview.Root>
  <LinkPreview.Trigger />
  <LinkPreview.Content />
</LinkPreview.Root>

Component API

Link Preview.Root

The root component used to manage the state of the state of the link preview.

Property Type Description
asChild boolean

Whether to use render delegation with this component or not.

Default: false
openDelay number

The amount of time in milliseconds to delay opening the preview when hovering over the trigger.

Default: 700
closeDelay number

The amount of time in milliseconds to delay closing the preview when the mouse leaves the trigger.

Default: 300
positioning FloatingConfig

The positioning configuration for the preview. (docs coming soon)

Default: { position: "bottom", align: "center" }
closeOnOutsideClick boolean

Whether or not to close the preview when clicking outside of it.

Default: true
closeOnEscape boolean

Whether or not to close the preview when pressing the escape key.

Default: true
open boolean

The open state of the link preview component.

Default: false
onOpenChange (open: boolean) => void

A callback that fires when the open state changes.

Default: undefined

Link Preview.Trigger

A component which triggers the opening and closing of the link preview on hover or focus.

Property Type Description
asChild boolean

Whether to use render delegation with this component or not.

Default: false
Data Attribute Value/Description
data-state

The open state of the link preview.

Value: 'open' | 'closed'

Link Preview.Content

The contents of the link preview which are displayed when the preview is open.

Property Type Description
asChild boolean

Whether to use render delegation with this component or not.

Default: false
Data Attribute Value/Description
data-state

The open state of the link preview.

Value: 'open' | 'closed'

Link Preview.Arrow

An optional arrow element which points to the trigger when the preview is open.

Property Type Description
asChild boolean

Whether to use render delegation with this component or not.

Default: false
size number

The height and width of the arrow in pixels.

Default: 8
Data Attribute Value/Description
data-arrow

Present on the arrow element.

Value: ''

🚧 UNDER CONSTRUCTION 🚧