/* Copyright 2026 Marimo. All rights reserved. */ import React, { type PropsWithChildren } from "react"; import { Label } from "@/components/ui/label"; import { renderHTML } from "@/plugins/core/RenderHTML"; import { cn } from "@/utils/cn"; interface Props { label: string | null | undefined; className?: string; labelClassName?: string; id?: string; fullWidth?: boolean; /** * Align the label to the top, left, or right of the component. * @default "left" */ align?: "top" | "left" | "right"; } /** * Label a component. */ export const Labeled: React.FC> = ({ label, children, align = "left", className, labelClassName, fullWidth, id, }) => { // If fullWidth is true, force align to be "top" if (fullWidth) { align = "top"; } if (!label) { // If its a top label, just return the children if (align === "top") { return
{children}
; } // Otherwise, return the children in an inline-flex container return
{children}
; } const labelElement = (
); return (
{labelElement} {children}
); };