A form that works worldwide

Lily targets every country, not one. It ships no English and assumes no country, so the choices that make a form local are yours, made on purpose. This tutorial walks through them.

What you'll build

A registration form for a clinic that serves people from many countries: a name, a date of birth, an address, a phone number, a fee, and a page that reads right to left when it should. The examples use Svelte; every catalog takes the same props. About 20 minutes, after the accessible forms tutorial.

Step 1 — Names: one field, not two

<label class="label" for="name">Full name</label>
<TextInput id="name" name="name" autocomplete="name" label="Full name" />

"First name" and "last name" fail many people: a single name, a family name first, two family names, a patronymic. Ask for the full name in one field, and if you need what to call someone, ask that separately.

Step 2 — Dates: the parts in the reader's order

<DateField
  label="Date of birth"
  dayLabel="Day"
  monthLabel="Month"
  yearLabel="Year"
  order="dmy"
  autocomplete="bday"
  name="dob"
  bind:value={dob}
/>

order is "dmy", "mdy" or "ymd": pick the one your readers expect, because 03/04 is March in one country and April in the next. The value is always ISO (YYYY-MM-DD), whatever the order. For a date someone only half knows, such as when an illness began, precision="month" stores 2019-03 and never invents a day.

To show a date, format it with Intl.DateTimeFormat in the reader's locale; Lily never formats one for you.

Step 3 — Addresses: no country's shape as the default

<AddressInput label="Home address">
  <label class="label" for="address">Address</label>
  <textarea class="text-area-input" id="address" name="address" autocomplete="street-address" rows="4"></textarea>
  <label class="label" for="country">Country or territory</label>
  <select class="select" id="country" name="country" autocomplete="country"> … </select>
</AddressInput>

AddressInput is a named group; the fields inside are yours. One free-text address plus a country works everywhere. If you split it, do it per country (a postcode is optional or absent in many) and never make a "state" field required.

Step 4 — Phone numbers and money

<TelInput label="Phone number" name="phone" autocomplete="tel" />
<CurrencyInput label="Fee" currencyCode="KES" bind:value={fee} />

Accept a phone number as typed, with spaces and a +; do not force one country's format. CurrencyInput has no default currency: currencyCode (ISO 4217) is required, because a default would be one country's money.

Step 5 — Direction and language

<LocalePicker label="Language" locales={["en", "fr", "ar", "sw"]} bind:value={locale} />

The locale picker sets lang and dir on the page, so Arabic or Hebrew reads right to left. Every Lily component inherits dir; the themes use logical properties (margin-inline-start, not margin-left), and so should your CSS. The picker translates nothing: your text comes from your own translations.

Step 6 — The helpers' labels, in the reader's language

<script lang="ts">
  import { labelsFor } from "@lilydesignsystem/svelte-locale-translations";
  import sw from "@lilydesignsystem/svelte-locale-translations/sw-001";
  import DataGrid from "@lilydesignsystem/svelte-data-grid";
</script>

<DataGrid label="Wagonjwa" labels={labelsFor("data-grid", sw)} … />

The data grid, kanban board, calendar, Gantt chart and filter carry many screen-reader labels. Lily ships them in 64 languages as label packs. Only English is reviewed; the other 63 are machine drafts, so have a native speaker check the screen-reader wording before you rely on one. A pack never falls back to another language.

Check your work: switch the page to Arabic and check that the layout mirrors with no text clipped; enter a date in your order and confirm the submitted value is ISO; give someone a one-word name, and an address with no postcode, and make sure the form takes both.

Next steps

  • Training — eight modules, each with an exercise and a self-check.
  • National identifiers: 164 components for 82 identifier types across more than 50 countries, each an -input and a -view.
  • Preference helpers: language, text size, motion and time zone.
  • Locales: the languages the site and the label packs cover.