Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

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.


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

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 happy,

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.


Your Support Matters!

We will highly appreciate your Metronic Review on Themeforest.
Please go to Themeforest Downloads page, select Metronic & leave your feedback.
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(