View laravel-hotwire on GitHub
1M
v0.91.0
Search 71 components and 72 controllers by name, category or description.
Attachment
Composable file card with media, metadata, states, actions and an optional full-card trigger
Composition
Combine media, metadata and actions in a compact file card.
sales-dashboard.pdf
PDF - 2.4 MB
<hw:attachment state="done">
<hw:attachment.media>
<hw:icon name="copy" />
</hw:attachment.media>
<hw:attachment.content>
<hw:attachment.title>sales-dashboard.pdf</hw:attachment.title>
<hw:attachment.description>PDF - 2.4 MB</hw:attachment.description>
</hw:attachment.content>
<hw:attachment.actions>
<hw:attachment.action aria-label="Remove sales-dashboard.pdf">
<hw:icon name="x" />
</hw:attachment.action>
</hw:attachment.actions>
</hw:attachment>
States
Use idle, uploading, processing, error and done to reflect the file lifecycle.
brand-guide.pdf
Waiting to upload
campaign-video.mp4
Uploading - 64%
team-photo.jpg
Optimizing preview
budget.xlsx
Upload failed - Try again
release-notes.pdf
PDF - 1.2 MB
<div class="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
<hw:attachment state="idle" class="w-full">
<hw:attachment.media><hw:icon name="file-up" /></hw:attachment.media>
<hw:attachment.content>
<hw:attachment.title>brand-guide.pdf</hw:attachment.title>
<hw:attachment.description>Waiting to upload</hw:attachment.description>
</hw:attachment.content>
</hw:attachment>
<hw:attachment state="uploading" class="w-full">
<hw:attachment.media><hw:spinner /></hw:attachment.media>
<hw:attachment.content>
<hw:attachment.title>campaign-video.mp4</hw:attachment.title>
<hw:attachment.description>Uploading - 64%</hw:attachment.description>
</hw:attachment.content>
</hw:attachment>
<hw:attachment state="processing" class="w-full">
<hw:attachment.media><hw:spinner /></hw:attachment.media>
<hw:attachment.content>
<hw:attachment.title>team-photo.jpg</hw:attachment.title>
<hw:attachment.description>Optimizing preview</hw:attachment.description>
</hw:attachment.content>
</hw:attachment>
<hw:attachment state="error" class="w-full">
<hw:attachment.media><hw:icon name="alert-circle" /></hw:attachment.media>
<hw:attachment.content>
<hw:attachment.title>budget.xlsx</hw:attachment.title>
<hw:attachment.description>Upload failed - Try again</hw:attachment.description>
</hw:attachment.content>
</hw:attachment>
<hw:attachment state="done" class="w-full">
<hw:attachment.media><hw:icon name="check-circle" /></hw:attachment.media>
<hw:attachment.content>
<hw:attachment.title>release-notes.pdf</hw:attachment.title>
<hw:attachment.description>PDF - 1.2 MB</hw:attachment.description>
</hw:attachment.content>
</hw:attachment>
</div>
Sizes
Choose default, sm or xs based on the density of the surrounding interface.
Default
2.4 MB
Small
860 KB
Extra small
120 KB
<div class="flex flex-wrap items-center gap-3">
<hw:attachment>
<hw:attachment.media><hw:icon name="copy" /></hw:attachment.media>
<hw:attachment.content>
<hw:attachment.title>Default</hw:attachment.title>
<hw:attachment.description>2.4 MB</hw:attachment.description>
</hw:attachment.content>
</hw:attachment>
<hw:attachment size="sm">
<hw:attachment.media><hw:icon name="copy" /></hw:attachment.media>
<hw:attachment.content>
<hw:attachment.title>Small</hw:attachment.title>
<hw:attachment.description>860 KB</hw:attachment.description>
</hw:attachment.content>
</hw:attachment>
<hw:attachment size="xs">
<hw:attachment.media><hw:icon name="copy" /></hw:attachment.media>
<hw:attachment.content>
<hw:attachment.title>Extra small</hw:attachment.title>
<hw:attachment.description>120 KB</hw:attachment.description>
</hw:attachment.content>
</hw:attachment>
</div>
Image gallery
Use image media, vertical orientation and a full-card trigger for browsable galleries.
<hw:attachment.group class="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
@foreach ($images as $image)
<hw:attachment orientation="vertical" role="listitem">
<hw:attachment.media variant="image">
<img src="{{ $image['previewUrl'] }}" alt="{{ $image['alt'] }}" loading="lazy">
</hw:attachment.media>
<hw:attachment.content>
<hw:attachment.title>{{ $image['name'] }}</hw:attachment.title>
<hw:attachment.description>{{ $image['description'] }}</hw:attachment.description>
</hw:attachment.content>
<hw:attachment.actions>
<hw:attachment.action aria-label="Remove {{ $image['name'] }}">
<hw:icon name="x" />
</hw:attachment.action>
</hw:attachment.actions>
<hw:attachment.trigger
as="a"
:href="$image['url']"
target="_blank"
rel="noopener noreferrer"
aria-label="Open {{ $image['name'] }}"
data-turbo="false"
/>
</hw:attachment>
@endforeach
</hw:attachment.group>