Label
Form field label for inputs and controls.
Enter your email...
Enter your password...
Web preview — components render natively on iOS & Android
import { Label } from "@/components/ui/label";
import { Input } from "@/components/ui/input";
export function MyScreen() {
return (
<View>
<Label>Email</Label>
<Input placeholder="Enter your email..." />
</View>
);
}Installation#
npx @aniui/cli add labelUsage#
app/index.tsx
import { Label } from "@/components/ui/label";
import { Input } from "@/components/ui/input";
export function MyScreen() {
return (
<View>
<Label>Email</Label>
<Input placeholder="Enter your email..." />
</View>
);
}Accessibility#
- Associates with form fields for screen readers.
- Use with
nativeIDto link labels to their corresponding inputs.
Source#
components/ui/label.tsx
import React from "react";
import { Text } from "react-native";
import { cn } from "@/lib/utils";
export interface LabelProps extends React.ComponentPropsWithoutRef<typeof Text> {
className?: string;
}
export function Label({ className, ...props }: LabelProps) {
return (
<Text
className={cn("text-sm font-medium text-foreground leading-none", className)}
{...props}
/>
);
}