material_checkbox: Create a shinymaterial checkbox

Description Usage Arguments See Also Examples

View source: R/shiny-material-checkbox.R

Description

Build a shinymaterial checkbox. The value is a boolean (TRUE if checked, FALSE if not checked).

Usage

1
material_checkbox(input_id, label, initial_value = FALSE, color = NULL)

Arguments

input_id

String. The input identifier used to access the value.

label

String. The checkbox label.

initial_value

Boolean. Is the checkbox initially checked?

color

String. The color of the check. Leave empty for the default color. Visit https://materializecss.com/color.html for a list of available colors. This input requires using color hex codes, rather than the word form. E.g., "#ef5350", rather than "red lighten-1".

See Also

update_material_checkbox

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
material_checkbox(
  input_id = "example_checkbox",
  label = "Checkbox",
  initial_value = TRUE,
  color = "#ef5350"
)

## End(Not run)

Example output

<script>$(document).ready(function () {
 
     var shinyMaterialCheckbox = new Shiny.InputBinding();
     $.extend(shinyMaterialCheckbox, {
         find: function (scope) {
             return $(scope).find(".shiny-material-checkbox");
         },
         getValue: function (el) {
             return $(el).val();
         },
         subscribe: function (el, callback) {
             $(el).on("change.shiny-material-checkbox", function (e) {
                 callback();
             });
         },
         unsubscribe: function (el) {
             $(el).off(".shiny-material-checkbox");
         }
     });
 
     Shiny.inputBindings.register(shinyMaterialCheckbox);
 });</script>
<form action="#" class="shiny-material-checkbox">
  <p>
    <input type="checkbox" id="example_checkbox" class="shinymaterial-checkbox-example_checkbox" checked="checked"/>
    <label for="example_checkbox">Checkbox</label>
  </p>
</form>

shinymaterial documentation built on Sept. 1, 2020, 1:07 a.m.