Unlike in most films, a lot of the chemicals commonly used in a lab are transparent liquids or white powders. This is for a number of different reasons, but generally speaking, colours in chemistry usually arise due to metals like iron, copper or chromium.
For instance, the mineral corundum has the molecular formula $Al_2O_3$ and in its pure, mineral form, is a transparent/white crystal.
If we take this exact same mineral, $Al_2O_3$, and introduce trace amounts iron, titanium or chromium, we can create vibrant blue or red crystals. In fact, the crystal forms of corundum with trace amounts of iron and titanium, and chromium, respectively, are what we know as sapphires and rubies.
These colours arise as the result of electron transitions within the metal impurities. In a similar way, many of the coloured powders one encounters in chemistry labs are compounds with a metal centre surrounded by a number of substituent branches called 'ligands'. These complexes are called metal (or 'coordination') complexes.
What is a Metal Complex?
A metal complex is a compound consisting of a central metal atom or ion surrounded by several atoms, ions or molecules known as ligands. Common examples of metal centres might include gold, chromium, nickel, copper, iron or platinum, and the ligands themselves may be halides, ions like cyanide, hydroxide or oxalate, or neutral compounds like water, carbon monoxide or phenyl groups.
The specific chemistry that governs which ligands bond to which metal centres is based primarily on acid-base theory, specific Lewis acid-base theory. The metal centre acts as a Lewis acid, and accepts electrons from the ligand, acting as a Lewis base. The bonds that form as a result of this interaction are generally classed as covalent bonds.
The Effect of the Ligands
As the ligands bond to the metal centre, they bring with them clouds of negative charge in the form of their donated electron pair. Since the metal centre already has a number of its own electrons, specifically those in its d-orbitals, this introduces a form of electrostatic repulsion between the metal's and ligands' electrons. This is complicated slightly more by the fact that the metal's d-electrons are not arranged equally around the metal, but instead in the 5 orbital shapes shown below, each housing up to 2 electrons.
As the ligands attach, imagine them as spaced out evenly around the metal centre. Some of the orbitals shown above will be closer to ligands than others, leading to more repulsion and overall higher-energy orbitals. This depends, of course, in the geometry of the ligands themselves (surely if 4 or 6 ligands attach, they'll arrange in different ways?). This is true, though for simplicity, we'll look at the most common case, which is "octahedral geometry". In octahedral complexes, 6 ligands arrange evenly around a metal centre. As such, when these ligands bond to our centre, what we observe is a 'splitting' of the d-orbitals, wherein $d_{x^2-y^2}$ and $d_{z^2}$ orbitals end up with higher energy than the other 3. We can represent these new energies with a splitting diagram, in which the orbitals' new energies are arranged vertically.
d-Electron Splitting Diagrams
To visualize the uneven repulsion and subsequent energy splitting explained above, we use diagrams showing the various energies of the metal's d-orbitals. An example is shown below.
As we can see, an energy difference exists between electrons in lower and higher energy orbitals, which leads, as one might imagine, to the possibility of electron transitions. Indeed when visible light hits a metal complex, the electrons in lower energy orbitals may excite to the higher energy ones, and upon relaxing back to their original orbital, release photons of light of a certain wavelength. This corresponds to a specific colour, and is, for instance, the reason a cobalt metal centre, surrounded by amine ($NH_3$) ligands is bright yellow/orange.
In summary, metal complexes allow for entire new avenues of chemistry to be explored as an incredibly useful and unique class of substances. As a final note, one might notice that the splitting diagram above is labeled as being "high spin". Without going into too much detail, the extent of repulsion and subsequent d-orbital splitting in metal complexes can lead to metal complexes wherein electrons fill all the orbitals first (i.e. high spin) or those where the low-energy orbitals are filled before the high-energy ones (i.e. low spin). This is mainly due to the nature of the ligands themselves, and to a lesser extent, the metal centre. The "spectrochemical series" is an ascending list of ligands ordered in terms of "field strength", or how much they split metal's d-orbitals in these complexes. We can use this series to predict what the electron configuration may be in various different metal complexes with the general rule being what we might expect: the higher the extent of the orbital-splitting, the more likely we are to observe a low-spin complex.
Try out the metal complex builder to experiment with building and visualizing different metal complexes, including their IUPAC names and d-electron splitting diagrams. In addition, the interactive spectrochemical series allows one to explore the splitting capabilities of all common ligands, and see examples complexes in which they might be found.