How to create a curved speech bubble?

I would consider radial-gradient to do this:

.userMsgBottom {
  position: relative;
  display: inline-block;
  color:#fff;
  max-width: 260px;
  background-color: #2e7384;
  margin: 30px;
  padding: 7px;
  border-radius: 6px;
}

.userMsgBottom:after {
  content: "";
  position: absolute;
  bottom: 0;
  right: -25px;
  width: 40px;
  height: 25px;
  background: radial-gradient(25px at top right, #0000 99%, #2e7384 102%);
}

.userMsgBottom.left:after {
  content: "";
  position: absolute;
  bottom: 0;
  left: -25px;
  width: 40px;
  height: 25px;
  background: radial-gradient(25px at top left, #0000 99%, #2e7384 102%);
}
<div class="userMsgBottom">
  Some text here<br> Some text here<br> Some text here
</div>

<div class="userMsgBottom left">
  Some text here<br> Some text here<br> Some text here
</div>

Here is another idea using mask with CSS variables to easily control the shape:

.bubble {
  --r: 25px; /* the radius */
  --t: 30px; /* the size of the tail */
  
  max-width: 300px;
  padding: calc(2*var(--r)/3);
  -webkit-mask: 
    radial-gradient(var(--t) at var(--_d) 0,#0000 98%,#000 102%) 
      var(--_d) 100%/calc(100% - var(--r)) var(--t) no-repeat,
    conic-gradient(at var(--r) var(--r),#000 75%,#0000 0) 
      calc(var(--r)/-2) calc(var(--r)/-2) padding-box, 
    radial-gradient(50% 50%,#000 98%,#0000 101%) 
      0 0/var(--r) var(--r) space padding-box;
  background: linear-gradient(135deg,#FE6D00,#1384C5) border-box;
  color: #fff;
}
.left {
  --_d: 0%;
  border-left: var(--t) solid #0000;
  margin-right: var(--t);
  place-self: start;
}
.right {
  --_d: 100%;
  border-right: var(--t) solid #0000;
  margin-left: var(--t);
  place-self: end;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-content: center;
  gap: 20px;
  font-family: system-ui, sans-serif;
  font-size: 20px;
}
<div class="bubble left">Bro ipsum dolor sit amet gaper backside single track, manny Bike epic clipless. Schraeder drop gondy, rail fatty slash gear jammer steeps</div>
<div class="bubble right">Ok, Thank you</div>
<div class="bubble left"> ut labore et dolore magna </div>
<div class="bubble right">👌</div>

CSS only curved speech bubble

Leave a Comment