Input
tetra-ui/inputFreeComponent
A core component that allows users to enter text.
Live preview
live · rendered by the registry
Rendered by tetra-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://tetra-ui.com/r/input.jsonSource
1import { cva, type VariantProps } from "class-variance-authority";2import {3 Children,4 cloneElement,5 createContext,6 isValidElement,7 useCallback,8 useContext,9 useEffect,10 useMemo,11 useRef,12 useState,13} from "react";14import {15 type BlurEvent,16 type FocusEvent,17 Platform,18 Pressable,19 TextInput as RNTextInput,20 View,21} from "react-native";22import Animated, {23 interpolateColor,24 useAnimatedStyle,25 useSharedValue,26 withTiming,27} from "react-native-reanimated";28import { useCSSVariable } from "uniwind";29import { cn } from "../lib/utils";30import { Button, ButtonIcon, type ButtonProps, ButtonText } from "./button";3132// Constants33const ANIMATION_DURATION = 120;34const AnimatedPressable = Animated.createAnimatedComponent(Pressable);3536// Types37type InternalInputAddonButtonContextType = VariantProps<38 typeof inputAddonButtonVariants39> &40 Pick<ButtonProps, "variant">;4142export type InputProps = Omit<43 React.ComponentPropsWithRef<typeof RNTextInput>,44 "editable"45> & {46 disabled?: boolean;47};4849export type InputPressableProps = React.ComponentProps<typeof Pressable> & {50 disabled?: boolean;51 invalid?: boolean;52 focused?: boolean;53};5455export type InputAddonProps = React.ComponentProps<typeof View> &56 VariantProps<typeof inputAddonVariants> & {57 children: React.ReactNode;58 };5960export type InputAddonChild =61 | React.ReactElement<InputAddonProps>62 | null63 | false;64export type InputAddonChildren = InputAddonChild | InputAddonChild[];6566type InputAddonIconProps = {67 children: React.ReactNode;68 className?: string;69};7071type InputAddonButtonProps = Omit<React.ComponentProps<typeof Button>, "size"> &72 VariantProps<typeof inputAddonButtonVariants>;7374type UseInputFocusStateProps = {75 onFocus?: (e: FocusEvent) => void;76 onBlur?: (e: BlurEvent) => void;77};7879// Context80const InputAddonButtonContext =81 createContext<InternalInputAddonButtonContextType | null>(null);8283const useInputAddonButtonContext = () => {84 const context = useContext(InputAddonButtonContext);85 if (!context) {86 throw new Error(87 "useInputAddonButtonContext must be used within a Button component"88 );89 }90 return context;91};9293// Components94export const Input = ({ className, disabled, ...props }: InputProps) => {95 return (96 <RNTextInput97 className={cn(98 "grow font-normal text-base text-foreground leading-tight",99 className100 )}101 editable={!disabled}102 placeholderTextColorClassName="accent-muted-foreground"103 {...props}104 />105// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from tetra-ui
All 41 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | tetra-ui | Components | Free | 1 dep | |
| Action Inputaction-input | tetra-ui | Components | Free | no deps | |
| Alertalert | tetra-ui | Components | Free | no deps | |
| Avataravatar | tetra-ui | Components | Free | no deps | |
| Badgebadge | tetra-ui | Components | Free | no deps | |
| Bottom Sheetbottom-sheet | tetra-ui | Components | Free | 4 deps · 7 files | |
| Buttonbutton | tetra-ui | Components | Free | no deps | |
| Cardcard | tetra-ui | Components | Free | no deps |
