Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Input Group examples · Label

Inline Labels Input Group for React

A username input after an @ label and a price input after a $ label.

Framework
UI library

Short prefixes that are part of the value's meaning: @ before a username and $ before a price. Each prefix is a Label in a default inline-start addon, so clicking it focuses its input.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

FAQ

How does the prefix sit before the input?

The addon keeps the default align, inline-start, while the code keeps the input first.

Why is the prefix a Label?

With htmlFor pointing at the input's id, a click on @ or $ focuses the field.

What do screen readers call the fields?

Username and Price, from their aria-labels, which are clearer than @ or $ alone.

How is the price input set up?

type="text" with inputMode="decimal", which shows a numeric keyboard with a decimal point and keeps the value as typed.

Can I use plain text instead of a Label?

Yes: InputGroupText in the addon, as in Currency Input. A click still focuses the input, through the addon.

Does the prefix follow right-to-left text?

Yes. inline-start is the start of the line in either direction.