When white light passes through a prism, it will refract and disperse into the seven colors of the visible spectrum - red, orange, yellow, green, indigo, blue, and violet. This is because white light is composed of a mixture of colored lights. To produce a rainbow, the sun light must hit water droplets inside a certain angle so that the light undergoes total internal reflection inside the droplets and is seen by the observer.