checkbox function

({HTMLInputElement box, HTMLElement root}) checkbox(
  1. String label, {
  2. required String id,
  3. bool checked = false,
})

A checkbox with a label.

Implementation

({web.HTMLElement root, web.HTMLInputElement box}) checkbox(
  String label, {
  required String id,
  bool checked = false,
}) {
  final box = el('input', id: id) as web.HTMLInputElement;
  box.type = 'checkbox';
  box.checked = checked;
  final root = el(
    'label',
    classes: 'check',
    attrs: {'for': id},
    children: [box, textNode(label)],
  );
  return (root: root, box: box);
}