interface UnderlineOptions { angle?: string; colors?: string[]; top?: string; width?: string; } interface UnderlineStyles { display: "inline"; backgroundImage: string; backgroundSize: string; backgroundRepeat: string; backgroundPosition: string; } function generateUnderline({ angle = "0deg", colors = ["blue"], top = "80%", width = "0.3em" }: UnderlineOptions = {}): UnderlineStyles { return { display: "inline", backgroundImage: `linear-gradient(${angle}, ${(colors.length === 1 ? [colors[0], colors[0]] : colors ).join(", ")} 100%)`, backgroundSize: `100% ${width}`, backgroundRepeat: "no-repeat", backgroundPosition: `0 ${top}` }; } export default generateUnderline;