Theory:

We all know that the Sun is the primary and most natural source of light. A monochromatic source is one that produces only one colour of light. A composite light source, on the other hand, produces a white light that contains light of various colours. Sunlight is a composite light that consists of light of various colours or wavelengths. Another example of a composite source is a mercury vapour lamp.
 
What do you observe when white light is refracted through a glass prism?
 
prism-gb9278698a_1920.jpg
Passing white light through a prism
 
When a white or composite light beam is refracted through a transparent medium like glass or water, it splits into its component colours. The term for this phenomenon is "light dispersion." A spectrum refers to a group of colours. This spectrum consists of the following colours: Violet, Indigo, Blue, Green, Yellow, Orange, and Red. The abbreviation "VIBGYOR" stands for these colours.
 
When white light is refracted by a transparent medium, why do we get the spectrum? This is due to the fact that different coloured lights are bent at different angles. That is, the angle of refraction varies depending on the colour.
 
Red has the smallest refraction angle, and violet has the largest. The angle of refraction is determined in terms of the medium's refractive index, according to Snell's law. As a result, the refractive index of the medium varies depending on the colour of the light. This means that a medium's refractive index is affected by the wavelength of light.
Reference:
https://pixabay.com/photos/prism-light-spectrum-optics-6174502/