Media library table — Files block

Pro

files-media-library-table · for app pages

Media library table

A dense table when there are many files: a small preview, the name and folder, the kind, the weight, the date

Documentation

Installation

One command copies the block into your project with the shadcn CLI (the registry is set once: Installation).

pnpm dlx shadcn-vue@latest add @trame/files-media-library-table

Usage

Its demo data, shortened (Using blocks).

<script setup lang="ts">
import FilesMediaLibraryTable from '@/components/trame/blocks/files/files-media-library-table.vue'

const props = {
title: "Store media library",
items: [
{
id: "a1",
name: "leather-tote-04.jpg",
kind: "image",
src: "https://images.unsplash.com/photo-1657603738389-951c374b740c?w=1600&q=80",
alt: "A cognac leather shoulder bag on a light background",
path: "media/products/",
size: "2.4 MB",
dimensions: "2400 × 1600 px",
date: "Jun 24",
author: {
name: "Leah Fontaine"
},
uses: 4
},
{
id: "a2",
name: "patina-tote-01.jpg",
kind: "image",
src: "https://images.unsplash.com/photo-1473188588951-666fce8e7c68?w=1600&q=80",
alt: "A patinated brown leather bag resting on a stone block",
path: "media/products/",
size: "1.9 MB",
dimensions: "2000 × 1500 px",
date: "Jun 21",
author: {
name: "Leah Fontaine"
},
uses: 2
}
],
folders: [
{
id: "f1",
name: "Products",
count: 148,
action: "folder-products"
},
{
id: "f2",
name: "Workshop",
count: 46,
action: "folder-workshop"
}
],
kinds: [
{
value: "all",
label: "All",
count: 216
},
{
value: "image",
label: "Images",
count: 171
}
],
storage: "12.4 GB of 50 GB used",
upload: {
label: "Upload",
action: "media-upload"
},
open: "media-open"
}
</script>

<template>
<FilesMediaLibraryTable v-bind="props" />
</template>

Props

Each prop says who changes it: Words, Picture, Action, Design, Data.* required.

PropTypeDescription
title*stringWordswhat the library holds ("Shop media library")
items*Item[] | nullDatathe assets, with the details the app holds about each
foldersFolder[]Datathe folders at the top of the library
kindsKind[]the filter chips of the toolbar
storagestringWordswhat the library occupies, as the app writes it ("12.4 GB of 50 GB")
uploadUploadthe entry to add assets
openstringActionopens one asset
optionsOptionsthe block’s settings: layout choices and secondary words, read by every variant
Item items[] · 11 props
PropTypeDescription
id*string | numberDatathe asset’s id in the library
name*stringWordsthe file’s name ("leather-tote-04.jpg")
kind'image' | 'video' | 'document' | 'archive'what the file is: image, video, document or archive
srcstringPicturethe small preview the library serves
altstringWordswhat the picture shows
pathstringWordswhere it lives ("media/products/")
sizestringWordsits weight as the app writes it ("2.4 MB")
dimensionsstringWordsits pixel size ("2400 × 1600 px")
datestringWordsthe upload date as the app writes it
authorAuthorwho added the file
usesnumberon how many pages the app shows it
Author items[].author · 6 props
PropTypeDescription
idstring | numberDatathe record’s id in the tool that answers it
name*stringWordsthe person’s name
rolestringWordstheir role or job title
companystringWordswhere they work
avatarstringPicturea picture: a root-relative path (/media/…) or an absolute URL
urlstringDesigna page about them
Folder folders[] · 4 props
PropTypeDescription
id*string | numberDatathe folder’s id
name*stringWordsthe album or folder ("Products")
countnumberhow many assets it holds
action*stringActionopens that folder
Kind kinds[] · 3 props
PropTypeDescription
value*stringDesignthe kind’s value
label*stringWordswhat is read ("Pictures")
countnumberhow many assets of this kind
Upload upload · 2 props
PropTypeDescription
label*stringWordswhat happens ("Upload")
action*stringActionopens the upload flow
Options options · 3 props
PropTypeDescription
mood'inverse' | 'brand' | 'warm' | 'tint' | stringa band of the page that redefines the theme surfaces inside it
loadingstringWordswhat the page says while the tool answers ("Loading the media library")
selectLabelstringWordswhat picking a tile means ("Select")
What it asks your app for

The block never knows your app: it asks it, through one context provided once, where its links lead, what its actions do, how a price reads and which words to say (The host context).

MemberWhat it is for
hrefthe address an action leads to, or null to hide what leads there
actruns a change (subscribe, add to cart, save) and answers { ok } or { ok: false, error }
canwhether the page has this action
asseta picture’s address as your app serves it
Linkyour router’s link component
cartCountthe cart badge’s number
cartDrawerwhether your app has a cart drawer
cartOpenwhether the cart drawer is open
labelyour word for an interface key, or undefined to keep the block’s own

The words it says itself, in English and French; label(key) replaces any of them:

KeyEnglishFrench
newsletter.alreadyYou are already subscribed.Vous êtes déjà inscrit.
newsletter.doneDone: you are subscribed.C’est noté : vous êtes inscrit.
newsletter.invalidCheck the email address.Vérifiez l’adresse e-mail.
newsletter.tooManyToo many attempts, try again in a moment.Trop de tentatives, réessayez dans un moment.

Features

  • Every word in the server HTML
  • Same markup in Vue and React
  • Theme tokens only: every theme, light and dark
  • Shows what you give it, invents nothing
  • No motion; still under reduced motion
  • Real buttons and links, a visible focus
  • Asks your app through actions: folders[], upload, open
  • Reads files from your app

A files section, for app pages; it uses @lucide/vue, class-variance-authority, clsx, reka-ui, tailwind-merge.

More files blocks

  • Drop zone: a form that takes files by drop or choice within stated limits, then lists what was added.
  • Import mapping stepped: the import in numbered steps: match each column to a field, choose the duplicates to merge when there are any, review and send.
  • List browser: A file browser with list and grid views, using the merchant's own files only.
  • List links: A shared-file ledger with access and expiry, using the merchant's own system values only.
  • Recent dated list: A date-grouped reading list for returning to the merchant's own recently used files, in host order.
  • Recent event rail: An event rail with file details and actors, using the merchant's own recorded activity only.
  • Upload request panel: someone else must send files: a panel with the folder, the deadline and a link to copy.
  • Upload sources: files can also come from a link, a camera or a library: the zone plus a row of source buttons.

All 12 files blocks