Inputs

File Dropzone

A dropzone that stays a button: a real file input inside, so keyboard and phone work the same way.

  • input
  • file
  • upload
  • drag-and-drop

Preview

1440pxHost theme

Use it with AI

  1. 1. Copy the link.
  2. 2. Write to your agent in your own words and drop the link into the sentence.
  3. 3. The agent opens the link and installs the component from the registry.

put this in the header: https://vibeui.ru/c/file-001?lang=en

Show the full instructions

What the link says, spelled out. Use it when your agent cannot open links — paste this text instead.

# Install and place "file-001" (File Dropzone) from VibeUI

## 1. Install first — do not skip, do not recreate
Run this exact command before writing any code:
npx shadcn@latest add https://vibeui.ru/r/file-001.json

Registry item: https://vibeui.ru/r/file-001.json
Installs to: components/vibeui/file-001.tsx (the exact path follows this project's components.json aliases).
npm dependencies: none.
Registry dependencies: none.

Install it from the registry. Do not recreate it from the description,
do not substitute a similar component from another library, and do not
rewrite it to match the project's existing style.

## 2. What it is
A dropzone that stays a button: a real file input inside, so keyboard and phone work the same way.

An upload zone: drag and drop, click to choose, highlight while a file hovers and a list of picked files with sizes. Zero dependencies, one file.

## 3. How to use it
import { File001 } from "@/components/vibeui/file-001"

<File001 accept="image/png,image/jpeg" onChange={setFiles} />

Read the installed file for the full prop list.

## 4. Where to place it
This is a small inline component. Put it exactly where the user asked,
inside the existing markup. Do not create a new page, section or
wrapper for it. If a similar control already sits in that spot,
replace it instead of adding a second one.

Placement: ___
(The user fills this line in. If it is still blank, ask where to put it
instead of guessing.)

## 5. Keep exactly as installed
- the local --vibeui-file-001-* palette — do not swap it for your theme tokens
- the label with a hidden input: dragging is mouse-only, choosing must work for everyone
- preventing the default on dragover — otherwise the browser opens the file
- highlighting the zone while a file hovers: otherwise it is unclear whether to drop
- the list of picked files: without it nothing says what went through
- the formats and size limit beside the zone, not inside an error message

## 6. You may change
- label and hint
- accept — the formats you take
- the onChange handler
- the accent through the accent prop

## 7. Rules
- The component only picks files: upload, progress and errors belong to the caller.
- accept is a dialog hint, not protection: validate type and size on the server.
- The size limit in the copy validates nothing — it is text.
- Do not lift the CSS variables into globals.css: the component has to stay a single file.

## 8. Verify
- it renders with no console errors;
- it looks like the preview on the VibeUI page you copied this from;
- if it does not, you changed something listed in section 5 — put it back.

For developers

npx shadcn@latest add https://vibeui.ru/r/file-001.json
https://vibeui.ru/r/file-001.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-file-001-*. Клиентский: "use client". Зона — <label> со скрытым input type="file", поэтому выбор доступен без мыши. Обработчики dragover и drop отменяют стандартное поведение браузера, состояние наведения выносится в data-over. Список выбранного показывает имена и размеры.

Component source

The same file your agent installs. Here in case you would rather copy it by hand.

"use client"

import { useId, useState } from "react"
import type { ComponentPropsWithoutRef, CSSProperties, DragEvent } from "react"

export type File001Props = Omit<
  ComponentPropsWithoutRef<"div">,
  "children" | "onChange"
> & {
  label?: string
  hint?: string
  accept?: string
  onChange?: (names: string[]) => void
  accent?: string
}

// Идея компонента: зона перетаскивания, которая остаётся кнопкой. Перетащить
// файл можно только мышью — поэтому внутри настоящий input с типом file и
// подписью-label: с клавиатуры и с телефона всё работает так же. Список
// выбранного показывается сразу: без него непонятно, что именно улетело.
const STYLES = `
:where([data-vibeui-block="file-001"]){
--vibeui-file-001-bg:oklch(1 0 0);
--vibeui-file-001-fg:oklch(0.22 0.014 265);
--vibeui-file-001-muted:oklch(0.56 0.014 265);
--vibeui-file-001-border:oklch(0.86 0.008 265);
--vibeui-file-001-hover:oklch(0.97 0.003 265);
--vibeui-file-001-accent:oklch(0.55 0.17 265);
--vibeui-file-001-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="file-001"]{
display:flex;flex-direction:column;gap:0.5rem;
width:100%;max-width:22rem;box-sizing:border-box;
font-family:var(--vibeui-file-001-font);color:var(--vibeui-file-001-fg);
}
/* Зона — это label: клавиатура и телефон получают тот же выбор файла. */
[data-vibeui-block="file-001"] label{
position:relative;display:flex;flex-direction:column;align-items:center;gap:0.25rem;
padding:1.25rem 1rem;box-sizing:border-box;text-align:center;cursor:pointer;
border:1.5px dashed var(--vibeui-file-001-border);border-radius:0.875rem;
background:var(--vibeui-file-001-bg);
transition:border-color .16s ease,background-color .16s ease;
}
[data-vibeui-block="file-001"] label:hover{background:var(--vibeui-file-001-hover)}
[data-vibeui-block="file-001"][data-over="true"] label{
border-color:var(--vibeui-file-001-accent);
background:color-mix(in oklab,var(--vibeui-file-001-accent) 8%,oklch(1 0 0));
}
[data-vibeui-block="file-001"] label:has(input:focus-visible){outline:2px solid var(--vibeui-file-001-accent);outline-offset:2px}
[data-vibeui-block="file-001"] input{position:absolute;width:1px;height:1px;opacity:0}
[data-vibeui-block="file-001"] [data-part="arrow"]{
position:relative;width:1.5rem;height:1.5rem;margin-bottom:0.125rem;
}
[data-vibeui-block="file-001"] [data-part="arrow"]::before{
content:"";position:absolute;left:50%;top:0.125rem;width:2px;height:0.875rem;
margin-left:-1px;background:var(--vibeui-file-001-muted);border-radius:9999px;
}
[data-vibeui-block="file-001"] [data-part="arrow"]::after{
content:"";position:absolute;left:50%;top:0.1875rem;width:0.5rem;height:0.5rem;
margin-left:-0.25rem;
border-left:2px solid var(--vibeui-file-001-muted);
border-top:2px solid var(--vibeui-file-001-muted);
transform:rotate(45deg);
}
[data-vibeui-block="file-001"] [data-part="title"]{font-size:0.875rem;font-weight:650}
[data-vibeui-block="file-001"] [data-part="hint"]{font-size:0.75rem;line-height:1.4;color:var(--vibeui-file-001-muted)}
/* Список выбранного: без него непонятно, что именно улетело. */
[data-vibeui-block="file-001"] ul{display:flex;flex-direction:column;gap:0.25rem;margin:0;padding:0;list-style:none}
[data-vibeui-block="file-001"] li{
display:flex;align-items:center;justify-content:space-between;gap:0.5rem;
padding:0.4375rem 0.625rem;border-radius:0.5rem;
border:1px solid var(--vibeui-file-001-border);
font-size:0.8125rem;
}
[data-vibeui-block="file-001"] [data-part="size"]{color:var(--vibeui-file-001-muted);font-size:0.75rem;font-variant-numeric:tabular-nums}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="file-001"] *{animation:none!important;transition:none!important}}
`

/**
 * Зона перетаскивания на настоящем input type="file" с списком выбранного.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function File001({
  label = "Перетащите файлы сюда",
  hint = "PNG, JPG или PDF до 10 МБ. Можно выбрать несколько",
  accept = "image/png,image/jpeg,application/pdf",
  onChange,
  accent,
  className,
  style,
  ...props
}: File001Props) {
  const id = useId()
  const [over, setOver] = useState(false)
  const [files, setFiles] = useState<{ name: string; size: string }[]>([])

  const palette = {
    ...(accent ? { "--vibeui-file-001-accent": accent } : null),
    ...style,
  } as CSSProperties

  const take = (list: FileList | null) => {
    if (!list) return
    const next = Array.from(list).map((file) => ({
      name: file.name,
      size: `${Math.max(1, Math.round(file.size / 1024))} КБ`,
    }))
    setFiles(next)
    onChange?.(next.map((file) => file.name))
  }

  const onDrop = (event: DragEvent<HTMLDivElement>) => {
    event.preventDefault()
    setOver(false)
    take(event.dataTransfer.files)
  }

  return (
    <>
      <style href="vibeui-file-001" precedence="medium">
        {STYLES}
      </style>
      <div
        {...props}
        data-vibeui-block="file-001"
        data-over={over}
        className={className}
        style={palette}
        onDragOver={(event) => {
          event.preventDefault()
          setOver(true)
        }}
        onDragLeave={() => setOver(false)}
        onDrop={onDrop}
      >
        <label htmlFor={id}>
          <span data-part="arrow" aria-hidden="true" />
          <span data-part="title">{label}</span>
          <span data-part="hint">{hint}</span>
          <input
            id={id}
            type="file"
            multiple
            accept={accept}
            onChange={(event) => take(event.target.files)}
          />
        </label>
        {files.length ? (
          <ul>
            {files.map((file) => (
              <li key={file.name}>
                <span>{file.name}</span>
                <span data-part="size">{file.size}</span>
              </li>
            ))}
          </ul>
        ) : null}
      </div>
    </>
  )
}