Display <hw:attachment>
View examples

Attachment

Composable file attachment primitive with media, metadata, state, actions and an optional full-card trigger. It is used by <hw:file-upload> and can be used directly for server-rendered upload lists.

Usage

BLADE
<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>

Group

BLADE
<hw:attachment.group>
    <hw:attachment>...</hw:attachment>
    <hw:attachment>...</hw:attachment>
</hw:attachment.group>

Image Media

BLADE
<hw:attachment orientation="vertical">
    <hw:attachment.media variant="image">
        <img src="{{ $photo->url }}" alt="{{ $photo->name }}">
    </hw:attachment.media>
    <hw:attachment.content>
        <hw:attachment.title>{{ $photo->name }}</hw:attachment.title>
        <hw:attachment.description>Uploaded · {{ $photo->size }}</hw:attachment.description>
    </hw:attachment.content>
</hw:attachment>

States

uploading and processing apply a lightweight CSS shimmer to the title. error switches the card to the destructive treatment; keep the failure reason in attachment.description so the state is not conveyed by color alone.

The shimmer motion is also available as the CSS hook data-shimmer="true" for package or app UI that needs the same text shimmer without introducing another component. Under prefers-reduced-motion, the foundation stops the animation and Nova restores the inherited text color without the gradient so the label remains legible.

Props

Component Prop Default Description
attachment state done idle, uploading, processing, error, done.
attachment size default default, sm, xs.
attachment orientation horizontal horizontal or vertical.
attachment.media variant icon icon or image.
attachment.action variant ghost Button variant.
attachment.action size icon-xs Button size.
attachment.action as button Root element: button or a.
attachment.action type button Native button type: button, submit, or reset.
attachment.action frame null Turbo Frame target for the action or its owning form submission.
attachment.trigger as button Root element: button, a, div, or span.
attachment.trigger type button Native button type: button, submit, or reset.
attachment.trigger frame null Turbo Frame target when the trigger renders as a link.

Components

Component Element Slot
attachment.group div attachment-group
attachment div attachment
attachment.media div attachment-media
attachment.content div attachment-content
attachment.title span attachment-title
attachment.description p attachment-description
attachment.actions div attachment-actions
attachment.action button or a attachment-action
attachment.trigger configurable attachment-trigger

Accessibility

attachment.group renders role="list". Use list-compatible children such as attachment cards with role="listitem" when you build a fully semantic list.

Label icon-only attachment.action buttons with aria-label. The action defaults to type="button"; if you turn it into a submit button or wire it to a destructive form action, include Laravel's normal CSRF field/method spoofing in the owning form. If attachment.trigger covers the card, give it an aria-label that explains what it opens. A trigger rendered as span is not focusable unless you add the appropriate tabindex and keyboard handling yourself.

Attachment trigger as values are trimmed, lowercased, and validated; unsupported tags are rejected. Attachment actions delegate to Button and therefore render as button or a. Disabled attachment anchors omit href and frame metadata and receive aria-disabled="true" and tabindex="-1".

For triggers and actions, frame accepts strings or objects resolved with dom_id(); null, false, empty, and whitespace-only values are omitted. Explicit data-turbo-frame wins and can be bound to false to suppress the prop.

Styling hooks

The component exposes stable data-slot hooks for preset and application CSS:

  • data-slot="attachment"
  • data-slot="attachment-group"
  • data-slot="attachment-media"
  • data-slot="attachment-content"
  • data-slot="attachment-title"
  • data-slot="attachment-description"
  • data-slot="attachment-actions"
  • data-slot="attachment-trigger"
  • data-slot="attachment-action"