A switchable electrochromism and electrochemiluminescence bifunctional sensor based on the electro-triggered isomerization of spiropyran/layered double hydroxides.