Dyes and different colorings are often mixed into materials. These are usually a small fraction of the total material volume/mass and aren't painted on so don't have a uniform surface coat but some manage to block all light or all light from a certain wavelength.
How does this work? Why can widely/randomly spaces molecules block light?