Skip to content
NewYour data: charts, lists and meters that take your records
<px-upload>Custom elementMoments

Pixel upload

Upload drop zone where the file icon dissolves pixel by pixel into the progress bar, which regroups into a check; oversized files shake red.

View as Markdown
<px-upload>

Tryboth buttons, or drop a file onto the zone.

Demo data

Nothing is uploaded and the progress is simulated; the file name and size come from the chosen file and limit-mb can be set. It cannot show your own data yet, so use it as a template: replace the invented data in its source before it shows anything real. See Your data.

Playground

Change a prop and the component updates. Props marked live animate to the new value; the others rebuild the element.

Loading <px-upload>
Props
limit-mbremounts
<PxUpload limitMb={30} />

Installation

pnpm dlx shadcn@latest add @lumesec/px-upload
First timeRegister the @lumesec registry once, or install by URL

Adds @lumesec to your components.json:

pnpm dlx shadcn@latest registry add @lumesec=https://elements.lumesec.ai/r/{name}.json

Or skip the setup and install by URL:

npx shadcn@latest add https://elements.lumesec.ai/r/px-upload.json

Usage

import { PxUpload } from "@/components/lumesec/px-upload";

export function Example() {
  return (
    <PxUpload />
  );
}

Behaviour

The file icon dissolves from its corner, and each pixel arcs down into the progress bar. When it fills, the bar regroups into a check; files over the limit turn red and shake. Real files work too.

API reference

Attributes

limit-mbReact proplimitMbTypenumberDefault30

Size limit in megabytes (1 MB = 1,000,000 bytes); a missing, invalid or non-positive value uses 30. Read each time a file is started.

Events

Events bubble and cross the shadow boundary unless the description says otherwise.

errorReact proponErrorDetail{ name: string, size: number }

Fires when a file is over the limit. size is in bytes. Does not bubble, so it never reaches the window's global error handlers; listen on the element.

uploadedReact proponUploadedDetail{ name: string, size: number }

Fires when the simulated upload completes. size is in bytes.

Methods

Call them on the element, for example through a React ref.

start(name: string, size: number)

Runs the upload animation for a file of size bytes. Ignored unless the component is idle, and for a size that is not a finite number of at least 0.

reset()

Returns to the idle drop zone. After a success the check flies back into the file icon.

Properties

limit (read-only)Typenumber

The size limit in bytes, from limit-mb; 30 MB when it is missing, invalid or not positive.

Keyboard

KeysAction
Enter / Space (on the drop zone)Open the file picker while idle.

Accessibility

  • The drop zone is focusable with role="button" and aria-label="Upload a file: click or drop".
  • The status line ("Uploading …", "Uploaded", "Over the 30 MB limit") sits in the drop zone and is repeated in a visually hidden aria-live="polite" region beside it, because assistive technology does not read the content of a button.
  • "Use a sample file" and "Try a 48 MB file" are native buttons.
  • Reduced motion: the icon does not bob, the border does not march, an error does not shake and pixels jump to the bar and the check instead of arcing.

Theming

The element reads your shadcn theme tokens through its shadow root, so light and dark follow your theme. The accent comes from --lumesec. See Theming.

This component reads --destructive, --foreground, --lumesec, --lumesec-success and --muted-foreground.

To restyle only LumeSec elements, set the matching --ui-* overrides: --ui-accent, --ui-danger, --ui-fg, --ui-mono, --ui-muted and --ui-ok.

Notes

  • Nothing is sent over the network. A chosen or dropped file is used only for its name and size, and progress is simulated over 1.6 to 3.4 seconds depending on size.
  • The two demo buttons start a 2.4 MB sample and a 48.2 MB file that exceeds the default limit. Only the first file of a drop is used.
  • The host carries data-state="uploading", "error" or "done", and returns to idle 2.6 seconds after an error and 2.8 seconds after success.
  • The drop zone is 178px tall.

Was this page helpful?