Electrochromic matrials exchibit reversible and persistent change of the optical properties, hence the color, upon applying an electrical pulse that injects both electrons and compensating ions into the materials. Despite much research effort, a first-principles theory for the coloration mechanism in this material has not emerged. Although the connection between the appartent color of materrials and their optical properties is obvious, so far there has been no calculations of the color of materials from first-principles. In this talk, I will discuss first-principles investigations of the coloration of WO3 upon charge insertion, using sodium tungsten bronze (Na_xWO3) as a model system. Our results explain well the systematic color change of Na_xWO3 from dark blue to violet, red-orange, and finally to golden-yellow as sodium concentration x increases from 0.3 to unity. Proper accounts for both the interband and the intraband contributions to the optical response are found to be important for a detailed understanding of the coloration mechasnism in this system.