JSFiddle - React, Tailwind, and code Playground

HTML

<div class="container"><!--
    this technique is unfortunately sensitive to whitespace between children of .container. using html comments in this case to eliminate it for clarity's sake. in actual use i would just place the tag brackets directly adjacent to each other.
  --><div class="shim"></div><!--
  --><div class="content">
    <h1>inline-block vertical centering</h1>
        <p>Centered inside container.</p>
        <p>No fixed height or margin computations required.</p>
        <p>Expands as needed to contain content and remains centered.</p>
    </div><!--
--></div>

CSS

.container {
    /* arbitrary container height, could be a percentage, can use min/max height, etc. */
    height: 400px;
    text-align: center;
    background-color: #eee;
    white-space: no-wrap;
}

.container .shim {
    /* the shim makes the inline height the full height of the container, so display:inline-block paired with vertical-align:middle will now place elements vertically centered inline. */
    display: inline-block;
    height: 100%;
    vertical-align: middle;
}

.container .content {
    display: inline-block;
    vertical-align: middle;
    background-color: #ddd;
    /* any arbitrary width could be set here in px, percent, min/max etc. padding works fine, too. */
    padding: 10px;
}