2.0 beta — new releases can include breaking changes. Stable 1.x docs
dimah-s3v2.0.0-beta.0
Customization

Custom UI

Build bespoke upload interfaces using headless hooks and custom components.

Combine @dimah-s3/react hooks with your own components or custom shadcn primitives.

Preview

Example: Headless File Uploader

"use client";

import { useUpload } from "@dimah-s3/react";
import { Button } from "@/components/ui/button";

export function CustomFilePicker() {
  const upload = useUpload({ route: "avatar" });

  return (
    <div className="flex items-center gap-4">
      <input {...upload.getInputProps()} />
      <Button type="button" onClick={() => upload.open()}>
        {upload.isPending
          ? `Uploading ${upload.progress.percent}%`
          : "Choose file"}
      </Button>
    </div>
  );
}

Example: A part of your own

Inside Upload, useUploadContext() returns the root's hook. Build a part that sits next to UploadTrigger and UploadStatus:

"use client";

import { useUploadContext } from "@dimah-s3/ui";

export function UploadCount() {
  const { upload } = useUploadContext();
  const done = upload.files.filter((file) => file.phase === "success").length;

  if (upload.files.length === 0) return null;
  return (
    <p className="text-muted-foreground text-sm">
      {done} of {upload.files.length} uploaded
    </p>
  );
}

useDownloadContext() and useDeleteContext() do the same inside Download and Delete.

Frequently asked questions

On this page