{ "$schema": "../schemas/code-crispies-module-schema.json", "id": "html-datalist", "title": "Datalist: Autocomplete Inputs", "description": "Provide suggestions for text inputs without JavaScript", "mode": "html", "difficulty": "beginner", "lessons": [ { "id": "datalist-basic", "title": "Input with Suggestions", "description": "The <datalist> element provides autocomplete suggestions for inputs. Connect it using the list attribute on the input matching the datalist's id.

Users can still type freely - suggestions are just helpers!", "task": "Create a browser selector:
1. Add a <label> saying 'Browser:'
2. Add an <input> with list=\"browsers\"
3. Add a <datalist id=\"browsers\"> with options for Chrome, Firefox, and Safari", "previewHTML": "", "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } label { display: block; margin-bottom: 8px; font-weight: 500; } input { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 16px; } input:focus { outline: 2px solid #1976d2; border-color: transparent; }", "sandboxCSS": "", "initialCode": "", "solution": "\n\n\n ", "previewContainer": "preview-area", "validations": [ { "type": "element_exists", "value": "datalist", "message": "Add a <datalist> element" }, { "type": "attribute_value", "value": { "selector": "input", "attr": "list", "value": "browsers" }, "message": "Connect the input to datalist using list=\"browsers\"" }, { "type": "element_count", "value": { "selector": "option", "min": 3 }, "message": "Add at least 3