A dye is a coloured substance that chemically bonds to the substrate to which it is being applied. This distinguishes dyes from pigments which do not chemically bind to the material they colour. The dye is generally applied in an aqueous solution, and may require a mordant to improve the fastness of the dye on the fiber.Both dyes and pigments are colored, because they absorb only some wavelengths of visible light.
Yes it is not only allowed but even recommended (Mustahab) to dye the gray beard and gray hair with any color which suits you. Some non Shia Shaikhs claim that black color should not be used. This claim is not authentic and has no evidence. According to authentic Hadeeths, using any color which suits you is allowed.