kliping.pro
  • Docs
  • Explore
  • Builder
  • Directory
  • Colors
  • Typeset
Saved
Docs
  • Sections13
  • Installation5
  • Dark Mode4
  • Forms3
  • Registry6
  • Utilities2
  • More10
  • Components137
  • Accordion
  • Action Bar
  • AI Chat
  • AI Thread List
  • Alert
  • Alert Dialog
  • Angle Slider
  • Animated Grid Pattern
  • Aspect Ratio
  • Attachment
  • Avatar
  • Avatar Group
  • Badge
  • Badge Overflow
  • Banner
  • Border Beam
  • Breadcrumb
  • Bubble
  • Button
  • Button Group
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Checkbox Group
  • Chip
  • Circular Progress
  • Client Only
  • Collapsible
  • Color Picker
  • Color Swatch
  • Combobox
  • Combobox Advanced
  • Command
  • Compare Slider
  • Composition
  • Context Menu
  • Cropper
  • Data Grid
  • Data Table
  • Data Table Advanced
  • Date Picker
  • Dialog
  • Direction Provider
  • Dot Pattern
  • Drawer
  • Dropdown Menu
  • Editable
  • Empty
  • Field
  • File Upload
  • Form
  • FPS
  • Gauge
  • Hitbox
  • Hover Card
  • Input
  • Input Group
  • Input OTP
  • Item
  • Kanban
  • Kbd
  • Kbd Advanced
  • Key Value
  • Label
  • List
  • Listbox
  • Logos
  • Map
  • Marker
  • Marquee
  • Mask Input
  • Masonry
  • Media Player
  • Mention
  • Menubar
  • Message
  • Message Scroller
  • Native Select
  • Navigation Menu
  • Number Field
  • Pagination
  • Particles
  • Pending
  • Phone Input
  • Pin Input
  • Popover
  • Portal
  • Presence
  • Progress
  • QR Code
  • Questionnaire
  • Radio Group
  • Range Calendar
  • Rating
  • Relative Time Card
  • Resizable
  • Responsive Dialog
  • Scroll Area
  • Scroll Spy
  • Scroller
  • Segmented Input
  • Select
  • Selection Toolbar
  • Separator
  • Sheet
  • Sidebar
  • Skeleton
  • Slider
  • Software Purchase Card
  • Sonner
  • Sortable
  • Speed Dial
  • Spinner
  • Stack
  • Stat
  • Status
  • Stepper
  • Stepper Advanced
  • Swap
  • Switch
  • Table
  • Tabs
  • Tags Input
  • Tags Input Advanced
  • Textarea
  • Time Picker
  • Timeline
  • Toast
  • Toggle
  • Toggle Group
  • Tooltip
  • Tour
  • Typography
  • Visually Hidden
  • Visually Hidden Input
  1. Docs
  2. Components
  3. Attachment

Attachment

PreviousNext

Menampilkan lampiran berupa berkas atau gambar, lengkap dengan media, metadata, status unggah, dan aksinya.

Workspace
workspace.pngPNG · 820 KB
Desk
desk-reference.jpgJPG · 1.1 MB
Office
office-reference.jpgJPG · 940 KB
sales-dashboard.pdfUploading · 64%
message-renderer.vueTypeScript · 12 KB

Komponen Attachment menampilkan lampiran berupa berkas atau gambar beserta media, nama, dan metadatanya, ditambah aksi dan status unggah kalau diperlukan. Cocok untuk berkas dan gambar di kolom penulisan chat, utas pesan, dan daftar unggahan.

Installation ​

pnpm dlx kliping@latest add attachment

Salin dan tempel kode sumber di GitHub ke project Anda.

Sesuaikan path import dengan struktur project Anda.

Usage ​

vue
<script setup lang="ts">
import { FileTextIcon, XIcon } from '@lucide/vue'
import {
  Attachment,
  AttachmentAction,
  AttachmentActions,
  AttachmentContent,
  AttachmentDescription,
  AttachmentMedia,
  AttachmentTitle,
} from '@/components/ui/attachment'
</script>

<template>
  <Attachment>
    <AttachmentMedia>
      <FileTextIcon />
    </AttachmentMedia>
    <AttachmentContent>
      <AttachmentTitle>sales-dashboard.pdf</AttachmentTitle>
      <AttachmentDescription>PDF · 2.4 MB</AttachmentDescription>
    </AttachmentContent>
    <AttachmentActions>
      <AttachmentAction aria-label="Remove sales-dashboard.pdf">
        <XIcon />
      </AttachmentAction>
    </AttachmentActions>
  </Attachment>
</template>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

Composition ​

Susunan berikut adalah cara membangun sebuah attachment:

text
Attachment
├── AttachmentMedia
├── AttachmentContent
│   ├── AttachmentTitle
│   └── AttachmentDescription
├── AttachmentActions
│   └── AttachmentAction
└── AttachmentTrigger

Pakai AttachmentGroup untuk menata beberapa lampiran dalam satu baris yang bisa digulir:

text
AttachmentGroup
├── Attachment
└── Attachment

