Input
Text input with variants and states.
import { Input } from "@/components/ui/input";
export function MyScreen() {
return (
<Input placeholder="Enter your email..." />
);
}Installation
npx @aniui/cli add inputUsage
app/index.tsx
import { Input } from "@/components/ui/input";
export function MyScreen() {
return (
<Input placeholder="Enter your email..." />
);
}Variants
<Input variant="default" placeholder="Default input" />
<Input variant="ghost" placeholder="Ghost input" />Sizes
<Input size="sm" placeholder="Small" />
<Input size="md" placeholder="Medium" />
<Input size="lg" placeholder="Large" />Props
PropTypeDefault
variant"default" | "ghost""default"size"sm" | "md" | "lg""md"classNamestring—Also accepts all TextInput props from React Native.
Source
components/ui/input.tsx
import React from "react";
import { TextInput } from "react-native";
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils";
const inputVariants = cva(
"rounded-md border text-foreground placeholder:text-muted-foreground",
{
variants: {
variant: {
default: "border-input bg-background",
ghost: "border-transparent bg-transparent",
},
size: {
sm: "min-h-9 px-3 text-sm",
md: "min-h-12 px-4 text-base",
lg: "min-h-14 px-5 text-lg",
},
},
defaultVariants: {
variant: "default",
size: "md",
},
}
);
export interface InputProps
extends React.ComponentPropsWithoutRef<typeof TextInput>,
VariantProps<typeof inputVariants> {
className?: string;
}
export function Input({ variant, size, className, ...props }: InputProps) {
return (
<TextInput
className={cn(inputVariants({ variant, size }), className)}
placeholderTextColor="hsl(240 3.8% 46.1%)"
{...props}
/>
);
}