An electrochromic (EC) sensing strategy was presented through analyte-induced disassembly of an EC metal-organic framework-based nanocomposite. Carbon dots underwent charge reversion to separate from the entity stimulated by analytes, acting as a nanoswitch of the EC activity. We achieved colorimetric detection of glucose via the EC activity recovery mediated by released protons during glucose oxidation.