Sha256: 73de9d30821e3fbe4d52230fcb378eaf2beb150dde259b0ee038395d33338c0e
Contents?: true
Size: 820 Bytes
Versions: 4
Compression:
Stored size: 820 Bytes
Contents
import React from "react"; interface LabelledFieldProps { label: string; children: React.ReactNode; htmlFor?: string; description?: string; errors?: string[]; } export default function LabelledField(props: LabelledFieldProps) { const { htmlFor, description, label, errors, children } = props; const classNames = ["field"]; if (errors && errors.length > 0) { classNames.push("field-with-errors"); } return ( <div className={classNames.join(" ")}> <label htmlFor={htmlFor}> {label} {errors && ( <React.Fragment> {" "} <span className="error">{errors[errors.length - 1]}</span> </React.Fragment> )} </label> {description && <p className="description">{description}</p>} {children} </div> ); }
Version data entries
4 entries across 4 versions & 1 rubygems