Comments (8)
The color input fields shouldn't be styled by the color picker at all. But if you are talking about the input field inside the picker dialog, that's the intended behavior, you can of course customize the style with CSS.
from coloris.
@glewe can you post a screenshot of what you mean by "out of place" ?
from coloris.
Here is a normal input field (Bootstrap style)
As soon as I link coloris to it it changes to this:
Is there any way to leave the original input field untouched?
from coloris.
The easiest way is to use a custom selector (set the el
option to a class for example ) and set the wrap
option to false. But the little color preview will not render.
Coloris({
el: '.myclass',
wrap: false
});
from coloris.
@glewe I just added Bootstrap 5 to a test page and the input field are rendered correctly without any issue. There is no overflowing preview thumbnail like in your screenshot. Could you maybe share a public page where I can see your issue in action?
from coloris.
Great. Thanks, that works. Code looks something like this now:
<div class="input-group mb-3">
<span class="input-group-text"><i id="sample-txt_color" class="bi-square-fill" style="color: #F2EF3D"></i></span>
<input id="txt_color" type="text" class="form-control" name="txt_color" value="#F2EF3D" maxlength="9">
</div>
<script>
Coloris({
el: "#txt_color",
wrap: false,
theme: "polaroid",
themeMode: "dark",
alpha: true,
onChange: function (color) {
$("#sample-txt_color").css("color", color);
}
});
</script>
from coloris.
Additional note:
I noticed that the onChange function does not work with multiple instances. I changed the code to this:
<div class="input-group mb-3">
<span class="input-group-text"><i id="sample-txt_color" class="bi-square-fill" style="color: #608e20"></i></span>
<input id="txt_color" type="text" class="form-control" name="txt_color" value="#608e20" maxlength="9" >
</div>
<script>
Coloris({
el: "#txt_color",
wrap: false,
theme: "polaroid",
themeMode: "dark",
alpha: true,
format: "hex"
});
document.getElementById("txt_color").addEventListener("input", function() {
document.getElementById("sample-txt_color").style.color = this.value;
});
</script>
from coloris.
To support multiple instances, I'd recommend this method:
Coloris({
el: "#txt_color",
wrap: false,
theme: "polaroid",
themeMode: "dark",
alpha: true,
format: "hex",
onChange: function (color, input) {
var thumbnail = input.previousElementSibling; // This is the span.input-group-text
if (thumbnail && thumbnail.firstElementChild) {
thumbnail.firstElementChild.style.color = color;
}
}
});
from coloris.
Related Issues (20)
- Mouse does not lineup on palette after scrolling in scrollable container HOT 3
- Include SCSS file with variables HOT 10
- Add support for CSS custom properties (variables) HOT 1
- Colorpicker wraps all input fields on page load HOT 6
- I would like to contribute sass/scss to the repository HOT 4
- ARIA: issue with Inline `#clr-color-marker` HOT 6
- Incorrect output value of alpha channel in 8-digit Hex Code HOT 8
- The color picker doesn't stick to the input it scrolls along HOT 2
- Make `el` and `parent` options accept `Node` HOT 12
- colorArea doesn't handle right mouse button HOT 2
- Feature Request: Add Eyedropper HOT 2
- Missing info in docs about setting up thumbnails HOT 4
- Not showing in absolute positioned div HOT 2
- Alpha channel loses information HOT 5
- colorArea issue with CSS zoom HOT 1
- Coloris does not call the onChange event if the mouse is released outside the colorArea HOT 3
- Bug: problem with inline mode HOT 4
- Possibility to change z-index in option HOT 2
- How to show thumbnail color instead of numaric value?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from coloris.