import React, { FC, ReactNode } from "react";
import { twMerge } from "tailwind-merge";

interface LabelProps {
  htmlFor?: string;
  redPoint?:boolean;
  children: ReactNode;
  className?: string;
}

const Label: FC<LabelProps> = ({ htmlFor, redPoint, children, className }) => {
  return (
    <label
      htmlFor={htmlFor}
      className={twMerge(
        // Default classes that apply by default
        "mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-400",

        // User-defined className that can override the default margin
        (redPoint ? "relative before:content-['*'] before:text-red-500 before:mr-1" : "") +
        className
      )}
    >
      {children}
    </label>
  );
};

export default Label;
