Solar panels are made of photovoltaic cells that generate sunlight and convert this sunlight into a direct current which passes through your home to an inverter. Next, the inverter transmutes the direct current into an alternative current which travels through the electrical panel that powers the electricity in your home.
Excess electricity, not used, will be transmitted to the electrical grid. The grid is used to supply the electricity needed when your panels are not producing enough energy to power your home, for example when it gets dark.