~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0
44 lines · 926 B Raw History
<script lang="ts">
	import type { HTMLInputAttributes } from 'svelte/elements';
	import Input from '#lib/atoms/Input.svelte';

	// A field with its label, joined to what is said of it (`describedby`).
	let {
		id,
		label,
		type = 'text',
		value = $bindable(''),
		element = $bindable(),
		autocomplete,
		describedby,
		invalid = false,
		readonly = false
	}: {
		id: string;
		label: string;
		type?: 'text' | 'password';
		value?: string;
		element?: HTMLInputElement;
		autocomplete: HTMLInputAttributes['autocomplete'];
		describedby?: string;
		invalid?: boolean;
		readonly?: boolean;
	} = $props();
</script>

<div class="field">
	<label for={id}>{label}</label>
	<Input {id} {type} {autocomplete} {describedby} {invalid} {readonly} bind:value bind:element />
</div>

<style>
	.field {
		display: flex;
		flex-direction: column;
		gap: var(--space-1-5);
	}

	label {
		font-weight: var(--weight-medium);
	}
</style>