Closed NikitinVladimirV closed 1 year ago
I think that the choices.css
file is missing, you have several options to add it:
You can add the choices.css
in main.js
import Choices from "choices.js";
import "choices.js/public/assets/styles/choices.css";
const choices = new Choices('.select')
Let's say you have a CSS file called style.css
, then you can add the styles:
@import "choices.js/public/assets/styles/choices.css";
/* more css ... */
And don't forget to load your stylesheet in your html:
<html>
<head>
<!-- more tags ... -->
<link rel="stylesheet" href="/style.css">
</head>
<body>
<select class="select">
<option>1</option>
<option>2</option>
</select>
<script type="module" src="/main.js"></script>
</body>
</html>
Note you can also use choices.min.css
instead of choices.css
.
And of course, you can use choices.scss
for more customisation but that is another topic.
Thanks! I have already found a solution. Forgot to connect styles "Choices.js")
Describe the bug when connecting via NPM, the "select" looks open
To Reproduce Steps to reproduce the behavior:
const element = document.querySelector('.js-choice'); const choices = new Choices(element);
Expected behavior the select must be assembled into one line
Screenshots JS
HTML
RESULT
![image](https://user-images.githubusercontent.com/79249769/204532658-76f7a1e4-a6e6-4bbb-a1e1-ae986b7aebd8.png)
Desktop (please complete the following information):