Search Ready
This template shows how to build a completely search user interface that utilizes different Duet component to create the flow of content.
Hint: Press F
on your keyboard to view both templates and components in fullscreen and ESC
to exit the fullscreen mode. You can also open the template in a new browser window.
<!DOCTYPE html>
<html lang="fi">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<title>LähiTapiola</title>
<link rel="stylesheet" href="https://cdn.duetds.com/api/fonts/3.0.51/lib/localtapiola.css" integrity="sha384-5JYmtSD7nykpUvSmTW1CHMoBDkBZUpUmG0vuh+NUVtZag3F75Kr7+/JU3J7JV6Wq" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdn.duetds.com/api/css/4.0.45/lib/duet.min.css" integrity="sha384-UoMJnpXiN8f7fKVnTzfKfyi7LzQlApQ+WTS9O3PXlYr6CO9yzou4glfsHV747f3v" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdn.duetds.com/api/tokens/4.0.59/lib/tokens.custom-properties.css" integrity="sha384-AexjbYNj18dJLZR54wNVU44b/akdDc+tpbLIWhAnzjMAbwFSli2DHpSP+7NCK+Xw" crossorigin="anonymous" />
<script type="module" src="https://cdn.duetds.com/api/components/8.7.1/lib/duet/duet.esm.js" integrity="sha384-c3hLghWHTPntUxndMlK4myD7d59stA2U0EvBp2rPb3ibtacAwh56geBpq6z7nXLn" crossorigin="anonymous"></script>
<script nomodule src="https://cdn.duetds.com/api/components/8.7.1/lib/duet/duet.js" integrity="sha384-H7RH4Ssj/LmElXa1VCHFSIjvtCSoLXMiPXG/KQZTS9EvYujTo7tWaj0V6/GGkY16" crossorigin="anonymous"></script>
</head>
<body>
<duet-button id="search-opener" variation="primary" icon="form-search" fixed>Hae</duet-button>
<duet-slideout opener="search-opener" accessible-role="generic">
<div slot="sticky-header">
<duet-grid alignment="center" style="gap: var(--space-small)">
<duet-icon name="form-search" size="medium" margin="none"></duet-icon>
<duet-heading visual-level="h3" fixed-size margin="none">Haku</duet-heading>
</duet-grid>
<duet-spacer></duet-spacer>
<duet-visually-hidden>
<span>Hakuun vaaditaan vähintään neljä merkkiä. Löydät ehdotetut usein haetut sivut, hakutermit ja hakutulokset haku kentän alapuolelta.</span>
<span aria-live="polite" id="screenreader-assist"></span>
</duet-visually-hidden>
<duet-input id="search" type="text" expand label="Hakukenttä" label-hidden clear="true" debounce="400"></duet-input>
</div>
<duet-spacer size="x-small"></duet-spacer>
<div id="popular">
<duet-heading level="h3" visual-level="h6">Usein haettua</duet-heading>
<div role="list">
<duet-popup-menu-item leading-icon="navigation-arrow-right" leading-icon-color="primary" url="#" accessible-role="listitem">Autovakuutus</duet-popup-menu-item>
<duet-popup-menu-item leading-icon="navigation-arrow-right" leading-icon-color="primary" url="#" accessible-role="listitem">Lapsiturva</duet-popup-menu-item>
<duet-popup-menu-item leading-icon="navigation-arrow-right" leading-icon-color="primary" url="#" accessible-role="listitem">Rahastosäästäminen</duet-popup-menu-item>
<duet-popup-menu-item leading-icon="navigation-arrow-right" leading-icon-color="primary" url="#" accessible-role="listitem">Henkivakuutus</duet-popup-menu-item>
<duet-popup-menu-item leading-icon="navigation-arrow-right" leading-icon-color="primary" url="#" accessible-role="listitem">Varainhoito</duet-popup-menu-item>
</div>
</div>
<div id="suggested" hidden>
<duet-heading level="h3" visual-level="h6" color="gray-darker">Ehdotetut haut</duet-heading>
<div role="list">
<duet-popup-menu-item leading-icon="form-search" leading-icon-color="primary" accessible-role="listitem"><b>auto</b>vakuutus</duet-popup-menu-item>
<duet-popup-menu-item leading-icon="form-search" leading-icon-color="primary" accessible-role="listitem">sähkö<b>auto</b>n vakuutus</duet-popup-menu-item>
<duet-popup-menu-item leading-icon="form-search" leading-icon-color="primary" accessible-role="listitem"><b>auto</b>maattinen korvauskäsittely</duet-popup-menu-item>
<duet-popup-menu-item leading-icon="form-search" leading-icon-color="primary" accessible-role="listitem"><b>auto</b>tie</duet-popup-menu-item>
</div>
<duet-spacer size="large"></duet-spacer>
</div>
<div id="spinner" hidden>
<duet-spinner size="small" theme="default" accessible-label="Ladataan hakutuloksia"></duet-spinner>
</div>
<div id="results" hidden>
<duet-heading level="h3" visual-level="h6" color="gray-darker" id="results-heading">Hakutulokset termillä 'auto' (93)</duet-heading>
<ul style="list-style: none; padding: 0;" id="results-list">
<li style="padding: var(--space-medium) 0;">
<duet-button url="#" variation="plain" margin="none" padding="none" fixed>Autovakuutus</duet-button>
<duet-paragraph margin="none">Halvin autovakuutus ei aina ole järkevin vaihtoehto. Suosittelemme vakuutusten sisällön vertailua ja huomioimaan erityisesti...</duet-paragraph>
<duet-spacer size="xx-small"></duet-spacer>
<duet-breadcrumbs variation="plain" color="gray-darker">
<span><duet-breadcrumb icon="">Henkilöasiakas</duet-breadcrumb></span>
<span><duet-breadcrumb>Vakuutukset</duet-breadcrumb></span>
<span><duet-breadcrumb>Ajoneuvot</duet-breadcrumb></span>
<span><duet-breadcrumb>Autovakuutus</duet-breadcrumb></span>
</duet-breadcrumbs>
</li>
</ul>
</div>
</duet-slideout>
<script>
const search = document.querySelector("#search")
const screenreaderAssist = document.querySelector("#screenreader-assist")
const popular = document.querySelector("#popular")
const suggested = document.querySelector("#suggested")
const spinner = document.querySelector("#spinner")
const results = document.querySelector("#results")
const resultsHeading = document.querySelector("#results-heading")
const resultsList = document.querySelector("#results-list")
search.addEventListener("duetChange", (e) => {
const value = e.detail.value
popular.hidden = true
suggested.hidden = true
results.hidden = true
spinner.hidden = false
screenreaderAssist.innerHTML = `Haetaan.`
setTimeout(() => {
spinner.hidden = true
resultsHeading.innerHTML = `Hakutulokset termillä '${value}' (1).`
screenreaderAssist.innerHTML = `Hakutuloksia termillä '${value}' löytyi 1 kappale.`
popular.hidden = value.length > 3
suggested.hidden = value.length < 4 || value.length > 7
results.hidden = value.length < 4
}, 2000)
})
</script></body>
</html>
Integration
To install this template’s dependencies into your project, run:
npm install @duetds/components
npm install @duetds/css
npm install @duetds/fonts
For further guidelines, please see each package’s documentation.
Tutorials
Follow these practical tutorials to learn how to build simple page layouts using Duet’s CSS Framework, Web Components and other features:
Tutorials
Building Layouts
TutorialsUsing CLI Tools
TutorialsCreating Custom Patterns
TutorialsServer Side Rendering
TutorialsSharing Prototypes
TutorialsUsage With Markdown
Troubleshooting
If you experience any issues while using a template, please head over to the Support page for more guidelines and help.