Input
An input takes one line of text, such as a name, an email address or a search term.
When to use
Section titled “When to use”- Use it for short, free text.
- Use Select when the answer comes from a short list.
- Always pair it with a Label; a placeholder is not a label.
Ke sini kami kirim kabar penting untukmu.
Ke sini kami kirim kabar penting untukmu.
Do and don’t
Section titled “Do and don’t”Anatomy
Section titled “Anatomy”- 1Label above the field
- 2Field with an input border
- 3Value
- 4Caret
Label above the field, the field itself, then an optional hint below it. The field uses input for its border, radius-md for its corners and ring for focus.
Variants
Section titled “Variants”There is one style. Invalid fields set aria-invalid, which turns the border and the focus ring destructive.
| React | Vue | Flutter | Type | Default | Use |
|---|---|---|---|---|---|
value / defaultValue |
v-model / default-value |
controller / initialValue |
string | none | The text. |
type |
type |
keyboardType |
string | text |
Keyboard and validation hints. |
disabled |
disabled |
enabled: false |
boolean | false |
Blocks typing. |
aria-invalid |
aria-invalid |
validator |
boolean | false |
Marks the value as wrong. |
import { Input } from "@/components/ui/input"import { Label } from "@/components/ui/label"
export default function InputDemo() { return ( <div className="grid w-full max-w-sm gap-2"> <Label htmlFor="input-demo-email">Email</Label> <Input id="input-demo-email" type="email" aria-describedby="input-demo-hint" /> <p id="input-demo-hint" className="text-sm text-muted-foreground"> Ke sini kami kirim kabar penting untukmu. </p> </div> )}<script setup lang="ts">import { Input } from "@/components/ui/input"import { Label } from "@/components/ui/label"</script>
<template> <div class="grid w-full max-w-sm gap-2"> <Label for="input-demo-email-vue">Email</Label> <Input id="input-demo-email-vue" type="email" aria-describedby="input-demo-hint-vue" /> <p id="input-demo-hint-vue" class="text-sm text-muted-foreground"> Ke sini kami kirim kabar penting untukmu. </p> </div></template>import 'package:flutter/widgets.dart';import 'package:shadcn_ui/shadcn_ui.dart';
class InputDemo extends StatelessWidget { const InputDemo({super.key});
@override Widget build(BuildContext context) { return ConstrainedBox( constraints: const BoxConstraints(maxWidth: 384), child: ShadInputFormField( id: 'email', label: const Text('Email'), keyboardType: TextInputType.emailAddress, description: const Text('Ke sini kami kirim kabar penting untukmu.'), ), ); }}Install
Section titled “Install”npx shadcn@latest add https://design.sosialoka.tech/r/react/input.jsonnpx shadcn-vue@latest add https://design.sosialoka.tech/r/vue/input.jsonAccessibility
Section titled “Accessibility”- Link the label with
htmlFor(React) orfor(Vue) and the field’sid. - Link the hint with
aria-describedbyso screen readers read it. - Error text comes from the backend; show it below the field and set
aria-invalid.
