UNPKG

apphouse

Version:

Component library for React that uses observable state management and theme-able components.

17 lines (15 loc) 634 B
/** * Creates a radial gradient CSS string based on an array of colors. * @param {string[]} colors - An array of colors for the gradient. * @returns {string} The radial gradient CSS string. */ export const createRadialGradientString = (colors: string[]) => { // Create the color stops for the gradient const colorStops = colors.map((color: string, index: number) => { const percentage = (index / (colors.length - 1)) * 100; return `${color} ${percentage}%`; }); // Combine the color stops into a CSS string const gradientString = `radial-gradient(circle, ${colorStops.join(', ')})`; return gradientString; };