Features ​

  • Media berupa ikon maupun gambar lewat AttachmentMedia.
  • Status unggah idle, uploading, processing, error, dan done, lengkap dengan style bawaan dan efek shimmer selagi berjalan.
  • Tiga pilihan ukuran, dengan orientasi mendatar atau tegak.
  • AttachmentTrigger seluas kartu yang membuka tautan atau dialog, tanpa mengganggu tombol aksi yang tetap bisa diklik sendiri.
  • AttachmentGroup yang bisa digulir dengan efek snap dan pudar di tepinya.
  • Style tiap bagian bisa disesuaikan lewat atribut class Vue.

Examples ​

Image ​

Isi variant="image" pada AttachmentMedia lalu taruh <img> di dalamnya. Pakai orientation="vertical" kalau medianya ingin ditumpuk di atas konten.

Workspace
workspace.pngPNG · 820 KB
Desk
desk-reference.jpgJPG · 1.1 MB
Office
office-reference.jpgJPG · 940 KB

Status ​

Isi state sesuai tahapan unggahnya. uploading dan processing membuat judulnya berkilat, sedangkan error mengubah tampilannya jadi bernuansa peringatan.

selected-file.pdfReady to upload
design-system.zipUploading · 64%
market-research.pdfProcessing document
financial-model.xlsx Upload failed. Try again.
uploaded-report.pdfUploaded · 1.8 MB

Ukuran ​

Pakai size untuk berpindah antara default, sm, dan xs.

Default attachmentPDF · 2.4 MB
Small attachmentPDF · 2.4 MB
Extra small attachment

Grup ​

Bungkus beberapa lampiran dengan AttachmentGroup untuk menatanya dalam satu baris mendatar yang bisa digulir, dengan efek snap dan pudar di tepinya.

briefing-notes.pdfPDF · 1.4 MB
workspace.png
workspace.pngPNG · 820 KB
customers.csvCSV · 18 KB
renderer.vueVue · 12 KB

Trigger ​

Tambahkan AttachmentTrigger supaya seluruh kartu bisa membuka tautan atau dialog. Ia mengisi kartu di belakang tombol aksi, jadi tombolnya tetap bisa diklik.

research-summary.pdfOpen preview dialog
vue
<template>
  <Dialog>
    <Attachment>
      <!-- media, content, actions -->
      <DialogTrigger as-child>
        <AttachmentTrigger aria-label="Preview research-summary.pdf" />
      </DialogTrigger>
    </Attachment>
    <DialogContent>
      <!-- ... -->
    </DialogContent>
  </Dialog>
</template>
1
2
3
4
5
6
7
8
9
10
11
12
13

Accessibility ​

AttachmentAction menghasilkan Button, sedangkan AttachmentTrigger menghasilkan <button> sungguhan (atau elemen Anda sendiri lewat as-child). Ikuti panduan di bawah agar keduanya bisa dioperasikan dan dibacakan dengan benar.

Beri label pada aksi yang hanya berupa ikon ​

AttachmentAction biasanya hanya berupa ikon, jadi berilah masing-masing aria-label yang menjelaskan aksinya dan sasarannya.

vue
<template>
  <AttachmentAction aria-label="Remove sales-dashboard.pdf">
    <XIcon />
  </AttachmentAction>
</template>
1
2
3
4
5

Beri label pada trigger ​

AttachmentTrigger menutupi seluruh kartu tanpa teks sendiri, jadi berilah aria-label yang menjelaskan apa yang terjadi saat ia diaktifkan.

vue
<template>
  <AttachmentTrigger as-child>
    <a
      :href="url"
      target="_blank"
      rel="noreferrer"
      aria-label="Open workspace.png"
    />
  </AttachmentTrigger>
</template>
1
2
3
4
5
6
7
8
9
10

Trigger-nya berada di belakang tombol aksi dalam urutan tumpukan, jadi AttachmentAction dan AttachmentTrigger tidak saling menghalangi — keduanya tetap bisa di-focus dan diklik secara terpisah.

Menggulir lewat keyboard ​

AttachmentGroup bergulir mendatar. Kalau lampirannya interaktif — punya trigger atau tombol aksi — pengguna keyboard bisa menjangkau item di luar layar lewat tombol Tab. Untuk deretan lampiran yang hanya bersifat tampilan, buat grupnya sendiri bisa di-focus dan digulir dengan menambahkan tabindex="0", role="group", dan aria-label.

Makna yang tidak bergantung warna ​

Status error memakai warna peringatan. Cantumkan alasan kegagalannya di AttachmentDescription supaya maknanya tidak bergantung pada warna semata.

Requirements ​

Semua dipasang otomatis oleh kliping add; tabel ini untuk Anda yang memasang manual atau memeriksa project.

