Form
The Form component is a thin wrapper around the HTML <form> element that automatically prevents default browser submission behavior.
Props
Prop | Type | Default | Description |
|---|---|---|---|
class | string | '' | CSS classes to apply to the form. |
overrideDefaultStyling | boolean | false | If true, removes the base fluid-form class. |
children | Snippet | required | The content of the form. |
...rest | HTMLFormAttributes | — | Standard HTML form attributes. |
Samples
Basic Form
A standard form wrapper that automatically handles preventDefault on
submission.
0
<script>1
import { Form, InputField, Button, Container, Text } from 'fluid-ui-svelte/base';2
let username = $state('');3
</script>4
5
<Form class="gap-4">6
<Container class="flex flex-col gap-2">7
<Text type="span" class="text-sm font-medium">Username</Text>8
<InputField bind:value={username} placeholder="Enter username" />9
</Container>10
11
<Button12
type="submit"13
class="fluid-button-primary"14
onclick={async (event, buttonState) => {15
buttonState.inProgress = true;16
await new Promise((resolve) => setTimeout(resolve, 1000));17
buttonState.inProgress = false;18
}}19
>20
{#snippet loadingPlaceholder()}21
<span>Submitting...</span>22
{/snippet}23
Submit24
</Button>25
</Form>