Skip to content
h v3.13.3
Search the docs
Find a component, section or page.

Attachment

Displays a file or image attachment with media, metadata, upload state, and actions.

Workspace
workspace.png PNG · 820 KB
Desk
desk-reference.jpg JPG · 1.1 MB
Office
office-reference.jpg JPG · 940 KB
sales-dashboard.pdf Uploading · 64%
message-renderer.tsx TypeScript · 12 KB

Installation

pnpm add @heyramzi/ui

Usage

import * as Attachment from "@heyramzi/ui/shadcn/attachment";
<Attachment.Root>
  <Attachment.Media variant="image">
    <img src="/workspace.png" alt="Workspace" />
  </Attachment.Media>
  <Attachment.Content>
    <Attachment.Title>workspace.png</Attachment.Title>
    <Attachment.Description>PNG · 820 KB</Attachment.Description>
  </Attachment.Content>
  <Attachment.Actions>
    <Attachment.Action aria-label="Remove workspace.png">×</Attachment.Action>
  </Attachment.Actions>
</Attachment.Root>

Keyboard and accessibility

Key Does
Tab Moves focus to the card's trigger, then to each action button.
Space Enter Runs the focused trigger or action.
  • Attachment.Trigger is a button stretched over the whole card. With no aria-label, it's named by the card's Attachment.Title.
  • An icon-only Attachment.Action with no aria-label reads "Remove", with the title as its description. Pass an aria-label for any other action.
  • The card shows a ring while anything inside it has focus.
  • Upload and error states are colour and shimmer only. Say the state in Attachment.Description so a screen reader hears it.

API reference

Attachment.Root

state "idle" | "uploading" | "processing" | "error" | "done"
Default "done"
size "default" | "sm" | "xs"
Default "default"
orientation "horizontal" | "vertical"
Default "horizontal"
ref bindable HTMLDivElement | null
Default null
class string
children Snippet
...rest
Every prop of HTMLAttributes<HTMLDivElement> from svelte/elements
Prop Type Default
state "idle" | "uploading" | "processing" | "error" | "done" "done"
size "default" | "sm" | "xs" "default"
orientation "horizontal" | "vertical" "horizontal"
ref bindable HTMLDivElement | null null
class string
children Snippet
...rest Every prop of HTMLAttributes<HTMLDivElement> from svelte/elements

Attachment.Group

ref bindable HTMLDivElement | null
Default null
class string
children Snippet
...rest
Every prop of HTMLAttributes<HTMLDivElement> from svelte/elements
Prop Type Default
ref bindable HTMLDivElement | null null
class string
children Snippet
...rest Every prop of HTMLAttributes<HTMLDivElement> from svelte/elements

Attachment.Media

variant "icon" | "image"
Default "icon"
ref bindable HTMLDivElement | null
Default null
class string
children Snippet
...rest
Every prop of HTMLAttributes<HTMLDivElement> from svelte/elements
Prop Type Default
variant "icon" | "image" "icon"
ref bindable HTMLDivElement | null null
class string
children Snippet
...rest Every prop of HTMLAttributes<HTMLDivElement> from svelte/elements

Attachment.Content

ref bindable HTMLDivElement | null
Default null
class string
children Snippet
...rest
Every prop of HTMLAttributes<HTMLDivElement> from svelte/elements
Prop Type Default
ref bindable HTMLDivElement | null null
class string
children Snippet
...rest Every prop of HTMLAttributes<HTMLDivElement> from svelte/elements

Attachment.Title

ref bindable HTMLSpanElement | null
Default null
class string
id string
Default getAttachmentTitleId()
children Snippet
...rest
Every prop of HTMLAttributes<HTMLSpanElement> from svelte/elements
Prop Type Default
ref bindable HTMLSpanElement | null null
class string
id string getAttachmentTitleId()
children Snippet
...rest Every prop of HTMLAttributes<HTMLSpanElement> from svelte/elements

Attachment.Description

ref bindable HTMLSpanElement | null
Default null
class string
children Snippet
...rest
Every prop of HTMLAttributes<HTMLSpanElement> from svelte/elements
Prop Type Default
ref bindable HTMLSpanElement | null null
class string
children Snippet
...rest Every prop of HTMLAttributes<HTMLSpanElement> from svelte/elements

Attachment.Trigger

child Snippet<[{ props: Record<string, unknown> }]>
ref bindable HTMLButtonElement | null
Default null
class string
type "button" | "submit" | "reset"
Default "button"
...rest
Every prop of HTMLButtonAttributes from svelte/elements
Prop Type Default
child Snippet<[{ props: Record<string, unknown> }]>
ref bindable HTMLButtonElement | null null
class string
type "button" | "submit" | "reset" "button"
...rest Every prop of HTMLButtonAttributes from svelte/elements

Attachment.Actions

ref bindable HTMLDivElement | null
Default null
class string
children Snippet
...rest
Every prop of HTMLAttributes<HTMLDivElement> from svelte/elements
Prop Type Default
ref bindable HTMLDivElement | null null
class string
children Snippet
...rest Every prop of HTMLAttributes<HTMLDivElement> from svelte/elements

Attachment.Action

variant "default" | "outline" | "ghost" | "destructive" | "text" | "dashed"
Default "ghost"
size "sm" | "default" | "lg"
Default "sm"
icon boolean
Default true
ref bindable HTMLButtonElement | HTMLAnchorElement | null
Default null
class string
aria-label HTMLButtonAttributes
...rest
Every prop of HTMLButtonAttributes from svelte/elements
...rest
Every prop of HTMLAnchorAttributes from svelte/elements
Prop Type Default
variant "default" | "outline" | "ghost" | "destructive" | "text" | "dashed" "ghost"
size "sm" | "default" | "lg" "sm"
icon boolean true
ref bindable HTMLButtonElement | HTMLAnchorElement | null null
class string
aria-label HTMLButtonAttributes
...rest Every prop of HTMLButtonAttributes from svelte/elements
...rest Every prop of HTMLAnchorAttributes from svelte/elements