2021-04-22 17:10:19 +00:00
|
|
|
import React, { Fragment } from "react"
|
2021-04-26 16:36:41 +00:00
|
|
|
import Style from "./FormLabel.module.css"
|
2021-04-22 17:10:19 +00:00
|
|
|
|
|
|
|
|
2021-04-23 00:18:06 +00:00
|
|
|
/**
|
2021-04-26 16:36:41 +00:00
|
|
|
* A row of a {@link FormLabelled}.
|
|
|
|
*
|
2021-04-23 00:18:06 +00:00
|
|
|
* It displays a label on the first column and a container for the labelled element on the second column.
|
|
|
|
*
|
|
|
|
* @param children - The labelled element.
|
|
|
|
* @param text - Text to be displayed in the label.
|
2021-04-25 15:22:52 +00:00
|
|
|
* @param htmlFor - The `[id]` of the labelled element.
|
2021-04-23 00:18:06 +00:00
|
|
|
* @returns {JSX.Element}
|
|
|
|
* @constructor
|
|
|
|
*/
|
2021-04-26 16:36:41 +00:00
|
|
|
export default function FormLabel({ children, text, htmlFor }) {
|
2021-04-22 17:10:19 +00:00
|
|
|
return (
|
|
|
|
<Fragment>
|
2021-05-11 14:37:15 +00:00
|
|
|
<label htmlFor={htmlFor} className={Style.LabelText}>
|
2021-04-22 17:10:19 +00:00
|
|
|
{text}
|
|
|
|
</label>
|
|
|
|
<div className={Style.LabelContent}>
|
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
</Fragment>
|
|
|
|
)
|
|
|
|
}
|