{ "id": "todo-list", "name": "Todo List", "description": "Interactive checklist with strikethrough on completed items", "author": "gradio", "tags": [ "form", "todo", "checklist" ], "category": "form", "html_template": "

Todo List

\n", "css_template": "h2 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }\nul { padding: 0; margin: 0; }\nli { font-size: 14px; transition: opacity 0.2s; }\nli input { margin-right: 8px; cursor: pointer; }", "js_on_load": "const checkboxes = element.querySelectorAll('input[type=\"checkbox\"]');\ncheckboxes.forEach(checkbox => {\n checkbox.addEventListener('change', () => {\n const index = parseInt(checkbox.getAttribute('data-index'));\n let completed = props.completed || [];\n if (checkbox.checked) {\n if (!completed.includes(index)) {\n completed.push(index);\n }\n } else {\n completed = completed.filter(i => i !== index);\n }\n props.completed = [...completed];\n });\n});", "default_props": { "value": [ "Buy groceries", "Walk the dog", "Read a book", "Write code" ], "completed": [ 1 ] }, "python_code": "class TodoList(gr.HTML):\n def __init__(self, value=None, completed=None, **kwargs):\n html_template = \"\"\"\n

Todo List

\n \n \"\"\"\n js_on_load = \"\"\"\n const checkboxes = element.querySelectorAll('input[type=\"checkbox\"]');\n checkboxes.forEach(checkbox => {\n checkbox.addEventListener('change', () => {\n const index = parseInt(checkbox.getAttribute('data-index'));\n let completed = props.completed || [];\n if (checkbox.checked) {\n if (!completed.includes(index)) completed.push(index);\n } else {\n completed = completed.filter(i => i !== index);\n }\n props.completed = [...completed];\n });\n });\n \"\"\"\n super().__init__(\n value=value or [], completed=completed or [],\n html_template=html_template,\n js_on_load=js_on_load, **kwargs\n )" }