Input
A Shadcn-styled single-line text input with controlled state, IME handling, and accessible labeling.
A single-line text input for forms and user data entry built on Base Input, providing controlled and uncontrolled value management, normalized IME composition events, disabled and read-only handling, and accessible naming. The examples on this page use the Shadcn Rhea style preset.
Preview
Section titled “Preview”<div
id="shadcn-input-demo"
class="flex w-full max-w-sm flex-col gap-5"
>
<div class="flex flex-col gap-2">
<div class="text-sm font-medium">API Key</div>
<proto-ui-shadcn-input-root></proto-ui-shadcn-input-root>
<div class="text-xs text-muted-foreground">
Your API key is encrypted and stored securely.
</div>
</div>
<div class="flex flex-col gap-2">
<div class="text-sm font-medium">Email</div>
<proto-ui-shadcn-input-root></proto-ui-shadcn-input-root>
</div>
<div class="flex flex-col gap-2">
<div class="text-sm font-medium">Workspace URL</div>
<proto-ui-shadcn-input-root></proto-ui-shadcn-input-root>
</div>
</div>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const props = [
{
styleProfile: 'rhea',
defaultValue: 'sk-live-9f8e7d6c',
placeholder: 'sk-...',
ariaLabel: 'API Key',
autoComplete: 'off',
},
{
styleProfile: 'rhea',
defaultValue: 'jordan@example.com',
disabled: true,
inputMode: 'email',
ariaLabel: 'Email',
},
{
styleProfile: 'rhea',
defaultValue: 'https://app.example.com/acme',
readOnly: true,
inputMode: 'url',
ariaLabel: 'Workspace URL',
},
];
document
.querySelectorAll(
'#shadcn-input-demo proto-ui-shadcn-input-root'
)
.forEach((el, index) => {
setElementProps(el, props[index]);
});
</script>Installation
Section titled “Installation”This component is available from workspace source. In your application, install the CLI, Shadcn prototypes and target adapter built from the same workspace revision, then initialize the project with that CLI. Run the locally installed CLI to generate the facade.
npm exec -- proto-ui add wc shadcn-input
Replace wc with react, vue, or vue2 to generate the local facade for your framework. You can also import shadcnInputRoot directly from @proto.ui/prototypes-shadcn/input.
import { ShadcnInputRoot } from '@/components/ui/shadcn-input';
export function Example() { return <ShadcnInputRoot placeholder="Enter text" ariaLabel="Text input" />;}- Style presets: Switch presets via an enclosing Style Scope or
styleProfile. Under Shadcn Rhea, the input usesh-8(32px),radius-2xl,bg-input/50(bg-input/30in dark mode), and aborder-ring ring-3 ring-ring/30focus ring, scaling text to small at viewports>= 768px. - Validation and labels: Standalone
Inputfocuses on text editing; pair with Field for label focus forwarding, helper descriptions, and validation error styling. - Accessibility and methods:
RootexposesfocusSelf(),blurSelf(), andresetValue(value?: string), along withariaLabel,labelledBy, anddescribedBy.
Examples
Section titled “Examples”A standalone text input with placeholder guidance.
<proto-ui-shadcn-input-root
id="shadcn-input-basic"
></proto-ui-shadcn-input-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
setElementProps(document.querySelector('#shadcn-input-basic'), {
styleProfile: 'rhea',
placeholder: 'Enter text',
ariaLabel: 'Text input',
});
</script>Compose Field, FieldLabel, FieldControl, and FieldDescription for labeled form inputs.
<proto-ui-shadcn-field-root id="shadcn-input-field">
<proto-ui-shadcn-field-label>
Username
</proto-ui-shadcn-field-label>
<proto-ui-shadcn-field-control></proto-ui-shadcn-field-control>
<proto-ui-shadcn-field-description>
Choose a unique username for your account.
</proto-ui-shadcn-field-description>
</proto-ui-shadcn-field-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
setElementProps(
document.querySelector(
'#shadcn-input-field proto-ui-shadcn-field-control'
),
{
styleProfile: 'rhea',
placeholder: 'Enter your username',
autoComplete: 'username',
}
);
</script>Disabled
Section titled “Disabled”Use disabled to prevent focus and editing with muted surface feedback.
<proto-ui-shadcn-field-root id="shadcn-input-disabled">
<proto-ui-shadcn-field-label>Email</proto-ui-shadcn-field-label>
<proto-ui-shadcn-field-control></proto-ui-shadcn-field-control>
<proto-ui-shadcn-field-description>
This field is currently disabled.
</proto-ui-shadcn-field-description>
</proto-ui-shadcn-field-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const root = document.querySelector('#shadcn-input-disabled');
setElementProps(root, { disabled: true });
setElementProps(
root.querySelector('proto-ui-shadcn-field-control'),
{
styleProfile: 'rhea',
placeholder: 'Email',
inputMode: 'email',
disabled: true,
}
);
</script>Invalid
Section titled “Invalid”Pass invalid and errors to Field to highlight validation errors with destructive borders and accessible messages.
<proto-ui-shadcn-field-root id="shadcn-input-invalid">
<proto-ui-shadcn-field-label>
Invalid Input
</proto-ui-shadcn-field-label>
<proto-ui-shadcn-field-control></proto-ui-shadcn-field-control>
<proto-ui-shadcn-field-error>
This field contains validation errors.
</proto-ui-shadcn-field-error>
</proto-ui-shadcn-field-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const root = document.querySelector('#shadcn-input-invalid');
setElementProps(root, {
invalid: true,
errors: ['This field contains validation errors.'],
});
setElementProps(
root.querySelector('proto-ui-shadcn-field-control'),
{
styleProfile: 'rhea',
defaultValue: 'sk-invalid',
placeholder: 'Error',
}
);
</script>Inline
Section titled “Inline”Pair Input with Button horizontally and use inputMode="search" and enterKeyHint="search" for search bars.
<div class="flex w-full max-w-sm items-center gap-2">
<proto-ui-shadcn-input-root
id="shadcn-input-search"
></proto-ui-shadcn-input-root>
<proto-ui-shadcn-button id="shadcn-input-search-btn">
Search
</proto-ui-shadcn-button>
</div>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
setElementProps(document.querySelector('#shadcn-input-search'), {
styleProfile: 'rhea',
placeholder: 'Search...',
inputMode: 'search',
enterKeyHint: 'search',
ariaLabel: 'Search',
});
setElementProps(
document.querySelector('#shadcn-input-search-btn'),
{ styleProfile: 'rhea' }
);
</script>Grid and Form
Section titled “Grid and Form”Combine multi-column grid inputs, Label, Field, and action buttons into a complete form layout.
<div class="flex w-full max-w-sm flex-col gap-4">
<div class="grid grid-cols-2 gap-4">
<div class="flex flex-col gap-2">
<proto-ui-shadcn-label-root>
First Name
</proto-ui-shadcn-label-root>
<proto-ui-shadcn-input-root
id="form-first-name"
></proto-ui-shadcn-input-root>
</div>
<div class="flex flex-col gap-2">
<proto-ui-shadcn-label-root>
Last Name
</proto-ui-shadcn-label-root>
<proto-ui-shadcn-input-root
id="form-last-name"
></proto-ui-shadcn-input-root>
</div>
</div>
<proto-ui-shadcn-field-root id="form-email-field">
<proto-ui-shadcn-field-label>Email</proto-ui-shadcn-field-label>
<proto-ui-shadcn-field-control></proto-ui-shadcn-field-control>
<proto-ui-shadcn-field-description>
We will send updates to this address.
</proto-ui-shadcn-field-description>
</proto-ui-shadcn-field-root>
<div class="flex items-center gap-2">
<proto-ui-shadcn-button id="form-cancel">
Cancel
</proto-ui-shadcn-button>
<proto-ui-shadcn-button id="form-submit">
Submit
</proto-ui-shadcn-button>
</div>
</div>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
setElementProps(document.querySelector('#form-first-name'), {
styleProfile: 'rhea',
placeholder: 'Jordan',
name: 'firstName',
required: true,
});
setElementProps(document.querySelector('#form-last-name'), {
styleProfile: 'rhea',
placeholder: 'Lee',
name: 'lastName',
required: true,
});
setElementProps(document.querySelector('#form-email-field'), {
required: true,
});
setElementProps(
document.querySelector(
'#form-email-field proto-ui-shadcn-field-control'
),
{
styleProfile: 'rhea',
placeholder: 'name@example.com',
inputMode: 'email',
required: true,
}
);
setElementProps(document.querySelector('#form-cancel'), {
styleProfile: 'rhea',
variant: 'outline',
});
setElementProps(document.querySelector('#form-submit'), {
styleProfile: 'rhea',
});
</script>Root Props
Section titled “Root Props”| Prop | Type | Default |
|---|---|---|
value | string | undefined |
defaultValue | string | '' |
disabled | boolean | false |
readOnly | boolean | false |
placeholder | string | '' |
required | boolean | false |
name | string | '' |
autoComplete | string | '' |
minLength | number | -1 |
maxLength | number | -1 |
inputMode | 'none' 'text' 'tel' 'url' 'email' 'numeric' 'decimal' 'search' | undefined |
enterKeyHint | 'enter' 'done' 'go' 'next' 'previous' 'search' 'send' | undefined |
ariaLabel | string | '' |
labelledBy | string | '' |
describedBy | string | '' |
styleProfile | 'vega' 'nova' 'maia' 'lyra' 'mira' 'luma' 'sera' 'rhea' 'new-york-v4' | 'nova' |
Exposed States, Methods, and Events
Section titled “Exposed States, Methods, and Events”- States:
value,disabled,readOnly,focused,focusVisible,composing - Methods:
focusSelf(options?),blurSelf(),resetValue(value?: string): boolean - Events:
valueChange,change,compositionStart,compositionUpdate,compositionEnd