forked from Dshield-xyz/Dshield
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInput.tsx
More file actions
43 lines (40 loc) · 1.11 KB
/
Copy pathInput.tsx
File metadata and controls
43 lines (40 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { forwardRef, useId } from "react";
import { cn } from "@/lib/cn";
export interface InputProps
extends React.InputHTMLAttributes<HTMLInputElement> {
label?: string;
/** Helper text rendered under the field. Accepts rich content. */
hint?: React.ReactNode;
/** Render value in a monospace font (addresses, hashes, amounts). */
mono?: boolean;
}
export const Input = forwardRef<HTMLInputElement, InputProps>(function Input(
{ className, label, hint, mono, id, ...props },
ref,
) {
const generatedId = useId();
const inputId = id ?? generatedId;
return (
<div>
{label && (
<label
htmlFor={inputId}
className="mb-1.5 block text-xs text-zinc-500"
>
{label}
</label>
)}
<input
ref={ref}
id={inputId}
className={cn(
"aurora-field w-full rounded-xl p-3 text-sm text-zinc-200 placeholder-zinc-600 outline-none",
mono && "font-mono text-xs",
className,
)}
{...props}
/>
{hint && <p className="mt-1.5 text-xs text-zinc-600">{hint}</p>}
</div>
);
});