Essentially, solar panels consist of a layer of silicone, which has been created with elemental impurities so to create a natural electric field. When the photons from sunlight hit the panel, it releases an electron into the negative field of the PV and that electron is ejected from its atom. With the right wiring in place, that electron can create an electric current which can then be used to power your gadgets.
The problem with PV cells is that they only really work when they are subjected to sunlight, so they won’t create electricity at night, and produce less when the sky is overcast. That said, there are solutions available to store the charge from PV cells in batteries for later use, or to be sold back “to the grid” to give you a bit of cash from producing your own electricity, although in most cases you’ll consume more than your PV setup will create.
Considering the technology has been around since the Russians first went into space, it’s surprising that every house isn’t built with PV cells already attached.