Files
Trilium/apps/client/src/widgets/react/FormGroup.tsx

24 lines
810 B
TypeScript
Raw Normal View History

2025-08-05 19:06:47 +03:00
import { ComponentChildren, RefObject } from "preact";
2025-08-04 20:34:47 +03:00
interface FormGroupProps {
2025-08-05 19:06:47 +03:00
labelRef?: RefObject<HTMLLabelElement>;
2025-08-06 18:38:52 +03:00
label?: string;
2025-08-04 21:17:35 +03:00
title?: string;
className?: string;
2025-08-04 20:34:47 +03:00
children: ComponentChildren;
2025-08-07 19:20:35 +03:00
description?: string | ComponentChildren;
2025-08-04 20:34:47 +03:00
}
2025-08-05 19:06:47 +03:00
export default function FormGroup({ label, title, className, children, description, labelRef }: FormGroupProps) {
2025-08-04 20:34:47 +03:00
return (
<div className={`form-group ${className}`} title={title}
style={{ "margin-bottom": "15px" }}>
2025-08-05 19:06:47 +03:00
<label style={{ width: "100%" }} ref={labelRef}>
2025-08-06 18:38:52 +03:00
{label && <div style={{ "margin-bottom": "10px" }}>{label}</div> }
{children}
2025-08-04 20:34:47 +03:00
</label>
2025-08-04 21:17:35 +03:00
{description && <small className="form-text">{description}</small>}
2025-08-04 20:34:47 +03:00
</div>
);
}