# LinkPreview (@limerdev/zest) A preview card shown while the pointer rests on a link (`openDelay`, `closeDelay`): a person, a project or a document behind it. The link still works as a link. The card is a mouse convenience: keyboard and touch users only get the link. - Category: Overlays - Import: `import { LinkPreview } from '@limerdev/zest'` - Bits UI: `LinkPreview`, https://bits-ui.com/docs/components/link-preview - Exports: `LinkPreview.Root`, `LinkPreview.Trigger`, `LinkPreview.Content`, `LinkPreview.Portal` - Use for: A sighted, mouse-friendly preview of what a link leads to, such as a profile behind an @mention. - Don't: Anything the user needs, or anything to click inside the card: keyboard and touch users never see it. Use `Popover`, or put the information on the linked page. ```svelte @anna

Anna Berg

Project lead, Zest

``` Props of `LinkPreview.Root`: - `closeDelay` (`number`, default `300`): The delay in milliseconds before the preview closes. - `disabled` (`boolean`, default `false`): When `true`, the preview will be disabled and will not open. - `ignoreNonKeyboardFocus` (`boolean`, default `false`): Prevent the preview from opening if the focus did not come using the keyboard. - `onOpenChange` (`OnChangeFn`): A callback that will be called when the link preview is opened or closed. - `onOpenChangeComplete` (`OnChangeFn`): A callback that will be called when the link preview finishes opening/closing animations. - `open` (`boolean`, default `false`, bindable): The open state of the link preview. - `openDelay` (`number`, default `700`): The delay in milliseconds before the preview opens. Props of `LinkPreview.Content`: - `align` (`"start" | "center" | "end"`, default `'center'`): The preferred alignment of the anchor to render against when open. This may change when collisions occur. - `alignOffset` (`number`): An offset in pixels from the "start" or "end" alignment options. - `arrowPadding` (`number`): This describes the padding between the arrow and the edges of the floating element. If your floating element has border-radius, this will prevent it from overflowing the corners. - `avoidCollisions` (`boolean`, default `true`): When `true`, overrides the `side` and `align` options to prevent collisions with the boundary edges. - `collisionBoundary` (`Arrayable`): A boundary element or array of elements to check for collisions against. - `collisionPadding` (`number | Partial>`, default `8`): The amount in pixels of virtual padding around the viewport edges to check for overflow which will cause a collision. - `customAnchor` (`string | HTMLElement | Measurable | null`): Use an element other than the trigger to anchor the content to. If provided, the content will be anchored to the provided element instead of the trigger. You can pass a selector string or an HTMLElement. - `dir` (`"ltr" | "rtl"`): The text direction of the content. - `escapeKeydownBehavior` (`"close" | "defer-otherwise-close" | "defer-otherwise-ignore" | "ignore"`, default `close`): Escape behavior type. `close`: Closes the element immediately. `defer-otherwise-close`: Delegates the action to its parent component that has an escape keydown handler. If no parent is found, it closes the element. `defer-otherwise-ignore`: Delegates the action to the parent element. If no parent is found, nothing is done. `ignore`: Prevents the element from closing and also blocks the parent element from closing in response to an escape key press. - `forceMount` (`boolean`): When `true`, the link preview content will be forced to mount in the DOM. Useful for more control over the transition behavior. - `hideWhenDetached` (`boolean`) - `interactOutsideBehavior` (`"close" | "defer-otherwise-close" | "defer-otherwise-ignore" | "ignore"`, default `close`): Interact outside behavior type. `close`: Closes the element immediately. `defer-otherwise-close`: Delegates the action to the parent element. If no parent is found, it closes the element. `defer-otherwise-ignore`: Delegates the action to the parent element. If no parent is found, nothing is done. `ignore`: Prevents the element from closing and also blocks the parent element from closing in response to an outside interaction. - `onEscapeKeydown` (`((e: KeyboardEvent) => void)`): Callback fired when escape is pressed. - `onFocusOutside` (`((event: FocusEvent) => void)`): Callback fired when focus leaves the dismissible layer. - `onInteractOutside` (`InteractOutsideEventHandler`): Callback fired when an outside interaction event completes, which is either a `pointerup`, `mouseup`, or `touchend` event, depending on the user's input device. - `portalProps` (`PortalProps`): Props for the portal the content renders in: `to` (the element to render in, the body by default) and `disabled` (render in place). - `side` (`"top" | "right" | "bottom" | "left"`, default `'bottom'`): The preferred side of the anchor to render against when open. Will be reversed when collisions occur. - `sideOffset` (`number`, default `4`): The distance in pixels from the anchor to the floating element. - `sticky` (`"partial" | "always"`) Props of `LinkPreview.Portal`: - `disabled` (`boolean`, default `false`): Disable portalling and render the component inline - `to` (`PortalTarget`, default `document.body`): Where to portal the content to. Example: A mention A profile behind an @mention. The link works as a link; the card is extra, for mouse users. ```svelte

Week 49 was approved by @anna AB Anna Berg Project lead, Zest. Approves hours for 12 people.

```