Skip to content

<input type="color" class="form-control"> as colorpicker is displayed badly #18786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cvrebert opened this issue Jan 7, 2016 · 13 comments
Closed

Comments

@cvrebert
Copy link
Collaborator

cvrebert commented Jan 7, 2016

When browsers such as Chrome and Firefox present a proper colorpicker UI for <input type="color">, if you use .form-control on the input, it's displayed kinda weirdly.

In Chrome, the padding scrunches the actual color swatch and makes it invisible:
chrome

In Firefox, the height of the input doesn't match the height of <input type="text" class="form-control">:
firefox

Safari doesn't support color inputs, so it shows a plain text input, which looks fine.
I haven't tested on IE/Edge.
CC: @mdo

@patrickhlauke
Copy link
Member

Neither IE nor Edge currently support type="color", so visually it's the same as for type="text"

@eliottrobson
Copy link

There's a couple of inconsistencies with heights on elements. I've managed to fix these with a few explicit height declarations which normalizes select and input heights. This also works for input type color too.

http://www.bootply.com/NjBlSmhHNm

@vanillajonathan
Copy link
Contributor

@patrickhlauke Edge nowadays (version 14) supports type="color".

@mdo
Copy link
Member

mdo commented Nov 27, 2016

Agreed this needs addressing, but I don't think a fully custom (square) component like in the cross referenced PRs is the way to go. I think a modifier class or something similar to that would be helpful though for the browsers that do support it.

@oktalk
Copy link

oktalk commented May 8, 2017

There's been a lot of back and fourth on this issue. I would suggest removing support for the color attribute. It's glaringly broken now, and has limited browser support. I could open a PR if desired.

You can do a bit with pseudo classes, but it's still funky. Here's a pen: https://codepen.io/oktalk/pen/BRJKYd

@gvangool
Copy link

I've resolved it in our local build by setting the same height as on <select/>

input[type=color].form-control {
    height: $input-height;
}

@rparundekar
Copy link

I fixed mine by using @gvangool's solution, but by setting the padding as 0px.

input[type=color].form-control {
    padding: 0px;
}

@el07694
Copy link

el07694 commented Nov 26, 2018

input[type=color].form-control {
height: calc(2.25rem + 2px)!important;
}

solved for me!!

@MartijnCuppens
Copy link
Member

Since #26820, a height is added to the .form-control which solves this problem.

@mariusa
Copy link
Contributor

mariusa commented Nov 30, 2021

height: auto still results in the same bad display (1 thin line instead of rectangle), sometimes, with bootstrap 5, for .form-control-color. Screenshot (same as above)
2021-11-30_14-34

@vanillajonathan
Copy link
Contributor

@mariusa
Copy link
Contributor

mariusa commented Nov 30, 2021

Exactly the same control sometimes shows like this. I've seen this on multiple user devices, can't figure out why:
2021-11-30_14-59

@patrickhlauke
Copy link
Member

well, it would be good to isolate a reduced test case (without any non-bootstrap styles in the way), and trying to pin down which browsers/operating systems/etc it happens on. "sometimes" is a bit too vague to try and trouble-shoot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests