This study investigates the properties of AlB \(_{\varvec{2}}\) -type YB \(_{\varvec{2}}\) and YGa \(_{\varvec{2}}\) compounds using density-functional theory, focusing on elastic constants, electronic structure, mechanical behavior, and electron–phonon (e-ph) coupling. The results, aligned with theoretical predictions, are compared with MgB \(_{\varvec{2}}\) to assess their superconducting potential. YGa \(_{\varvec{2}}\) has larger structural dimensions but lower phonon frequencies due to gallium’s higher atomic mass. YB \(_{\varvec{2}}\) , on the other hand, shows a higher critical temperature (5.59 K), attributed to its stronger e-ph coupling and higher density of states at the Fermi level. Shorter B-B bonds in YB \(_{\varvec{2}}\) enhance its band structure and raise the Fermi energy. Both compounds are mechanically stable, with YB \(_{\varvec{2}}\) exhibiting higher shear resistance and stronger covalent bonding. Additionally, YB \(_{\varvec{2}}\) has a higher Debye temperature (779.75 K) and sound velocities, indicating superior mechanical properties. These findings underscore YB \(_{\varvec{2}}\) ’s promise as a superconductor with favorable e-ph interactions compared to YGa \(_{\varvec{2}}\) .