sun light white, while a rainbow is colorful because The light from the sun is really a mixture of many different colors or wavelength of light.
The wavelength is simply the distance in which a wave repeats itself. Red light has a long wavelength, while violet light has a short wavelength. The light that we can see or visible light is actually made up of different wavelengths that we see as red, orange, yellow, green, blue, indigo, and violet light. These colors gradually merge into one and the mixture produces white light.
As white light passes through droplets of water in the sky, the light is refracted or bent. The longer wavelengths of light are refracted more than shorter wavelengths. This cause the colors to be separated as they pass through the rain drops. The result is the rainbow of seen colors that you see in the sky.