Depends on the style guide you’re following, apparently: The AP style guide says space around them[0]. Chicago Manual of Style says not to[1].
0: https://www.prdaily.com/dashes-hyphens-ap-style/ 1: https://www.chicagomanualofstyle.org/qanda/data/faq/topics/H...