The optical and electronic properties of Mg-Ti hydrides are studied using first-principles density functional theory. Dielectric functions are calculated for MgxTi(1-x)H2 with compositions x = 0.5, 0.75, and 0.875. The structure is that of fluorite TiH2 where both Mg and Ti atoms reside at the Ti positions of the lattice. In order to assess the effect of randomness in the Mg and Ti occupations we consider both highly ordered structures, modeled with simple unit cells of minimal size, and models of random alloys. These are simulated by super cells containing up to 64 formula units (Z = 64). All compositions and structural models turn out metallic, hence the dielectric functions contain interband and intraband free electron contributions. The former are calculated in the independent particle random phase approximation. The latter are modeled based upon the intraband plasma frequencies, which are also calculated from first-principles. Only for the models of the random alloys we obtain a black state, i.e. low reflection and transmission in the energy range from 1 to 6 eV.