Toggle navigation
☰
Home
HTML
CSS
Scripting
Database
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Filterable List</title> <style> /* ========================================================================== Styles for Demo Preview Only ========================================================================== */ body { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background-color: #f1f5f9; color: #334155; margin: 0; padding: 2rem; display: flex; justify-content: center; } /* ========================================================================== Filterable List Component Styles - Copy from here ========================================================================== */ .filterable-list-template { --filter-font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; --filter-primary-text-color: #1e293b; --filter-secondary-text-color: #64748b; --filter-accent-color: #3b82f6; --filter-bg-color: #ffffff; --filter-border-color: #cbd5e1; font-family: var(--filter-font-family); color: var(--filter-primary-text-color); width: 100%; max-width: 600px; background-color: var(--filter-bg-color); border: 1px solid var(--filter-border-color); border-radius: .5rem; padding: 2rem; } .filterable-list-template *, .filterable-list-template *::before, .filterable-list-template *::after { box-sizing: border-box; } .filterable-list-template .list-header { text-align: center; margin-bottom: 2rem; } .filterable-list-template .list-header h2 { font-size: 1.75rem; margin: 0; } /* Visually hide the label, but keep it accessible */ .filterable-list-template .search-label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0; } .search-input { width: 100%; padding: .75rem 1rem; font-size: 1rem; border: 1px solid var(--filter-border-color); border-radius: .25rem; margin-bottom: 2rem; } .search-input:focus { outline: 2px solid var(--filter-accent-color); outline-offset: 1px; } .item-list { list-style: none; padding: 0; margin: 0; } .item-list li { padding: .75rem 0; border-bottom: 1px solid var(--filter-border-color); } .item-list li:last-child { border-bottom: none; } .no-results { text-align: center; color: var(--filter-secondary-text-color); font-style: italic; } </style> </head> <body> <div class="filterable-list-template"> <header class="list-header"> <h2>Conspiracy Clearinghouse</h2> </header> <div class="search-bar"> <label for="search-input" class="search-label">Search Theories:</label> <input type="search" id="search-input" class="search-input" placeholder="Search theories..." aria-controls="theory-list"> </div> <ul id="theory-list" class="item-list"> <li>Birds are not real; they are government drones.</li> <li>The moon landing was faked on a soundstage.</li> <li>Finland doesn't actually exist.</li> <li>Shakespeare's plays were written by someone else.</li> <li>Denver International Airport is a secret bunker.</li> <li>Lizard people secretly run the world.</li> <li>The Earth is actually hollow.</li> <li>The Titanic was deliberately sunk for insurance money.</li> <li>Bigfoot is just a blurry, out-of-focus bear.</li> </ul> <p class="no-results" hidden>No matching theories found. Keep searching!</p> <script> document.addEventListener('DOMContentLoaded', () => { const listContainer = document.querySelector('.filterable-list-template'); if (!listContainer) return; const searchInput = listContainer.querySelector('#search-input'); const listItems = listContainer.querySelectorAll('#theory-list li'); const noResultsMessage = listContainer.querySelector('.no-results'); searchInput.addEventListener('input', (e) => { const searchTerm = e.target.value.toLowerCase(); let visibleItemsCount = 0; listItems.forEach(item => { const itemText = item.textContent.toLowerCase(); const isVisible = itemText.includes(searchTerm); item.hidden = !isVisible; if(isVisible) { visibleItemsCount++; } }); noResultsMessage.hidden = visibleItemsCount > 0; }); }); </script> </div> </body> </html>