Is a tristate checkbox available?
Hi!
I'm using the metronic template. I need a tristate "switch" or checkbox to represeent "true", "false", and null.
Is there anything like it in the Metronic portfolio of controls? I checked the documentation and I have not seen it.
Replies (3)
Hi,
May I know which Metronic version are you using? Please consider using the latest Metronic v8.1.7 and we can provide you a custom code to implement indeterminate
state as shown in the Bootstrap docs. This fix will be added to the next update of Metronic - v8.1.8.
To make implement indeterminate in Metronic v8.1.7:
1) In src/sass/components/_variables.scss
set the checkbox indeterminate variables as below:
$form-check-input-indeterminate-color: $component-checked-color !default;
$form-check-input-indeterminate-bg-color: $component-checked-bg !default;
$form-check-input-indeterminate-border-color: $component-checked-bg !default;
2) In src/sass/components/forms/_form-check.scss
change the checkbox solid state code as below:
// Solid
&.form-check-solid {
.form-check-input {
border: 0; &:not(:checked):not(:indeterminate) {
background-color: $form-check-input-bg-solid;
}
}
}
3) Use the below code to set indeterminate. Please note that an indeterminate state can be set programmatically, no HTML attribute is available for it.
document.querySelector('#kt_check_indeterminate_1').indeterminate = true;
4) Then recompile your assets folder with Gulp or Webpack.
Please note that the build tools are required only in the development environment just to compile the assets when the source folder files are modified. In the hosting/server deployment, you will only need the compile assets, no need to install the build tools dependencies there.
Regards.
that worked great! thank you very much
Hi ,
Glad to help you out and thank you for the heads up on this. We helped us to improve Metronic with this new option.
Regards.