JSFiddle - React, Tailwind, and code Playground

HTML

<div class="box">
  I have<br>a gradient
</div>

CSS

body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: linear-gradient(to bottom left, cyan 50%, palegoldenrod 50%);
}

.box {
  position: relative;
  padding: 40px 50px;
  background: rgba(0,0,0,0.2);
  border-radius: 20px;
}

.box::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 20px;
  padding: 6px;
  background: linear-gradient(45deg, red, blue);
  -webkit-mask: 
    linear-gradient(white 0 0) content-box, 
    linear-gradient(white 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}