Link Preview
A rich Open Graph link preview card with thumbnail, favicon, domain, title and description, wrapped as a single anchor.
Preview
<div class="mx-auto w-full max-w-md space-y-3">
<x-ui.link-preview
href="https://ui.heygaia.io"
domain="heygaia.io"
title="Designing a token-first UI system"
description="How semantic design tokens keep light, dark and RTL themes in sync without touching a single component."
/>
<x-ui.link-preview
href="https://laravel.com/docs"
domain="laravel.com"
title="Laravel — The PHP framework for web artisans"
description="Documentation for the elegant, expressive framework that powers this registry."
/>
</div>
Installation
php artisan ui:add link-preview
Registry contract
php artisan ui:add link-preview
writes only the files below. The CLI validates each file hash before writing and asks before it replaces a local change, unless you pass --force.
-
resources/views/components/ui/link-preview.blade.php
- Registry dependencies
- None — installs on its own.
- Packages
-
composer: jml/brok:^0.2
Use with AI
A brief for your coding agent: install command, usage, props, guidance and the rules. Copy it, or open a prompt about this component in an assistant.
# Brok UI: Link Preview (`link-preview`)
A rich Open Graph link preview card with thumbnail, favicon, domain, title and description, wrapped as a single anchor.
Brok UI is a Laravel Blade component registry. Installed components are plain Blade files the app owns.
## Install
```bash
php artisan ui:add link-preview
```
## Usage
```blade
<div class="mx-auto w-full max-w-md space-y-3">
<x-ui.link-preview
href="https://ui.heygaia.io"
domain="heygaia.io"
title="Designing a token-first UI system"
description="How semantic design tokens keep light, dark and RTL themes in sync without touching a single component."
/>
<x-ui.link-preview
href="https://laravel.com/docs"
domain="laravel.com"
title="Laravel — The PHP framework for web artisans"
description="Documentation for the elegant, expressive framework that powers this registry."
/>
</div>
```
## Props
- `href` (string, default `#`)
- `title` (string, default `Designing a token-first UI system`)
- `description` (string, default `How semantic design tokens keep light, dark and RTL themes in sync without touching a single component.`)
- `image` (mixed|null, default `null`)
- `domain` (string, default `heygaia.io`)
- `favicon` (mixed|null, default `null`)
## Use when
- Use when self-contained content objects benefit from a recognizable card-like presentation with local actions or metadata.
- Showing a rich preview of an external link with its image, favicon, domain and description.
- Rendering Open Graph data already fetched server-side.
## Avoid when
- Do not use card widgets where a simpler list, table, or plain text block would make comparison faster.
- Previewing on hover; hover-card is the transient surface.
- Fetching metadata client-side; the card only renders what it is given.
## Anti-patterns
- Using cards for dense cross-item comparison
## Rules
- Use the `<brok:link-preview>` tag (or `<x-ui.link-preview>`) in Blade; do not rewrite the component.
- Prefer the documented props and variants over utility-class overrides; when a utility must win, use the `!` important modifier.
- Use semantic design tokens (`bg-primary`, `text-muted-foreground`), never raw colour utilities.
- Keep the `data-slot` attributes; they are the styling and test hooks.
## Links
- Docs: https://brokui.dev/docs/components/link-preview
- Registry JSON (files, props, contract): https://brokui.dev/r/open/link-preview.json
Working in Claude Code, Cursor or Codex? Give the agent the whole registry through the MCP server or the Brok UI skill.
API
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| href | string | # | |
| title | string | Designing a token-first UI system | |
| description | string | How semantic design tokens keep light, dark and... | |
| image | mixed | null | null | |
| domain | string | heygaia.io | |
| favicon | mixed | null | null |
Slots
default—
Data slots
Stable hooks for CSS overrides and browser tests.
Behavior
- The whole card is one anchor to href, so the title, domain and image are a single target.
- image and favicon render when given; the layout holds without either.
- Declares registry capability flags: a11y, responsive, rtl, darkMode, localized.
Guidance
Present a self-contained content object with local context.
Use when
- Use when self-contained content objects benefit from a recognizable card-like presentation with local actions or metadata.
- Showing a rich preview of an external link with its image, favicon, domain and description.
- Rendering Open Graph data already fetched server-side.
Avoid when
- Do not use card widgets where a simpler list, table, or plain text block would make comparison faster.
- Previewing on hover; hover-card is the transient surface.
- Fetching metadata client-side; the card only renders what it is given.
Use instead
- List for compact scanning
- Table for exact comparison
Anti-patterns
- Using cards for dense cross-item comparison
- Anatomy
- Theming hooks
Accessibility
- Keyboard
- native
- Focus
native
- One anchor per card means one tab stop and one announced link, named by the title.
- The thumbnail and favicon are decorative and aria-hidden.
- Semantic HTML and a stable
data-slotattribute for styling and scripting hooks. - Focus-visible rings use the
ringtoken, so keyboard focus is always visible. - Disabled and invalid states are conveyed to assistive tech, not by color alone.
- Targets WCAG 2.2 AA; verify contrast in light, dark, admin and customer surfaces in the preview.
- Labels go through
__()and layout uses logical properties (ms-*,text-start), so it mirrors underdir="rtl"— flip the preview to RTL to confirm. - Dark mode uses the same semantic tokens under the
darkclass; high contrast follows forced-color system tokens.
Livewire
Livewire can update this component through forwarded wire:* attributes.
Validation
Validation support: native. Keep the error message connected with aria-describedby.
<form wire:submit="save" class="space-y-2">
<brok:link-preview
wire:model="value"
:aria-invalid="$errors->has('value') ? 'true' : 'false'"
aria-describedby="value-error"
/>
@error('value')
<p id="value-error" role="alert">{{ $message }}</p>
@enderror
<brok:button type="submit" wire:loading.attr="disabled">
<span wire:loading.remove>Save</span>
<span wire:loading>Saving…</span>
</brok:button>
</form>
Source
The exact, editable file ui:add writes
into your app. Previews render this same code; there are no preview-only components.
@props([
'href' => '#',
'title' => 'Designing a token-first UI system',
'description' => 'How semantic design tokens keep light, dark and RTL themes in sync without touching a single component.',
'image' => null,
'domain' => 'heygaia.io',
'favicon' => null,
])
@php
// Derive a display domain from the href when one isn't supplied.
$domain = $domain ?: (parse_url((string) $href, PHP_URL_HOST) ?? '');
@endphp
{{--
Link preview — a rich Open Graph card for a URL. The whole card is a single
anchor (so the entire surface is the click target); it stacks on mobile and
lays the thumbnail beside the text from `sm` up. Falls back to a globe glyph
when no favicon is given and hides the media rail when no image is supplied.
--}}
<a
href="{{ $href }}"
data-slot="link-preview"
rel="noopener noreferrer"
{{ $attributes->merge(['class' => 'group flex flex-col overflow-hidden rounded-lg border border-border bg-card text-foreground shadow-sm transition-colors hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:flex-row']) }}
>
@if ($image)
<div class="aspect-video w-full shrink-0 overflow-hidden bg-muted sm:aspect-square sm:w-32">
<img src="{{ $image }}" alt="" loading="lazy" class="size-full object-cover transition-transform duration-300 group-hover:scale-105 motion-reduce:transform-none" />
</div>
@endif
<div class="min-w-0 flex-1 p-4">
<div class="flex items-center gap-2 text-xs text-muted-foreground">
@if ($favicon)
<img src="{{ $favicon }}" alt="" class="size-4 shrink-0 rounded-sm" loading="lazy" />
@else
<svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" class="size-4 shrink-0">
<circle cx="12" cy="12" r="9" />
<path d="M3 12h18M12 3a14 14 0 0 1 0 18 14 14 0 0 1 0-18Z" />
</svg>
@endif
<span class="truncate">{{ $domain }}</span>
</div>
<h3 class="mt-2 line-clamp-2 text-sm font-semibold leading-snug group-hover:underline">{{ $title }}</h3>
@if ($description)
<p class="mt-1 line-clamp-2 text-xs text-muted-foreground">{{ $description }}</p>
@endif
</div>
</a>
Ownership & lifecycle
Owner, release state, review evidence and adoption for this item.
- Owner
- Platform UI (@JoshJML)
- Current version
-
1.0.4 - Status
- Stable
- License
-
open - Accessibility reviewed
- No review date recorded
- Last breaking change
- No date recorded
- Deprecation
- Not deprecated
- Contract
-
v6 - Foundation
-
≥ 1.0.0