Skip to main content

Form Components
Ready

This template shows how to use the different form components that Duet provides. Please note that the example below does not represent a real use case.

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.


Open in new window
<!DOCTYPE html>
<html class="duet-bg-gradient duet-sticky-footer" 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.jsdelivr.net/npm/@duetds/fonts@1.3.12/lib/localtapiola.css" integrity="sha384-5JYmtSD7nykpUvSmTW1CHMoBDkBZUpUmG0vuh+NUVtZag3F75Kr7+/JU3J7JV6Wq" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@duetds/css@1.4.6/lib/duet.min.css" integrity="sha384-pCjsyofCzuxv5DPuTf+kg3QNWqVN0ZwRTCgvvNWCkI38A42MtkN2EK2I2e28j+wB" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@duetds/tokens@2.0.30/lib/tokens.custom-properties.css" integrity="sha384-arb0dRY7eabL9qYMLabGqlrgO9p75pZ9lvaqh3xpLpNUUW6KBtRjKqkSwBv3HyLp" crossorigin="anonymous" />
<script type="module" src="https://cdn.jsdelivr.net/npm/@duetds/components@4.2.6/lib/duet/duet.esm.js" integrity="sha384-ytNH4bICrleu6OXiFr0GctdjoojY5a4B3/H3+Z0wTQOB9eUcbh6i7GbP2QykjM4k" crossorigin="anonymous"></script>
<script nomodule src="https://cdn.jsdelivr.net/npm/@duetds/components@4.2.6/lib/duet/duet.js" integrity="sha384-j/SZhqGHRSMeQPpiO0sIu1NANTpsXU23YSk3+nfvGaUM9SvRrOaN15rhsFO4k6L4" crossorigin="anonymous"></script>
</head>
<body>
<duet-header language="fi" skip-to-id="#content" contact="Ota yhteyttä" current-href="/vakuutukset/"></duet-header>
<duet-layout sticky id="content">
<div slot="main">
<duet-card padding="large">
<duet-spacer breakpoint="x-small" size="medium"></duet-spacer>
<form action="#">
<duet-heading level="h1" visual-level="h2">Ota yhteyttä</duet-heading>
<duet-paragraph>
Lähetä meille viesti kun olet muuttamassa, haluat antaa palautetta tai pyytää
yhteydenottoa. Jos olet jo asiakkaamme, asiasi hoituu parhaiten, kun kirjaudut
verkkopalveluun.
</duet-paragraph>
<duet-spacer size="medium"></duet-spacer>
<duet-choice-group value="one" label="Asiointikieli" direction="horizontal" name="group" responsive>
<duet-choice label="Suomi" type="radio" value="one" expand></duet-choice>
<duet-choice label="Svenska" type="radio" value="two" expand></duet-choice>
<duet-choice label="English" type="radio" value="three" expand></duet-choice>
</duet-choice-group>
<duet-grid responsive>
<duet-input label="Etunimi" name="first name" placeholder="Matti" expand required>
</duet-input>
<duet-input label="Sukunimi" name="last name" placeholder="Meikäläinen" expand required>
</duet-input>
</duet-grid>
<duet-input
label="Katuosoite"
name="address"
placeholder="Kadunnimi 1 A 2"
tooltip="Hello, I’m a tooltip! To close me, you can click outside of
the tooltip or hit ESC key."

required
expand>

</duet-input>
<duet-select label="Kaupunki" name="city" placeholder="Valitse…" expand></duet-select>
<duet-range-slider label="Sijoitettava pääoma" value="3000" min="100" max="10000" step="100" unit="" expand>
</duet-range-slider>
<duet-grid responsive>
<duet-input label="Postinumero" name="zip" value="96100" expand disabled>
</duet-input>
<duet-input label="Postitoimipaikka" name="city" value="Rovaniemi" expand disabled>
</duet-input>
</duet-grid>
<duet-toggle label="Hyväksyn ehdot" identifier="toggle" checked></duet-toggle>
<duet-number-input label="Korvattava summa" value="100000" min="50000" max="500000" step="5000" unit="" expand>
</duet-number-input>
<duet-input label="Puhelinnumero" name="phone" type="tel" placeholder="+358" required expand>
</duet-input>
<duet-input label="Sähköposti" name="email" type="email" placeholder="nimi@email.com" required expand>
</duet-input>
<duet-textarea
label="Viesti asiakaspalveluun"
placeholder="Kirjoita tähän"
tooltip="Hello, I’m a tooltip! To close me, you can click outside
of the tooltip, hit ESC key or click the X button."

