JSFiddle - React, Tailwind, and code Playground
HTML
<div>
<label for="naming_dir_pattern">
<span>Custom</span>
<input type="text" value="" id="custom_pattern" name="custom_pattern" size="50"><br />
</label>
<br/>
<label>
<span>
<input type="button" class="setNamePattern" value="1111">
<input type="button" class="setNamePattern" value="2222">
</span>
</label>
</div>
JavaScript
$('.setNamePattern').on("click", function(){
$('#custom_pattern').val( $(this).val() );
});