Smart windows with high near-infrared (NIR) light shielding and controllable visible light transmittance are highly sought after for cooling energy saving in buildings. Herein, we present a rationally designed spectrally selective smart window which is capable of shielding 96.2% of the NIR irradiation from 800 to 2500 nm and at the same time permitting acceptable visible light (78.2% before and 45.3% after its optical switching) for indoor daylighting. The smart window synergistically integrates the highly selective and effective NIR absorption based photothermal conversion of cesium tungsten bronze (Cs xWO3) with the transparent thermoresponsive poly( N-isopropyl acrylamide) (PNIPAM) microgel-polyacrylamide (PAM) hydrogel. Optical switching of the smart window is a direct result of the phase transition of PAM-PNIPAM hydrogel, which in turn is induced by the photothermal effect of Cs xWO3 under sunlight irradiation. The smart window exhibits fast optical switching, shows long-term operational stability, and can be made highly flexible. Under the experimental conditions in this work, the indoor temperature with the smart window is ∼21 °C lower than that with a regular single-layered glass window under one sun irradiation. The smart window design in this work is meaningful for further development of effective smart windows for energy saving in the build environment.