Skip to content

shadcn.io is an independent project built on shadcn/ui

Free

Disabled Input for Svelte

A disabled Account ID field showing ACC-12345, with a line under it that says the field cannot be edited.

UI library: Ark UI

Account ID shows ACC-12345 and the field is disabled. A line under it says this field cannot be edited. The control looks dimmed.

Use it for an id people should see but not change, and say why. If they must copy it, or the form must send it, a read-only Input stays available. In Svelte, Ark UI leaves this disabled value out of the submit.

Preview

Preview width

Installation

MCP · Pro
Make your AI a shadcn expert
Your agent installs components, builds pages and restyles your app from one prompt, in Claude Code, Cursor or VS Code.
Part of Pro

Anatomy

Input anatomy: input, placeholder, value, caret

Usage

<Field class="w-full max-w-sm" disabled><FieldLabel>Account ID</FieldLabel><Input class="bg-background" defaultValue="ACC-12345" type="text" /><FieldDescription>This field cannot be edited.</FieldDescription></Field>

FAQ

What does disabling the field do?

The input can't be focused or edited, it's skipped by Tab, and it's left out of the form's submitted data. It's dimmed with disabled:opacity-50 and shows a not-allowed cursor.

Where is disabled set?

On Field, which disables the input inside it.

How is the account ID shown?

As the input's default value, ACC-12345. The field is disabled, so it never changes and needs no change handler.

When should I use readOnly instead?

When people should still focus, select and copy the value, or when the form must submit it. A read-only field stays in the tab order and in the submitted data; a disabled one does neither.

What does the line under the field do?

It's a FieldDescription that says This field cannot be edited. Saying why a field is locked helps more than the dimmed style alone.

How is Account ID tied to the field?

Clicking the label focuses the field, and screen readers announce it with the field. Field links FieldLabel to the input inside it, so there is no id to match.

API Reference

Field

Sets disabled. The rest is on the Field page.

Input

Sets defaultValue="ACC-12345" and type="text". The rest is on the Input page.