Historically and in modern times, when a fabric is to be dyed a color, it was either dipped into the dye, or the dye was applied to the fabric (like Indian “batik”).
Many fabrics like cotton need a chemical aid to make the dye adhere and stay. A “mordant”, called “adjective dye”, is an element which aids the chemical reaction between dye and fiber.
(Photo: dying by submersion today)