Media library grid — Files block
Profiles-media-library-grid · for app pages
Media library grid
A wall of previews with a box on each to pick several assets at once, and the upload entry at hand
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-gridUsage
Its demo data, shortened (Using blocks).
<script setup lang="ts">
import FilesMediaLibraryGrid from '@/components/trame/blocks/files/files-media-library-grid.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>
<FilesMediaLibraryGrid v-bind="props" />
</template>Props
Each prop says who changes it: Words, Picture, Action, Design, Data.* required.
| Prop | Type | Description |
|---|---|---|
| title* | string | Wordswhat the library holds ("Shop media library") |
| items* | Item[] | null | Datathe assets, with the details the app holds about each |
| folders | Folder[] | Datathe folders at the top of the library |
| kinds | Kind[] | the filter chips of the toolbar |
| storage | string | Wordswhat the library occupies, as the app writes it ("12.4 GB of 50 GB") |
| upload | Upload | the entry to add assets |
| open | string | Actionopens one asset |
| options | Options | the block’s settings: layout choices and secondary words, read by every variant |
Item items[] · 11 props
| Prop | Type | Description |
|---|---|---|
| id* | string | number | Datathe asset’s id in the library |
| name* | string | Wordsthe file’s name ("leather-tote-04.jpg") |
| kind | 'image' | 'video' | 'document' | 'archive' | what the file is: image, video, document or archive |
| src | string | Picturethe small preview the library serves |
| alt | string | Wordswhat the picture shows |
| path | string | Wordswhere it lives ("media/products/") |
| size | string | Wordsits weight as the app writes it ("2.4 MB") |
| dimensions | string | Wordsits pixel size ("2400 × 1600 px") |
| date | string | Wordsthe upload date as the app writes it |
| author | Author | who added the file |
| uses | number | on how many pages the app shows it |
Author items[].author · 6 props
| Prop | Type | Description |
|---|---|---|
| id | string | number | Datathe record’s id in the tool that answers it |
| name* | string | Wordsthe person’s name |
| role | string | Wordstheir role or job title |
| company | string | Wordswhere they work |
| avatar | string | Picturea picture: a root-relative path (/media/…) or an absolute URL |
| url | string | Designa page about them |
Folder folders[] · 4 props
| Prop | Type | Description |
|---|---|---|
| id* | string | number | Datathe folder’s id |
| name* | string | Wordsthe album or folder ("Products") |
| count | number | how many assets it holds |
| action* | string | Actionopens that folder |
Kind kinds[] · 3 props
| Prop | Type | Description |
|---|---|---|
| value* | string | Designthe kind’s value |
| label* | string | Wordswhat is read ("Pictures") |
| count | number | how many assets of this kind |
Upload upload · 2 props
| Prop | Type | Description |
|---|---|---|
| label* | string | Wordswhat happens ("Upload") |
| action* | string | Actionopens the upload flow |
Options options · 3 props
| Prop | Type | Description |
|---|---|---|
| mood | 'inverse' | 'brand' | 'warm' | 'tint' | string | a band of the page that redefines the theme surfaces inside it |
| loading | string | Wordswhat the page says while the tool answers ("Loading the media library") |
| selectLabel | string | Wordswhat 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).
| Member | What it is for |
|---|---|
| href | the address an action leads to, or null to hide what leads there |
| act | runs a change (subscribe, add to cart, save) and answers { ok } or { ok: false, error } |
| can | whether the page has this action |
| asset | a picture’s address as your app serves it |
| Link | your router’s link component |
| cartCount | the cart badge’s number |
| cartDrawer | whether your app has a cart drawer |
| cartOpen | whether the cart drawer is open |
| label | your 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:
| Key | English | French |
|---|---|---|
| newsletter.already | You are already subscribed. | Vous êtes déjà inscrit. |
| newsletter.done | Done: you are subscribed. | C’est noté : vous êtes inscrit. |
| newsletter.invalid | Check the email address. | Vérifiez l’adresse e-mail. |
| newsletter.tooMany | Too 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
filesfrom your app
A files section, for app pages; it uses @lucide/vue, class-variance-authority, clsx, reka-ui, tailwind-merge.
More files blocks
- Device sync cards: Device status cards and folder sync controls, using the merchant's own sync states only.
- 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.