Scientists have created a material that can selectively block out visible light or heat when an electric voltage is applied across it.
By mixing the tiny crystals of the material with glass, they were able to create window panes that could block light from passing through it.
Depending on the voltage they applied, the glass could be completely transparent, could block out only heat, only visible light or both.
It means the dimmable windows could not only be used instead curtains or blinds but also to help control the temperature of buildings during the summer.
The researchers achieved this by combining nanocrystals of tin-doped indium oxide into niobium oxide glass, which is often used to make optical glasses.
Dr Anna Llordes, who led the research at the Lawrence Berkeley National Laboratory in California, said: "The resulting material demonstrates a previously unrealised optical switching behaviour that will enable the dynamic control of solar radiation transmittance through windows.
"These transparent films can block near-infrared and visible light selectively and independently by varying the applied electrochemical voltage over a range of 2.5 volts."
The reason why the glass has the ability to block out both heat, in the form of infrared radiation, and visible light is because the indium tin oxide nanocrystals and the niobium oxide glass both respond differently when an electric current is applied across them.
They are what is known as electrochromic. When a small negative charge is applied to the glass, it causes the indium tin oxide nanocrystals to absorb infrared light.
If that charge is made more negative then the niobium oxide absorbs visible light.
This means that a window can be tuned to simply dim or to block out light altogether.
The researchers also found that combining the two materials into a single glass caused the niobium oxide to block out five times as much light as it would by itself.
Dr Delia Milliron, the principal investigator on the project, said they hoped to improve the amount of infrared light that can be blocked.
She believes the cost could be brought down to produce glass that is just 10 to 15 per cent more expensive than a standard window.
"Integrating our active glass with a solid electrolyte and a transparent counter electrode, suitable for a real window prototype, is the subject of our current research," she said.