Complete Example
This page walks through the key concepts behind the example Unsplash plugin — a reference implementation of a custom source with a search UI, activity header, and file picking.
Activity UI
The render function receives a host element — an empty container inside the uploader’s DOM. You build your activity UI by appending children to it. The uploader provides a set of CSS classes and built-in elements that automatically inherit the current theme.
You are not limited to web components or vanilla DOM. The host element is a regular DOM node, so you can mount a React component with createRoot(host).render(...), a Vue app with createApp(...).mount(host), a Svelte component, or anything else that can render into a DOM container. The example Unsplash plugin uses Lit for convenience, but any UI framework or library works.
Activity header
Activities typically include a header bar for navigation. Use the .uc-ui-activity-header class on a div with three direct children:
- Back button — an
.uc-ui-icon-btnthat callsuploaderApi.historyBack()to return to the previous screen. - Center slot — a
divcontaining an icon and a title. - Close button — an
.uc-ui-icon-btnthat callsuploaderApi.setModalState(false)to close the modal.
Use the built-in <uc-icon> element for icons. Built-in names like back and close are always available; plugin-registered icons (via registerIcon) are also accessible by name. Since <uc-icon> is a standard Web Component, it works in any framework — Lit templates, React JSX, Vue templates, etc.
Adding files to the upload list
When a user picks a photo, call uploaderApi.addFileFromUrl() to add it to the upload list. The uploader handles downloading, uploading, and progress tracking automatically. After adding the file, navigate the user to the upload list so they can see progress:
Other methods are available depending on what you have:
addFileFromObject()— forFileorBlobinstances.addFileFromUuid()— for files already uploaded to Uploadcare.addFileFromCdnUrl()— for existing Uploadcare CDN URLs.
Using a framework
The render function’s host is a plain DOM node. You can mount any framework into it and clean up in the returned function. For example, with React:
config.subscribe fires immediately with the current value and again on every change, so wrapping root.render inside it keeps the React tree in sync with config updates.
The same pattern applies to Vue (createApp(...).mount(host)), Svelte, Solid, or any other library that can render into a DOM container.
Usage
To expose this source in the picker, add unsplash to sourceList and pass the plugin:
See the example Unsplash plugin source for the complete implementation.