expand>

</duet-textarea>
<duet-divider></duet-divider>
<duet-radio-group responsive label="Yhteydenoton syy" direction="horizontal" value="one" name="group1">
<duet-radio label="Tarvitsen apua" value="one"></duet-radio>
<duet-radio label="Ongelma" value="two"></duet-radio>
<duet-radio label="Kysymys" value="three"></duet-radio>
</duet-radio-group>
<duet-divider></duet-divider>
<duet-label>Haluatko viestin myös sähköpostiisi?</duet-label>
<duet-checkbox label="Kyllä" checked></duet-checkbox>
<duet-spacer size="x-large"></duet-spacer>
<duet-button variation="primary" submit>Lähetä viesti</duet-button>
<duet-button>Keskeytä</duet-button>
</form>
</duet-card>
</div>
<div slot="sidebar">
<duet-card padding="large" heading="Sivupalsta">
Sivupalstaa voidaan käyttää pääsisältöön liittyvän tiedon näyttämiseen
tai vaihtoehtoisesti nostamaan esiin aiheeseen liittyvää muuta sisältöä.
</duet-card>
</div>
</duet-layout>
<duet-footer logo-href="#" language="fi"></duet-footer>
<script>
// Save references to components we want to adjust below
var header = document.querySelector("duet-header")
var footer = document.querySelector("duet-footer")
var select = document.querySelector("duet-select")

// Set the header main navigation items
header.items = [
{ label: 'Etusivu', href: '#' },
{ label: 'Vakuutukset', href: '/vakuutukset/' },
{ label: 'Vahinkoasiat', href: '#' },
{ label: 'Säästöt ja sijoitukset', href: '#' },
{ label: 'Laskut', href: '#', badge: true },
{ label: 'Viestit', href: '#' }
]

// Set the contact menu items
header.contactItems = [
{ label: "Lähetä viesti", href: "/viestit/laheta" },
{ label: "Avaa chat", href: "/chat/" },
{ label: "Yhteystiedot", href: "/yhteystiedot/" }
]

// Set the language menu items
header.languageItems = [
{ label: "Suomeksi", country: "fi", href: "/?lang=fi" },
{ label: "På Svenska", country: "sv", href: "/?lang=sv" },
{ label: "In English", country: "en", href: "/?lang=en" }
]

// Set label and href for session link
header.session = {
label: "Kirjaudu ulos",
href: "/?logout",
type: "logout"
}

// Set label and href for user profile link
header.user = {
label: "Laura",
href: "/?userId=1234"
}

// Listen for change events inside the navigation component
header.addEventListener("duetChange", function(ev) {
var event = ev.detail.originalEvent
var data = ev.detail.data
if (data.href !== "#content") {
event.preventDefault()
}
})

// Set the main links in footer
footer.items = [
{ label: 'Hae korvausta', href: '#', icon: 'navigation-make-claim' },
{ label: 'Osta vakuutus', href: '#', icon: 'action-buy-insurance' },
{ label: 'Yhteystiedot', href: '#', icon: 'form-tel' }
]

// Set the help menu items in footer
footer.menu = [
{ label: 'Turvallisuus ja käyttöehdot', href: '#' },
{ label: 'Evästeet', href: '#' },
{ label: 'Henkilötietojen käsittely', href: '#', external: true },
]

// Set select menu items and their values
select.items = [
{ label: "Helsinki", value: "1" },
{ label: "Tampere", value: "2" },
{ label: "Vantaa", value: "3" },
{ label: "Espoo", value: "4" }
]
</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

Tutorials

Using CLI Tools

Tutorials

Creating Custom Patterns

Tutorials

Server Side Rendering

Tutorials

Sharing Prototypes

Tutorials

Usage With Markdown


Troubleshooting

If you experience any issues while using a template, please head over to the Support page for more guidelines and help.