JSFiddle - React, Tailwind, and code Playground

Chat messages bubbles

by Christopher O

HTML

<div class="container">

  <div>
    <div class="bubble">
     <p>Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. </p>
     <span class="triangle triangleL"></span>
     <span class="bubBtm bubBtmL">3m</span>
    </div>
  </div>
  
  <div>
    <div class="bubble bubbleR">
     <p>Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. </p>
     <span class="triangle triangleR"></span>
     <span class="bubBtm bubBtmR">1m</span>
    </div>
  </div>
  
</div>

CSS

*, *::after, *::before {
  box-sizing: inherit;
}

html {
  box-sizing: border-box;
}

body {
 padding: 0 2em;
 font-size: 1em;
 color: #000;
 font-family: Helvetica, Arial, sans-serif;
}

.container{
  width: 600px;
  height: 100vh;
  border: 1px dashed grey;
  background-color: #616d7a;
}

.bubble {
 position: relative;
 background-color: #5ad28c;
 min-width: 200px;
 max-width: 400px;
 border-radius: 0.5em;
 display: flex;
 justify-content: center;
 align-items: center;
 margin: 8px 15px 12px 15px;
 padding: 0.1em 1em;
 font-size: 0.9em;
}

.bubbleR {
  float: right;
  background-color: #fff !important;
}

.triangle {
 position: absolute;
 top: 3px;
 display: block;
 height: 15px;
 width: 15px;
 background-color: inherit;
 border: inherit;
 /* left: calc(50% - 10px); */
 clip-path: polygon(0% 0%, 100% 100%, 0% 100%);
 border-radius: 0 0 0 0.2em;
}

.triangleL {
 transform: rotate(45deg);
 left: -4px;
}

.triangleR {
 transform: rotate(-135deg);
 right: -4px;
}

.bubBtm {
  position: absolute;
  bottom: -16px;
  color: #000;
  font-size: .8em;
}

.bubBtmL {
 left: 2px;
}

.bubBtmR {
 right: 2px;
}