Vietnamese Input
A text input with a built-in Vietnamese input method: Telex and VNI keystrokes become diacritics in place as you type, with modern tone placement, and pass-through when disabled. The method prop switches between telex and vni; the use-vietnamese-input hook drives any input or textarea without an OS IME.
npx shadcn@latest add @velaui/vietnamese-inputpnpm dlx velaui add @velaui/vietnamese-inputyarn dlx shadcn@latest add @velaui/vietnamese-inputbunx --bun shadcn@latest add @velaui/vietnamese-inputveni add vietnamese-inputInstalls the copy of vela-ui that veni-builder serves to Venizia apps; veni-builder serves the Radix UI copy only, so this tab exists for that base alone.
npx shadcn@latest add @velaui/vietnamese-inputpnpm dlx velaui add @velaui/vietnamese-inputyarn dlx shadcn@latest add @velaui/vietnamese-inputbunx --bun shadcn@latest add @velaui/vietnamese-inputExamples
- Default
- Method toggle
- Chat vietnamese
Usage
Props
| Prop | Type | Default |
|---|---|---|
enabled | boolean | true |
method | import("/app/catalog/hooks/use-vietnamese-input").TVietnameseMethod | VietnameseMethods.TELEX |
size | "sm" | "md" | "lg" | — |
variant | "fill" | "underline" | "outlined" | — |
Takes these and every prop of VietnameseInputProps.
| Prop | Type | Default |
|---|---|---|
enabled | boolean | true |
method | import("/app/catalog/hooks/use-vietnamese-input").TVietnameseMethod | VietnameseMethods.TELEX |
size | "sm" | "md" | "lg" | — |
variant | "underline" | "fill" | "outlined" | — |
Takes these and every prop of VietnameseInputProps.
Dependencies
- npm
- none besides React
- Installs with it
- Input
Source
components/ui/vietnamese-input.tsx
import { Input, type InputProps } from "@/components/ui/input";
import {
useVietnameseInput,
VietnameseMethods,
type VietnameseInputOptions,
} from "@/hooks/use-vietnamese-input";
export type VietnameseInputProps = InputProps & VietnameseInputOptions;
function VietnameseInput({
method = VietnameseMethods.TELEX,
enabled = true,
ref,
...props
}: VietnameseInputProps) {
const { ref: imeRef } = useVietnameseInput({ method, enabled });
return (
<Input
{...props}
ref={(element) => {
const detach = imeRef(element);
if (typeof ref === "function") {
ref(element);
} else if (ref) {
ref.current = element;
}
return detach;
}}
data-slot="vietnamese-input"
data-method={method}
/>
);
}
export { VietnameseInput };