Smart grids are electric networks that employ advanced monitoring, control, and communication technologies to deliver reliable and secure energy supply, enhance operation efficiency for generators and distributors, and provide flexible choices for prosumers. Smart grids are a combination of complex physical network systems and cyber systems that face many technological challenges. In this paper, we will first present an overview of these challenges in the context ofcyber-physical systems. We will then outline potential contributions that cyber-physical systems can make to smart grids, as well as the challenges that smart grids present to cyber-physical systems. Finally, implications of current technological advances to smart grids are outlined.