web/app/components/ui/input.tsxblame
View source
4dfd09b1import { forwardRef } from "react";
4dfd09b2
4dfd09b3export interface InputProps
4dfd09b4 extends React.InputHTMLAttributes<HTMLInputElement> {
4dfd09b5 label?: string;
4dfd09b6 hint?: string;
4dfd09b7 error?: string;
4dfd09b8 optional?: boolean;
4dfd09b9}
4dfd09b10
4dfd09b11export const Input = forwardRef<HTMLInputElement, InputProps>(
4dfd09b12 function Input(
4dfd09b13 { label, hint, error, optional, className = "", style, ...props },
4dfd09b14 ref
4dfd09b15 ) {
4dfd09b16 return (
4dfd09b17 <div>
4dfd09b18 {label && (
4dfd09b19 <label
4dfd09b20 className="block text-xs mb-1"
4dfd09b21 style={{ color: "var(--text-muted)" }}
4dfd09b22 >
4dfd09b23 {label}
4dfd09b24 {optional && (
4dfd09b25 <span style={{ color: "var(--text-faint)" }}> (optional)</span>
4dfd09b26 )}
4dfd09b27 </label>
4dfd09b28 )}
4dfd09b29 <input
4dfd09b30 ref={ref}
4dfd09b31 className={`w-full px-2 py-1 text-sm focus:outline-none ${className}`}
4dfd09b32 style={{
4dfd09b33 backgroundColor: "var(--bg-input)",
4dfd09b34 border: "1px solid var(--border)",
4dfd09b35 color: "var(--text-primary)",
4dfd09b36 ...style,
4dfd09b37 }}
4dfd09b38 {...props}
4dfd09b39 />
4dfd09b40 {hint && !error && (
4dfd09b41 <p className="text-xs mt-1" style={{ color: "var(--text-faint)" }}>
4dfd09b42 {hint}
4dfd09b43 </p>
4dfd09b44 )}
4dfd09b45 {error && (
4dfd09b46 <p className="text-xs mt-1" style={{ color: "var(--error-text)" }}>
4dfd09b47 {error}
4dfd09b48 </p>
4dfd09b49 )}
4dfd09b50 </div>
4dfd09b51 );
4dfd09b52 }
4dfd09b53);