diff --git a/input.tsx b/input.tsx index c405de7..fc21265 100644 --- a/input.tsx +++ b/input.tsx @@ -1,20 +1,39 @@ -import { type InputHTMLAttributes, forwardRef } from "react"; +import { type InputHTMLAttributes, type ReactElement, cloneElement, forwardRef } from "react"; import { cn } from "./cn"; export interface InputProps extends InputHTMLAttributes { // any other prop goes here + startIcon?: ReactElement; + endIcon?: ReactElement; } -const Input = forwardRef(({ className, type, ...rest }, ref) => ( - +const Input = forwardRef(({ startIcon, endIcon, className, type, ...rest }, ref) => ( +
+ + {startIcon && + cloneElement(startIcon as ReactElement, { + className: cn( + "absolute top-2.5 left-3 mr-2 size-4 text-muted-foreground peer-disabled:text-muted peer-focus-visible:text-primary", + startIcon.props.className, + ), + })} + {endIcon && + cloneElement(endIcon as ReactElement, { + className: cn( + "absolute top-2.5 right-3 mr-2 size-4 text-muted-foreground peer-disabled:text-muted peer-focus-visible:text-primary", + endIcon.props.className, + ), + })} +
)); Input.displayName = "Input"; diff --git a/package.json b/package.json index aac746b..866b655 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@risc0/ui", - "version": "0.0.59", + "version": "0.0.60", "sideEffects": false, "type": "module", "scripts": {