MCPcopy Create free account
hub / github.com/untitleduico/react / Label

Function Label

components/base/input/label.tsx:19–60  ·  view source on GitHub ↗
({ isInvalid, isRequired, tooltip, tooltipDescription, className, ...props }: LabelProps)

Source from the content-addressed store, hash-verified

17}
18
19export const Label = ({ isInvalid, isRequired, tooltip, tooltipDescription, className, ...props }: LabelProps) => {
20 return (
21 <AriaLabel
22 // Used for conditionally hiding/showing the label element via CSS:
23 // <Input label="Visible only on mobile" className="lg:**:data-label:hidden" />
24 // or
25 // <Input label="Visible only on mobile" className="lg:label:hidden" />
26 data-label="true"
27 {...props}
28 className={cx("flex cursor-default items-center gap-0.5 text-sm font-medium text-secondary", className)}
29 >
30 {props.children}
31
32 <span
33 className={cx(
34 "hidden text-brand-tertiary",
35 isRequired && "block",
36 typeof isRequired === "undefined" && "group-required:block",
37
38 isInvalid && "text-error-primary",
39 typeof isInvalid === "undefined" && "group-invalid:text-error-primary",
40 )}
41 >
42 *
43 </span>
44
45 {tooltip && (
46 <Tooltip title={tooltip} description={tooltipDescription} placement="top">
47 <TooltipTrigger
48 // `TooltipTrigger` inherits the disabled state from the parent form field
49 // but we don't that. We want the tooltip be enabled even if the parent
50 // field is disabled.
51 isDisabled={false}
52 className="cursor-pointer text-fg-quaternary transition duration-200 hover:text-fg-quaternary_hover focus:text-fg-quaternary_hover"
53 >
54 <HelpCircle className="size-4" />
55 </TooltipTrigger>
56 </Tooltip>
57 )}
58 </AriaLabel>
59 );
60};
61
62Label.displayName = "Label";

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected