Home > Enterprise >  Customised search bar with side tag design
Customised search bar with side tag design

Time:11-20

I recently came across a search bar that looks something like this, with a tiny triangle on the side of the input text bar.

enter image description here

What will the general approach be for creating this side shape using the input tag? I have tried to toggle borderRadius (I am using styled components) but have not been able to replicate this feature.

CodePudding user response:

Use clip-path and positions. For custom clip-paths visit clippy.

section {
  display: inline-block;
  position: relative;
  border-radius: 4px;
  overflow: hidden;
}
input {
  border: 3px solid #01509D;
  background: rgba(2,28,36, 1);
  outline: none;
  padding: 10px 20px;
  color: #fff
}
div.triangle {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 20px;
  background-color: #01509D;
  clip-path: polygon(0 0, 20% 0, 70% 50%, 20% 100%, 0 100%);
}
<section>
  <input type="text" />
  <div ></div>
</section>

  • Related