How to apply gradient colour inside the icon of svg icon in react js
- User
How to apply gradient colour inside the icon of svg icon in react js
Assistant
Here's how you can apply a gradient color to an SVG icon in React:
jsxfunction GradientIcon() { return ( <svg width="24" height="24" viewBox="0 0 24 24"> {/* Define the gradient */} <defs> <linearGradient id="myGradient" gradientTransform="rotate(90)"> <stop offset="0%" stopColor="#FF6B6B" /> <stop offset="100%" stopColor="#4ECDC4" /> </linearGradient> </defs> {/* Use the gradient in the path/shape */} <path d="M12 2L2 7v10l10 5 10-5V7L12 2z" fill="url(#myGradient)" /> </svg> ); }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.