There are a number of ways of looking at this problem. Some are not very intuitive and don't really seem to match reality. But they give the right answer.
One early explanation that give the wrong answer is ray optics. It works for many things, but does not explain diffraction.
It says that light propagates in a straight line. This predicts a geometric shadow of the slit. So we need a better approximation of what is really happening.
Light is a wave. If you toss a rock in a pond, you see a wave spreading out in all directions.
If you toss many rocks in a line, each rock generates its own circle. The waves from each circle add. Some reinforce and some cancel. The result is the same as if you tossed a stick in the water. A straight wave spreads out from the stick.
You can do the same thing with light. A point source of light leads to an expanding spherical wave. A plane source of light is equivalent to many point sources. It leads to a plane wave.
You can take this idea further. A plane wave propagates in a straight line. Suppose such a wave propagates up to plane A and continues on to plane B. You get the same wave B if you have a set of point sources at A. It is as if the plane wave is a set of point sources of expanding spherical waves that continually generates new point sources as it propagates.
Now add in a slit at A. When the wave hits, only the point sources inside the slit are left. And what you get at B is exactly what this view predicts. So whether or not this idea matches reality, you have experimental evidence in favor of it. This was the earliest explanation of diffraction. It can still be used today. This tells us that diffraction is a consequence of the wave nature of light.
In this view, the shape of the slit is important. The material is not. The role of the material is to absorb the light that hits it and extinguish the point source that would have appeared.
Another way of looking at it is that light is an electromagnetic wave. Maxwell's equations describe the propagation of such a wave. You specify boundary conditions appropriate to a particular problem, and calculate the state of the wave in the future.
These equations predict that oscillating charges generate waves, and waves keep going after they are generated.
If the initial condition is a point charge oscillating up and down, you get expanding spherical waves with a particular polarization and intensity pattern. A small sphere of charges vibrating randomly generates a uniform spherical wave. A plane of charges generates a plane wave.
The material around a slit is a boundary condition. A wave propagates up to a slit, and all but the wave inside is absorbed. Maxwell's equations predict the future of the rectangular patch of wave that passes through. It matches what we see.
In this view, the material is charges that interact with the wave. One instructive example is if the material is a smooth metal. Metals contain freely moving electrons. The surface of the metal can be approximated as a sheet of freely moving charges. Such charges are accelerated by the incident wave. This absorbs the energy of the wave. However, accelerating charges generate a new wave. This adds up to a mirror reflection.
If the metal is very thin (say less than a nanometer), absorption is incomplete. The intensity of light decays exponentially in a sheet of charge. For a thin sheet, some may exit the other side. So we get some explanation of why the material absorbs.
We have lots of experimental support for light as an electromagnetic wave. This is in widespread use today. It was considered to be the ultimate answer until about 1900, when several things turned up that it could not explain. These include the photoelectric effect. The energy in very dim light seems to be concentrated in lumps. Electrons orbiting a nucleus is accelerated and should radiate away its energy. It should spiral into the nucleus in a small fraction of a second.
Quantum mechanics is the next explanation. Light consists of photons. Photons are like nothing classical. Their behavior is counterintuitive. The ideas are strange and hard to get used to. In an effort to make them understandable, photons are described as both a classical wave and a classical particle. This is close enough to the truth the make you think you understand, and far enough that you get confused if you reason from it. Here are a couple posts where I try to explain a bit more realistically. But the thing that predicts the actual behavior is the math.
How can a red light photon be different from a blue light photon?
Does the collapse of the wave function happen immediately everywhere?
A photon is described by a wave equation. The Schrodinger equation predicts how the photon propagates. The wave predicts the probability of where the photon can be found and the momentum of the photon. Like Maxwell's equations, a slit is a boundary condition that affects how the wave propagates from there on. The Schrodinger equation predicts the future state of the wave. This leads to a prediction of where the photon probably will be found.
The uncertainty principle provides a bit of explanation. Constricting the region where the wave is reduces the uncertainty in side to side position of the photon. This necessarily increases the uncertainty in side to side momentum. This means the photon can be found farther sideways than ray optics would predict.
Quantum mechanics has experimental support even in cases where Maxwell's equations fail. It explains chemistry. Electrons in an atom have orbitals. The absorb and emit when they change orbitals. More complex orbitals are found in molecules. In metals, electrons are not restricted to individual atoms. The energy structure forms bands.
In this view, the material has charges that can emit and absorb photons. The thickness of the material matters as in Maxwell's equations. The type of material matters because different electron configurations absorb differently.
Given material covered in black paint, there is a quantum mechanical explanation of why this material absorbs so well. But for chemists, the usual way is to understand the properties of the chemicals and not dig into quantum mechanics unless necessary.