To address the demands of rapidly advancing precision instruments requiring higher efficiency and miniaturization, permanent magnets must exhibit exceptional energy density, temperature stability, high magnetic energy product [(BH)max], and adequate coercivity (Hcj). Herein, we design rare earth Er-based magnets (2 : 17-type Er-magnets) with a composition of (Er, Sm)(Co, Fe, Cu, Zr)7.6. Erbium-based compounds (Er2Co17) offer a unique combination of temperature compensation and high saturation magnetization compared to other heavy rare earth elements, resulting in 2 : 17-type Er-magnets with superior temperature stability in Br and (BH)max. Partially substituting Sm reduces the energy barrier for the 2 : 17H-to-2 : 17R phase transition, promoting the development of a complete cellular structure and achieving enhanced coercivity. Notably, the optimal performance is obtained with Er constituting 60% of the total rare earth content, delivering a near-zero temperature-coefficient for Br and (BH)max within 20-150 °C while maintaining Br at 8.92 kG, Hcj at 29.83 kOe, and (BH)max at 18.5 MGOe. These 2 : 17-type Er-magnets provide valuable insights for developing permanent magnets with exceptional comprehensive properties.