RequirementValue
ProjectVue 3.5+, Tailwind CSS v4, alias @ — disiapkan kliping init
npm packagesclass-variance-authority@^0.7.1, reka-ui@^2.10.3
Kliping itemsbutton
Filescomponents/ui/attachment/attachment.vue
components/ui/attachment/attachment-action.vue
components/ui/attachment/attachment-actions.vue
components/ui/attachment/attachment-content.vue
components/ui/attachment/attachment-description.vue
components/ui/attachment/attachment-group.vue
components/ui/attachment/attachment-media.vue
components/ui/attachment/attachment-title.vue
components/ui/attachment/attachment-trigger.vue
components/ui/attachment/index.ts

Anatomy ​

Susunan bagiannya seperti dipakai di contoh-contoh di atas. Impor semua bagian dari satu tempat, lalu susun begini:

vue
<AttachmentGroup>
  <Attachment>
    <AttachmentMedia />
    <AttachmentContent>
      <AttachmentTitle />
      <AttachmentDescription />
    </AttachmentContent>
    <AttachmentActions>
      <AttachmentAction />
    </AttachmentActions>
    <AttachmentTrigger />
  </Attachment>
</AttachmentGroup>
<Attachment>
  <AttachmentMedia />
  <AttachmentContent>
    <AttachmentTitle />
    <AttachmentDescription />
  </AttachmentContent>
  <AttachmentActions>
    <AttachmentAction />
  </AttachmentActions>
  <AttachmentTrigger />
</Attachment>

API Reference ​

Attachment ​

Wadah terluar attachment.

PropTypeDefaultDescription
size?"default" | "sm" | "xs""default"The attachment size.
orientation?"vertical" | "horizontal""horizontal"Lay the media beside or above the content.
state?"done" | "idle" | "uploading" | "processing" | "error""done"The upload state. Drives styling and the shimmer.
SlotProps
#default—
Data attributeValue
[data-slot]"attachment"
[data-state]"done" | "idle" | "uploading" | "processing" | "error"
[data-size]"default" | "sm" | "xs"
[data-orientation]"vertical" | "horizontal"

AttachmentMedia ​

Slot media untuk ikon atau pratinjau gambar.

PropTypeDefaultDescription
variant?"icon" | "image"—Whether the media holds an icon or an <img>.
SlotProps
#default—
Data attributeValue
[data-slot]"attachment-media"
[data-variant]"icon" | "image"

AttachmentContent ​

Membungkus judul dan keterangan.

SlotProps
#default—
Data attributeValue
[data-slot]"attachment-content"

AttachmentTitle ​

Nama lampirannya. Berkilat selagi statusnya uploading atau processing.

SlotProps
#default—
Data attributeValue
[data-slot]"attachment-title"

AttachmentDescription ​

Metadata tambahan seperti tipe berkas, ukuran, atau status unggah.

SlotProps
#default—
Data attributeValue
[data-slot]"attachment-description"

AttachmentActions ​

Wadah untuk satu atau beberapa aksi, diratakan ke sisi akhir lampiran.

SlotProps
#default—
Data attributeValue
[data-slot]"attachment-actions"

AttachmentAction ​

Tombol aksi. Menghasilkan Button dan menerima atribut Vue yang diteruskan, misalnya aria-label.

PropTypeDefaultDescription
variant?"default" | "destructive" | "ghost" | "outline" | "secondary" | "link""ghost"The button variant.
size?"default" | "sm" | "xs" | "icon-xs" | "lg" | "icon" | "icon-sm" | "icon-lg""icon-xs"The button size.
asChild?boolean—Change the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details.
as?AsTag | Component—The element or component this component should render as. Can be overwritten by asChild.
SlotProps
#default—
Data attributeValue
[data-slot]"attachment-action"

AttachmentTrigger ​

Lapisan seluas kartu yang mengaktifkan lampiran. Menghasilkan <button> secara bawaan dan menerima atribut Vue yang diteruskan, misalnya aria-label.

PropTypeDefaultDescription
asChild?boolean—Change the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details.
as?AsTag | Component"button"The element or component this component should render as. Can be overwritten by asChild.
SlotProps
#default—
Data attributeValue
[data-slot]"attachment-trigger"

AttachmentGroup ​

Menata lampiran dalam satu baris mendatar yang bisa digulir dengan efek snap.

SlotProps
#default—
Data attributeValue
[data-slot]"attachment-group"

CSS Variables ​

Token tema yang dibaca komponen ini — ubah nilainya di CSS global (:root dan .dark, lihat Theming) untuk mengubah tampilannya tanpa menyentuh komponennya: --border, --card, --card-foreground, --destructive, --foreground, --muted, --muted-foreground, --radius, --ring.

PreviousAspect RatioNext Avatar

On This Page

InstallationUsageCompositionFeaturesExamplesImageStatusUkuranGrupTriggerAccessibilityBeri label pada aksi yang hanya berupa ikonBeri label pada triggerMenggulir lewat keyboardMakna yang tidak bergantung warnaRequirementsAnatomyAPI ReferenceAttachmentAttachmentMediaAttachmentContentAttachmentTitleAttachmentDescriptionAttachmentActionsAttachmentActionAttachmentTriggerAttachmentGroupCSS Variables

© 2026 Kliping. Free components are open source under the MIT License.

LicenseCreditsRoadmap