JSFiddle - React, Tailwind, and code Playground

HTML

<p class="phone">2124771000</p>

JavaScript

$(".phone").text(function(i, text) {
        text = text.replace(/(\d{3})(\d{3})(\d{4})/, "$1-$2-$3");
        return text;
    });