Version Range Input

Version Range Input is a copy-paste React component that stops semver range installs the wrong version 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/version-range-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

StopsSemver range installs the wrong version

Was this component page useful?

How do I install Version Range Input?

pnpm dlx shadcn@latest add @bollard/version-range-input

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

How do I use Version Range Input in React?

version-range-input-usage.tsx
import { VersionRangeInput } from "@/components/ui/version-range-input"

<VersionRangeInput label="react" defaultValue="^18.2.0" versions={react} />

What input mistakes does Version Range Input catch?

  • Ranges that match no published version
  • ^0.x and ^0.0.x, which lock to a minor or patch
  • A hyphen range without spaces
  • Commas used where npm expects spaces (AND)
  • Latest version falling outside the range
  • Which version npm would install

What props does Version Range Input accept?

VersionRangeInput props
PropTypeDefault
label

Visible label.

string"Version range"
value

Controlled value.

string—
defaultValue

Initial value when uncontrolled.

string""
onValueChange

Called with the text on every change.

(value: string) => void—
versions

Published versions to test the range against. Invalid entries are ignored.

string[][]
delay

Pause in ms before warnings appear while typing. Leaving the field shows them at once.

number500
describe

Turns a parsed range into words. Override to translate.

(sets: ComparatorSet[]) => stringdescribeRange
allowsText

Templates: `{range}`, `{allowed}`, `{token}`, `{version}`, `{count}`, `{total}` are filled in.

string"{range} allows {allowed}."
matchCountText

Count of matching versions.

string"{count} of {total} published versions match"
invalidText

Shown when the range can't be parsed.

string"That isn't a valid range."
andText

Warning when commas are used for AND.

string"npm ranges use a space for AND, not a comma or &&."
hyphenText

Warning for a hyphen range without spaces.

string"{token} is a prerelease of one version, not a range."
zeroMinorText

Warning for ^0.x ranges.

string"{token} won't reach the next 0.x minor: below 1.0, every…
zeroPatchText

Warning for ^0.0.x ranges.

string"{token} allows only that one version: below 0.1, every p…
noMatchText

Shown when no published version matches.

string"No published version matches."
neverText

Shown when the range can never match.

string"This range can never match any version."
latestOutsideText

Shown when the latest version is outside the range.

string"Excludes the latest, {version}."
installsLabel

Badge on the version a fresh install would resolve to.

string"installs"
fixAriaLabel

Accessible label of a suggested-range fix button.

(fix: string) => string(fix) => `Use ${fix}`
versionsLabel

Accessible name of the published-versions list.

string"Published versions"
matchSrText

Screen-reader note on each listed version.

(matches: boolean) => string(matches) => (matches ? " matches" : " does not match")

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

How is Version Range Input accessible?

  • Visible <label>; aria-invalid with hint via aria-describedby
  • Hint in a polite live region; parse errors use role=alert
  • Versions list has an aria-label; each row states matches/does not match in text
  • Fix buttons have aria-labels

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

What are the limitations and server boundaries?

  • Implements node-semver default options; includePrerelease and loose modes are not modelled
  • Needs the published versions list you pass

What expensive mistakes does Version Range Input stop?

Semver range installs the wrong version

Also known as

semver · version range · package.json · caret · tilde · npm · dependencies · peer deps

Field type

What dependencies does Version Range Input require?

Version Range Input facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameVersion Range Input
Registry identifier@bollard/version-range-input
Install commandnpx shadcn@latest add @bollard/version-range-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 Version Range Input

What form validation mistake does Version Range Input catch?

Version Range Input prevents semver range installs the wrong version. Reads npm semver ranges back in plain English and shows which published versions match and which one installs. Catches: Ranges that match no published version, ^0.x and ^0.0.x, which lock to a minor or patch, A hyphen range without spaces, Commas used where npm expects spaces (AND), Latest version falling outside the range, Which version npm would install. Limitation: validate version-range-input schemas on backend.

How do I install version-range-input with shadcn?

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

What props customize Version Range Input?

Version Range Input accepts `label`, `value`, `defaultValue`, `onValueChange`, `versions`. Configures semver, version range, package.json behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of version-range-input?

Implements node-semver default options; includePrerelease and loose modes are not modelled. Needs the published versions list you pass Server requirement: backend verification for version-range-input.

How does Version Range Input meet accessibility guidelines?

Visible <label>; aria-invalid with hint via aria-describedby. Hint in a polite live region; parse errors use role=alert. Versions list has an aria-label; each row states matches/does not match in text. Fix buttons have aria-labels. Minimizes errors: caret range 0.x, semver range meaning.

Which components pair with Version Range Input?