This is a form components library for Svelte 5. It prioritizes simplicity over flexibility. The primary goals of this library are to do the following:
pnpm add easy-forms-svelte
Then add this line to 'tailwind.config.ts' or 'tailwind.config.js' depending on your project setup.
import forms from '@tailwindcss/forms';
import type { Config } from 'tailwindcss';
export default {
content: [
'./src/**/*.{html,js,svelte,ts}',
'./node_modules/easy-forms-svelte/**/*.{svelte,js,ts}' // <- Add this
],
theme: {
extend: {}
},
plugins: [forms]
} satisfies Config;
pnpm remove easy-forms-svelte
Then remove the following line from 'tailwind.config.ts' or 'tailwind.config.js':
export default {
content: [
'./src/**/*.{html,js,svelte,ts}',
'./node_modules/easy-forms-svelte/**/*.{svelte,js,ts}' <- REMOVE
],
...
}
<script lang="ts">
import { Form, TextInput } from 'easy-forms-svelte';
let email = $state('');
function handleSubmit(event: SubmitEvent) {
// Handle form submission
}
</script>
<Form on_submit={handleSubmit}>
<TextInput
name="email"
type="email"
label="Email"
bind:value={email}
required
/>
</Form>
The library works out of the box in English without any additional setup.
For multi-language support, install the optional dependencies:
npm install i18n-iso-countries svelte-i18n
Register languages in your app's entry point:
import countries from 'i18n-iso-countries';
import en from 'i18n-iso-countries/langs/en.json' assert { type: 'json' };
import fr from 'i18n-iso-countries/langs/fr.json' assert { type: 'json' };
countries.registerLocale(en);
countries.registerLocale(fr);
Set up svelte-i18n:
import { locale } from 'svelte-i18n';
// Set initial locale
locale.set('en');
// Switch language
locale.set('fr');
Components like CountryInput will automatically display content in the active locale.
pnpm install
pnpm run storybook