Search 71 components and 72 controllers by name, category or description.
Image Viewer
Windowed or full-viewport image viewer with zoom, pan, pinch, keyboard navigation, Turbo updates, a full-screen touch layout whose controls hide on tap, and optional side arrows, rotation, flips, thumbnails and original downloads
Image gallery
Zoom, rotate and mirror an image while keeping the original download unchanged. Tab moves between controls; arrow keys navigate the thumbnail strip.
<hw:image-viewer id="viewer-basic" label="Geometric studies" download thumbnails rotate flip arrows>
<div class="flex flex-wrap gap-3">
@include('components-demo.examples.image-viewer.images')
</div>
</hw:image-viewer>
Full viewport
Give the image more room with size="full". Explore 18 images with side arrows, a scrollable thumbnail strip and loop navigation.
<hw:image-viewer id="viewer-thumbnails-lab" label="Gallery with thumbnail navigation" size="full" thumbnails loop download rotate flip arrows>
<div class="flex flex-wrap gap-2">
@foreach (range(1, 18) as $index)
@php($media = ['grid', 'portrait', 'square'][($index - 1) % 3])
<a href="{{ route('components.image-viewer.asset', [$media, 'original']) }}" data-turbo="false" class="inline-block overflow-hidden rounded-md border">
<img
src="{{ route('components.image-viewer.asset', [$media, 'thumbnail']) }}"
data-original="{{ route('components.image-viewer.asset', [$media, 'original']) }}"
data-image-key="composition-{{ $index }}"
data-caption="Geometric composition {{ $index }} of 18"
data-download-url="{{ route('components.image-viewer.download', $media) }}"
alt="Geometric composition {{ $index }}"
class="h-16 w-20 object-cover"
loading="lazy"
>
</a>
@endforeach
</div>
</hw:image-viewer>
Long captions
Keep descriptions and credits beside the image. Longer text stays readable and scrolls above the thumbnail strip.
@php
$longCaption = 'Teal grid study — composition notes and credits. '.str_repeat(
'Fine lines meet at a circular focal point, balancing repetition with open space. '
.'A restrained palette keeps attention on the geometry and the relationship between the shapes. '
.'This illustration is part of a series of landscape, portrait and square compositions. ',
14,
).'Created for the Laravel Hotwire playground.';
$captions = [
'grid' => $longCaption,
'portrait' => 'An unusually long identifier: '.str_repeat('LongUnbrokenIdentifier0123456789', 20),
];
@endphp
<hw:image-viewer id="viewer-long-caption" label="Long caption examples" download>
<div class="flex flex-wrap gap-3">
@include('components-demo.examples.image-viewer.images', ['images' => ['grid', 'portrait'], 'captions' => $captions])
</div>
</hw:image-viewer>
Live gallery updates
Choose an update, then open an image. Turbo refreshes the gallery without closing a retained image.
<div
data-controller="image-viewer-demo"
data-image-viewer-demo-url-value="{{ route('components.image-viewer.changes') }}"
data-action="image-viewer:opened->image-viewer-demo#schedule image-viewer:closed->image-viewer-demo#cancel"
class="space-y-4"
>
<label class="grid max-w-sm gap-2 text-sm">
Update the gallery after opening
<select data-image-viewer-demo-target="mode" class="rounded-md border border-input bg-background px-3 py-2">
<option value="">No automatic update</option>
<option value="reversed">Reverse the image order</option>
<option value="changed">Replace the landscape image</option>
<option value="removed">Remove the landscape image</option>
<option value="empty">Empty the gallery and close</option>
<option value="added">Add another image</option>
<option value="base">Restore the gallery</option>
</select>
</label>
<div class="flex flex-wrap items-center gap-3">
<hw:button type="button" variant="outline" data-action="image-viewer-demo#restore">Restore gallery</hw:button>
<span role="status" data-image-viewer-demo-target="status" class="text-sm text-muted-foreground"></span>
</div>
<hw:image-viewer id="viewer-live" label="Live gallery" download thumbnails rotate flip arrows>
<div id="viewer-live-items" class="flex flex-wrap gap-3">
@include('components-demo.examples.image-viewer.images')
</div>
</hw:image-viewer>
</div>
Inside a Modal
Explore images without closing the surrounding dialog. Escape returns to it.
<hw:modal id="viewer-parent-modal" size="lg">
<hw:modal.trigger>Open parent Modal</hw:modal.trigger>
<hw:modal.content>
<hw:modal.header>
<hw:modal.title>Inspect an image without closing the parent</hw:modal.title>
<hw:modal.description>First Escape closes the viewer and returns focus to the thumbnail. Second Escape closes this Modal.</hw:modal.description>
</hw:modal.header>
<div class="p-4">
<hw:image-viewer id="viewer-in-modal" label="Photos inside Modal" download thumbnails rotate flip arrows>
<div class="flex flex-wrap gap-3">@include('components-demo.examples.image-viewer.images')</div>
</hw:image-viewer>
</div>
</hw:modal.content>
</hw:modal>
Inside a Dropdown
Open a gallery from a menu, then return to the same image link.
<hw:dropdown id="viewer-parent-dropdown" :close-on-select="false">
<hw:dropdown.trigger>Open image Dropdown</hw:dropdown.trigger>
<hw:dropdown.content width="w-80 max-w-[calc(100vw-2rem)]">
<div class="space-y-3 p-2">
<p class="text-sm text-muted-foreground">Explore the image, then close the viewer to return to this menu.</p>
<hw:image-viewer id="viewer-in-dropdown" label="Photos inside Dropdown" thumbnails rotate flip arrows>
@include('components-demo.examples.image-viewer.images', ['images' => ['grid']])
</hw:image-viewer>
</div>
</hw:dropdown.content>
</hw:dropdown>
Inside a Turbo Frame
Load another gallery into a frame and open its images without a full-page reload.
<turbo-frame id="viewer-demo-frame">
<div class="space-y-4">
<hw:button as="a" :href="route('components.image-viewer.frame')" variant="outline">Replace this Frame</hw:button>
<hw:image-viewer id="viewer-in-frame" label="Photos inside Turbo Frame" download thumbnails rotate flip arrows>
<div class="flex flex-wrap gap-3">@include('components-demo.examples.image-viewer.images')</div>
</hw:image-viewer>
</div>
</turbo-frame>
Unavailable and small images
An unavailable original shows a clear error. Small originals keep their natural size until you choose to zoom.
<hw:image-viewer id="viewer-errors" label="Broken and small originals">
<div class="flex flex-wrap gap-3">
<a href="{{ route('components.image-viewer.asset', ['missing', 'original']) }}" data-turbo="false" class="inline-block w-36 rounded-lg border">
<img src="{{ route('components.image-viewer.asset', ['grid', 'thumbnail']) }}" alt="Intentionally broken original" class="h-28 w-full object-cover">
</a>
<a href="{{ route('components.image-viewer.asset', ['grid', 'thumbnail']) }}" data-turbo="false" class="inline-block w-36 rounded-lg border">
<img src="{{ route('components.image-viewer.asset', ['grid', 'thumbnail']) }}" alt="Small original is not enlarged at fit" class="h-28 w-full object-cover">
</a>
</div>
</hw:image-viewer>