  The evolution of the 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-metals ratio (DTM) and the dust-to-gas ratio (DTG)
with metallicity. We use a novel method to determine mass estimates of the DTM,
DTG and dust composition 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, toward quasars 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 derive the dust extinction from
the estimated dust depletion ($A_{V, \rm depl}$) and compare with the $A_{V}$
from extinction. 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
a dominant process of dust production. The increasing trend of the DTM and DTG
with metallicity is in good agreement with a dust production and evolution
model. Our data suggest that the stellar dust yield is much lower than the
metal yield and thus that the overall amount of dust in the warm neutral medium
that is produced by stars is much lower. We find that $A_{V,\rm depl}$ is
overall lower than $A_{V, \rm ext}$ for the Milky Way and a few Magellanic
Clouds lines of sight, a discrepancy that is likely related to the presence of
carbonaceous dust. We show that the main elements that contribute to the dust
composition are, O, Fe, Si, Mg, C, S, Ni and Al for all the environments.
Abundances at low dust regimes suggest the presence of pyroxene and metallic
iron in dust.
