An aspect of the present invention is an electrical device, where the device includes a current collector and a porous active layer electrically connected to the current collector to form an electrode. The porous active layer includes MgBx particles, where x≥1, mixed with a conductive additive and a binder additive to form empty interstitial spaces between the MgBx particles, the conductive additive, and the binder additive. The MgBx particles include a plurality of boron sheets of boron atoms covalently bound together, with a plurality of magnesium atoms reversibly intercalated between the boron sheets and ionically bound to the boron atoms.