Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change color of Bootstrap Delete Text X Icon in FormControl

Is it somehow possible to change the color of this "x" in React? The element is a FormControl with the type "search"

enter image description here

 <div className="w-25 input-group my-2">
            <FormControl
              type="search"
              placeholder="Suchen"
              aria-label="Search"
              onChange={(e) => searchItem(e.target.value)}
            />
          </div>
like image 961
Philipp Fischer Avatar asked Nov 16 '25 14:11

Philipp Fischer


1 Answers

You can not change the color of X, but can use -webkit-search-cancel-button pseudo-element to customize it. in below example I've used font-awsome as background to customize it but you can do it by whatever you want.

input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  height: 20px;
  width: 20px;
  border-radius: 50%;
  background: url(https://pro.fontawesome.com/releases/v5.10.0/svgs/solid/times-circle.svg) no-repeat 50% 50%;
}
like image 137
Saeed Shamloo Avatar answered Nov 19 '25 07:11

Saeed Shamloo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!