By enabling rapid, cost-effective, user-friendly andin situdetection of carbon dioxide, colorimetric CO2sensors are of relevance for a variety of fields. However, it still remains a challenge the development of optical chemosensors for CO2that combine high sensitivity, selectivity and reusability with facile integration into solid materials. Herein we pursued this goal by preparing hydrogels functionalized with spiropyrans, a well-known class of molecular switches that undergo different color changes upon application of light and acid stimuli. By varying the nature of the substituents of the spiropyran core, different acidochromic responses are obtained in aqueous media that allow discriminating CO2from other acid gases (e.g., HCl). Interestingly, this behavior can be transferred to functional solid materials by synthesizing polymerizable spiropyran derivatives, which are used to prepare hydrogels. These materials preserve the acidochromic properties of the incorporated spiropyrans, thus leading to selective, reversible and quantifiable color changes upon exposure to different CO2amounts. In addition, CO2desorption and, therefore, recovery of the initial state of the chemosensor is favored by irradiation with visible light. This makes spiropyran-based chromic hydrogels promising systems for the colorimetric monitorization of carbon dioxide in a diversity of applications.