skip section navigation

FormField

FormField is a legacy convenience wrapper for an existing string-valued field. it combines the field family, a label, a hint and a visible required marker. pass the value separately from the child control so the marker can reflect it.

required

give this collection a name.

usage

svelte
<script>
	import { FormField, Input } from '@ciabi/loafkit-ui';
	let title = $state('');
</script>

<FormField label="Collection title" id="collection-title" hint="give this collection a name."
	long={false} required={true} value={title}>
	<Input id="collection-title" bind:value={title} required />
</FormField>

composition

  • FormField
    • Input (or another string-valued control)

the required-value marker

the marker appears when required is true and value.trim() is empty. this is a display check, not native form validation. put required on the actual Input too if the browser should enforce it.

long gives the child wrapper a minimum height; it doesn’t turn the child into a textarea. use Input’s multiline for that. the hint has no generated ID, so it isn’t automatically linked with aria-describedby. choose the field family when you need explicit hint and error relationships.

API reference

FormField

Component
label

visible field label.

id

control ID used by the label.

hint

hint text; use an empty string when no hint is needed.

long

gives the child wrapper a minimum height.

required

shows a missing-value marker when value.trim() is empty.

value

the child control’s current string, used by the marker.

children

the separately labelled and bound control.

class
Default: ''

extra classes on the component root.

style

inline styles on the component root.