Label Component
The <Label> component is designed to render <label> html element. It provides options for displaying a required indicator and error styling.
Basic Usage
The component renders a label with optional required indicator and error styling.
- Basic
- Required
- Error
import { Label } from "react-better-html";
function App() {
return (
<Label text="Username" />
);
}
import { Label } from "react-better-html";
function App() {
return (
<Label text="Email" required />
);
}
import { Label } from "react-better-html";
function App() {
return (
<Label text="Password" isError />
);
}
Common Props
type LabelProps = {
text?: string;
required?: boolean;
requiredSize?: React.CSSProperties["fontSize"];
isError?: boolean;
fontFamily?: React.CSSProperties["fontFamily"];
fontSize?: React.CSSProperties["fontSize"];
letterSpacing?: React.CSSProperties["letterSpacing"];
textTransform?: React.CSSProperties["textTransform"];
color?: React.CSSProperties["color"];
htmlFor?: string;
};
text- the text to display in the labelrequired- iftrue, an asterisk is appended to the label to indicate it is requiredrequiredSize- the font size of the asterisk (defaults to16)isError- iftrue, the label is styled with an error colorfontSize- the font size of the label (defaults to14)color- the color of the label (defaults totextSecondary)htmlFor- theidof the input the label belongs to
tip
The default style of all labels in the app (including the ones in <InputField>, <Dropdown> and <ToggleInput>) can be changed from the components configuration.