Filename Input

Filename Input is a copy-paste React component that stops rename strips the file extension before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/filename-input
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsRename strips the file extension

Was this component page useful?

How do I install Filename Input?

pnpm dlx shadcn@latest add @bollard/filename-input

The files land in your project. They're yours to edit.

How do I use Filename Input in React?

filename-input-usage.tsx
import { FilenameInput } from "@/components/ui/filename-input"

<FilenameInput label="Rename Q3 report.pdf" originalName="Q3 report.pdf" defaultValue="Q3 report.docx" existingNames={folder} />

What input mistakes does Filename Input catch?

  • Extensions changed or removed, with undo
  • Characters Windows forbids
  • Reserved device names such as CON or NUL.txt
  • Trailing dots and spaces, and names over the byte limit
  • Names that differ from an existing file only in capitals

What props does Filename Input accept?

FilenameInput props
PropTypeDefault
label

Visible label.

string"Name"
value

Controlled file name.

string—
defaultValue

Initial file name when uncontrolled.

string""
onValueChange

Called with the new name and whether it has no errors (extension warnings don't count).

(name: string, valid: boolean) => void—
originalName

The name before renaming. Defaults to the first value. Escape restores it.

string—
existingNames

Other names already in the folder, compared without regard to case.

string[]NO_NAMES
maxBytes

Longest name in UTF-8 bytes.

number255
messages

Override any of the default messages.

Partial<typeof FILENAME_MESSAGES>—

* required. Also accepts the native props of <input> (className, aria-*, data-*…), passed through to it.

How is Filename Input accessible?

  • Visible <label>; aria-invalid and aria-describedby to an aria-live="polite" status
  • Escape restores the original name
  • Fixes return focus to the input

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

  • Follows Windows naming rules, the strictest common case; other systems allow more
  • Duplicate checks only cover the existingNames you pass

What validation rules apply to Filename Input?

Rules last verified:

Informational. Checked the reserved device names (including superscript-digit COM/LPT) and the rule against trailing spaces and periods. Copied components don't update themselves, so re-check after rule changes (see updating a component).

What expensive mistakes does Filename Input stop?

Rename strips the file extension

Also known as

filename · rename · file name · extension · upload · file manager · save as · download name

Field type

What dependencies does Filename Input require?

Filename Input facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameFilename Input
Registry identifier@bollard/filename-input
Install commandnpx shadcn@latest add @bollard/filename-input
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Filename Input

What form validation mistake does Filename Input catch?

Filename Input prevents rename strips the file extension. Selects only the base name when renaming and catches lost extensions and names Windows can't store, so a rename doesn't break a file. Catches: Extensions changed or removed, with undo, Characters Windows forbids, Reserved device names such as CON or NUL.txt, Trailing dots and spaces, and names over the byte limit, Names that differ from an existing file only in capitals. Limitation: validate filename-input schemas on backend.

How do I install filename-input with shadcn?

Run `npx shadcn@latest add @bollard/filename-input`. Sources added: registry/default/filename-input/filename-input.tsx, registry/default/filename-input/filename.ts. Package requirements: lucide-react.

What props customize Filename Input?

Filename Input accepts `label`, `value`, `defaultValue`, `onValueChange`, `originalName`. Configures filename, rename, file name behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of filename-input?

Follows Windows naming rules, the strictest common case; other systems allow more. Duplicate checks only cover the existingNames you pass Server requirement: backend verification for filename-input.

How does Filename Input meet accessibility guidelines?

Visible <label>; aria-invalid and aria-describedby to an aria-live="polite" status. Escape restores the original name. Fixes return focus to the input. Minimizes errors: rename removes extension, invalid filename characters.

Which components pair with Filename Input?