JSFiddle - React, Tailwind, and code Playground

by Kazzkiq

HTML

<div class="battery">
  <div class="load"></div>
  <div class="pct">29%</div>
</div>

CSS

.battery {
  position: relative;
  width: 25px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid #444;
  padding: 1px;
}

.battery:after {
  content: '';
  position: absolute;
  top: 50%;
  margin-top: -3px;
  left: 100%;
  width: 3px;
  height: 6px;
  background: #444;
  border-radius: 0 2px 2px 0;
}

.load {
  min-width: 1px;
  width: 80%;
  height: 12px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.1), rgba(0, 0, 0, 0.3)),
    linear-gradient(90deg, #ff2222 -10%, #fff700 30%, #00e000 120%);
  background-size: 30px auto;
  border-radius: 1px;
  box-shadow: 0 0 0 1px rgba(99,0,0,0.4) inset;
}

.battery .pct {
  position: absolute;
  top: 0px;
  left: 100%;
  margin-left: 10px;
  font-size: 10px;
  font-family: sans-serif;
  color: #222;
  font-weight: bold;
}