JSFiddle - React, Tailwind, and code Playground

HTML

<div class="grid">
  <div class="cell">
    <a class="link" href="https://stackoverflow.com/questions/65760464/grid-aspect-ratio-with-text-and-image-covering-all-spare-space" target="_blank">
      <div class="content">
        <img class="image" src="https://images.unsplash.com/photo-1499492568083-9115ab12d0d2?auto=format%2Ccompress&fit=crop&w=400" />
        <div class="text">
          text 1
        </div>
      </div>
    </a>
  </div>
  <div class="cell">
    <a class="link" href="https://stackoverflow.com/questions/65760464/grid-aspect-ratio-with-text-and-image-covering-all-spare-space" target="_blank">
      <div class="content">
        <img class="image" src="https://images.unsplash.com/photo-1533743409942-b91130480a7a?auto=format%2Ccompress&fit=crop&w=400" />
        <div class="text">
          text 2<br>
          more text
        </div>
      </div>
    </a>
  </div>
  <div class="cell">
    <a class="link" href="https://stackoverflow.com/questions/65760464/grid-aspect-ratio-with-text-and-image-covering-all-spare-space" target="_blank">
      <div class="content">
        <img class="image" src="https://images.unsplash.com/photo-1505569127510-bde1536937bc?auto=format%2Ccompress&fit=crop&w=400" />
        <div class="text">
          text 3
        </div>
      </div>
    </a>
  </div>
  <div class="cell">
    <a class="link" href="https://stackoverflow.com/questions/65760464/grid-aspect-ratio-with-text-and-image-covering-all-spare-space" target="_blank">
      <div class="content">
        <img class="image" src="https://images.unsplash.com/photo-1531852855896-94f2949b34fe?auto=format%2Ccompress&fit=crop&w=400" />
        <div class="text">
          text 4<br>
          more text
        </div>
      </div>
    </a>
  </div>
</div>

CSS

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(275px, 1fr));
  gap: 24px;
}

.cell {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  padding-top: 100%;
  background: red;
}

.link {
  text-decoration: none;
  color: inherit;
}

.content {
  position: absolute;
  top: 0px;
  width: 100%;
  height: 100%;
}

.image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.text {
  padding: 16px;
}