The evolution of cosmic dust content and the cycle between metals and dust in the interstellar medium (ISM) play a fundamental role in galaxy evolution. The chemical enrichment of the Universe can be traced through the evolution of the dust-to-metal ratio (DTM) and the dust-to-gas ratio (DTG) with metallicity. The physical processes through which dust is created and eventually destroyed remain to be elucidated. We use a novel method to determine mass estimates of the DTM, DTG, and dust composition in terms of the fraction of dust mass contributed by element X (f_MX_) based on our previous measurements of the depletion of metals in different environments (the Milky Way, the Magellanic Clouds, and damped Lyman-{alpha} absorbers (DLAs) towards quasars (QSOs) and towards gamma-ray bursts (GRBs)), which were calculated from the relative abundances of metals in the ISM through absorption-line spectroscopy column densities observed mainly from VLT/UVES and X-shooter, and HST/STIS. We also derive the dust extinction from the estimated dust depletion (A_V,depl_) for GRB-DLAs, the Magellanic Clouds, and the Milky Way, and compare it with the A_V_ estimated from extinction (A_V,ext_). We find that the DTM and DTG ratios increase with metallicity and with the dust tracer [Zn/Fe]. This suggests that grain growth in the ISM is the dominant process of dust production, at least in the metallicity range (-2<=[M/H]tot<=0.5) and redshift range (0.6