Slug Input

Slug Input is a copy-paste React component that stops live url slug breaks links 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/slug-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

StopsLive URL slug breaks links

Was this component page useful?

How do I install Slug Input?

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

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

How do I use Slug Input in React?

slug-input-usage.tsx
import { SlugInput } from "@/components/ui/slug-input"

<SlugInput
  title={title}
  baseUrl="https://acme.com/blog/"
  publishedSlug="pricing-update"
  defaultValue="pricing-update-2026"
  checkAvailability={check}
/>

What input mistakes does Slug Input catch?

  • Lossy slugify (ß, é and similar), by transliterating first
  • Slugs already taken, with the next free one suggested
  • Edits to a published slug that would break links
  • Removing the redirect from the old slug
  • Slugs too long, cut at a word boundary

What props does Slug Input accept?

SlugInput props
PropTypeDefault
title

The title the slug follows until the user edits the slug (or it has been published).

string""
label

Visible label.

string"URL slug"
value

Controlled slug.

string—
defaultValue

Initial slug when uncontrolled. Defaults to the published slug, or one made from the title.

string—
onValueChange

Called with the slug on every change.

(value: string) => void—
baseUrl

Where the slug lives, e.g. "https://acme.com/blog/".

string"https://example.com/blog/"
publishedSlug

The slug that is live now. Changing away from it warns that links will break.

string—
keepRedirect

Controlled "keep a redirect from the old URL" choice.

boolean—
defaultKeepRedirect

Initial redirect choice when uncontrolled. On by default, like Shopify's pre-ticked box.

booleantrue
onKeepRedirectChange

Called when the redirect choice changes.

(keep: boolean) => void—
checkAvailability

Resolves `true` when the slug is free. Called after a pause in typing; stale answers are ignored.

(slug: string) => boolean | Promise<boolean>—
maxLength

Most characters in a slug.

number60
breaksLinksText

Warning after a published slug changes; `{path}` is the old path.

string"Changing this breaks links to {path}."
redirectLabel

Label of the redirect checkbox; `{path}` is the old path.

string"Redirect {path} to the new URL"
noRedirectText

Shown when the redirect is unticked; `{path}` is the old path.

string"Visitors to {path} will get a 404."
restoreLabel

Label of the one-tap fix that restores the published slug.

string"Keep the old slug"
takenText

Shown when `checkAvailability` says the slug is taken.

string"That URL is already used."
useSuggestionLabel

Label of the fix that applies the next free slug; `{slug}` is filled in.

string"Use {slug}"
availableText

Shown when the slug is free.

string"Available"
checkingText

Shown while the check runs.

string"Checking…"
checkErrorText

Shown when the check fails.

string"Couldn't check if this URL is free."
fromTitleLabel

Label of the button that goes back to following the title.

string"Match the title"

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

How is Slug Input accessible?

  • Visible <label> on the input; status via aria-describedby
  • Availability and warnings render in a polite live region
  • Keep-redirect is a labelled checkbox; icons are aria-hidden

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

What are the limitations and server boundaries?

This is a UX guard rail. Enforce on the server: Enforce slug uniqueness with a database constraint and create the old→new redirect server-side.

  • Collision check depends on your checkAvailability
  • Transliteration covers Latin-script letters; other scripts are dropped
  • Creating the redirect is your server's job

What expensive mistakes does Slug Input stop?

Live URL slug breaks links

Also known as

slug · permalink · url slug · blog post · cms · seo url · handle · redirect

Field type

What dependencies does Slug Input require?

Slug Input facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameSlug Input
Registry identifier@bollard/slug-input
Install commandnpx shadcn@latest add @bollard/slug-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 Slug Input

What form validation mistake does Slug Input catch?

Slug Input prevents live URL slug breaks links. Keeps URL slugs clean and stable: proper transliteration, a full-URL readback, collision checks, and a warning before editing a live slug. Catches: Lossy slugify (ß, é and similar), by transliterating first, Slugs already taken, with the next free one suggested, Edits to a published slug that would break links, Removing the redirect from the old slug, Slugs too long, cut at a word boundary. Limitation: validate slug-input schemas on backend.

How do I install slug-input with shadcn?

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

What props customize Slug Input?

Slug Input accepts `title`, `label`, `value`, `defaultValue`, `onValueChange`. Configures slug, permalink, url slug behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of slug-input?

Collision check depends on your checkAvailability. Transliteration covers Latin-script letters; other scripts are dropped. Creating the redirect is your server's job Server requirement: Enforce slug uniqueness with a database constraint and create the old→new redirect server-side.

How does Slug Input meet accessibility guidelines?

Visible <label> on the input; status via aria-describedby. Availability and warnings render in a polite live region. Keep-redirect is a labelled checkbox; icons are aria-hidden. Minimizes errors: slug collision, change slug broke links.

Which components pair with Slug Input?