JSFiddle - React, Tailwind, and code Playground

HTML

<form>
    <div class="custom-file">
        <span>Anexar Arquivo</span>
        <input type="file" />
    </div>
    <input type="submit" value="Enviar" />
</form>

CSS

.custom-file {
    position: relative;
    width: 150px;
    height: 40px;
}
.custom-file span,
.custom-file input {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    display: inline-block;
}

.custom-file input {
    opacity: 0;    
}
.custom-file span {
    z-index: 1;
    background-color: #ddd;
    line-height: 40px;
    text-align: center;
}

JavaScript

$('input[type="file"]').on('change',function() {
    var arquivo = $(this).val();
    var file = arquivo.replace(/\\/g, '/').replace(/.*\//, '');
    
    file = (file == '') ? 'Anexar arquivo' : file;
    
    $(this).siblings('span').text(file);
});