JSFiddle - React, Tailwind, and code Playground

HTML

<div class="c">big text</div>

CSS

.c{    
    width:30px;
    min-height:30px;
    background-color:red;
    border-radius:100%;
    position:absolute;
    text-align:center;
    line-height:30px;
}

JavaScript

var c;
var max_height;
var current_height;
var current_font_size;

function fitFontSize(){
    current_height = c.height();
    current_font_size = parseInt( c.css("font-size") );
    if(current_height > max_height){
        console.log("Overflow!")
        current_font_size --;
        c.css("font-size" , current_font_size+"px") ;       
        fitFontSize();
    }
    //console.log(current_height , max_height)
}

$(function(){
    c = $(".c");
    max_height = parseInt( c.css("min-height") );
    fitFontSize();
});