The speed of light is slower in various materials than it is in a vacuum or outer space.
When the light passes into a material at an angle, the light beam is bent or refracted according to Snell's Law and the index of refraction of the material. But also, the speed of light through a material varies slightly with the wavelength or frequency of the light. Thus, each wavelength is refracted at a slightly different angle when passing through a material at an angle. This spreading out of the beam of light is called dispersion or chromatic dispersion. This can be seen when sunlight passes through a glass prism. Dispersion can cause problems with camera lenses and must be minimized.
Sunlight is often called white light, since it is a combination of all the visible colors. Since the index of refraction is different for each color, the angle of refraction will be different for each color when the light passes from air into glass or other transparent material. This is according to Snell's Law. If the material is shaped like a prism, the angles for each color will be exaggerated, and the colors will be displayed as a spectrum of light.