the physics of blackbody radiation that enabled us to understand the variation of stellar colors. It was noticed that the spectra of stars look extremely similar to blackbody radiation curves of various temperatures. Ranging from a couple of thousand kelvin to ~50,000 kelvin. Stars are similar to blackbodies and the color variation of stars is a direct consequence of their surface temperatures. To estimate the surface temperature of a star, we can use the known relationship between the temperature of a blackbody and the wavelength of light where the spectrum peaks. As you increase the temperature of a blackbody, the peak of its spectrum moves to shorter (bluer) wavelengths of light.
I hoped this helped!