Documentation / Forms
Label
The form label: a <label> (or a <span> / <p> through as) with five sizes, eight semantic colours in three intensities, icons on either side and the “required” / “optional” marks. Linked to a field with htmlFor, it gives that field its accessible name.
required adds an asterisk hidden from screen readers, backed by invisible text, requiredLabel (“(required)” by default); optionalText defaults to "(optional)". tooltip renders as a native title attribute.
No hooks and no directive: it renders on the server, so UILabelsProvider does not reach it. Its two texts are props, English by default: pass frenchUILabels.labelRequired and frenchUILabels.labelOptional, or your own texts. The library’s fields (Input, Select…) already carry their own label through label; Label is for native fields and custom compositions.
Examples
Basic usage
htmlFor links the label to the field’s id: clicking it focuses the field.
import { Label } from "@synertech/ui";
export function Basic() {
return (
<div className="flex flex-col gap-1.5">
<Label htmlFor="company-name">Raison sociale</Label>
<input id="company-name" className="rounded-lg border border-gray-300 p-2 text-sm" />
</div>
);
}Required and optional
required adds the requiredIndicator mark (“*” by default); optional the optionalText text.
import { Label } from "@synertech/ui";
export function RequiredOptional() {
return (
<div className="flex flex-col gap-2">
<Label htmlFor="email" required>
Adresse e-mail
</Label>
<Label htmlFor="phone" optional optionalText="(facultatif)">
Téléphone
</Label>
<Label htmlFor="siret" required requiredIndicator=" (obligatoire)">
SIRET
</Label>
</div>
);
}Sizes and weights
size goes from xs to xl, weight from normal to bold (medium by default).
import { Label } from "@synertech/ui";
export function Sizes() {
return (
<div className="flex flex-col gap-2">
<Label size="xs" weight="normal">
Très petit, normal
</Label>
<Label size="sm">Petit, medium</Label>
<Label size="lg" weight="semibold">
Grand, semi-gras
</Label>
<Label size="xl" weight="bold">
Très grand, gras
</Label>
</div>
);
}Colours and intensities
color picks the hue, variant its intensity: light, default or strong.
import { Label } from "@synertech/ui";
export function Colors() {
return (
<div className="flex flex-wrap gap-4">
<Label as="span" color="primary">
Principal
</Label>
<Label as="span" color="success" variant="strong">
Validé
</Label>
<Label as="span" color="warning">
En attente
</Label>
<Label as="span" color="error" variant="strong">
Refusé
</Label>
<Label as="span" color="muted" variant="light">
Archivé
</Label>
</div>
);
}Icons, tooltip and disabled state
icon / endIcon frame the text, tooltip adds a title, truncate cuts long texts.
import { Label } from "@synertech/ui";
const InfoIcon = () => (
<svg fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2} aria-hidden="true">
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M12 16v-4m0-4h.01M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"
/>
</svg>
);
export function WithIcons() {
return (
<div className="flex w-56 flex-col gap-2">
<Label
htmlFor="vat"
endIcon={<InfoIcon />}
tooltip="Numéro de TVA intracommunautaire, ex. FR12345678901"
>
N° de TVA
</Label>
<Label htmlFor="ref" truncate className="w-full">
Référence interne du dossier client chez le fournisseur
</Label>
<Label htmlFor="archived" disabled>
Champ verrouillé
</Label>
</div>
);
}API reference
Components
import { Label } from "@synertech/ui";Props — LabelProps
| Prop | Type | Default | Description |
|---|---|---|---|
as |
"label" | "span" | "p" |
"label" |
|
children |
ReactNode |
— | |
color |
LabelColor |
"default" |
|
disabled |
boolean |
false |
|
endIcon |
ReactNode |
— | |
htmlFor |
string |
— | |
icon |
ReactNode |
— | |
optional |
boolean |
false |
|
optionalText |
string |
serverUILabels.labelOptional |
Hint shown after an optional label. English by default ( |
required |
boolean |
false |
|
requiredIndicator |
ReactNode |
"*" |
|
requiredLabel |
string |
serverUILabels.labelRequired |
What a screen reader hears after a required label, in place of the indicator. English by default ( |
size |
LabelSize |
"md" |
|
textColor |
string |
— | |
tooltip |
string |
— | |
truncate |
boolean |
false |
|
variant |
LabelVariant |
"default" |
|
weight |
LabelWeight |
"medium" |
+ 276 inherited native attributes from HTMLAttributes, AriaAttributes, DOMAttributes (className, id, aria-*, event handlers…).
Types
LabelColor
Typetype LabelColor = | "default"
| "primary"
| "secondary"
| "success"
| "warning"
| "error"
| "info"
| "muted"LabelSize
Typetype LabelSize = "xs" | "sm" | "md" | "lg" | "xl"LabelVariant
Typetype LabelVariant = "default" | "light" | "strong"LabelWeight
Typetype LabelWeight = "normal" | "medium" | "semibold" | "bold"