Skip to content
tcpsystemsui

Theme

Colour scheme
Accent
Density
Radius
Esc

Field

Label, hint, control and error wired together. The label is required.

beta

Examples

Basic label and hint

Used as the hostname for internal routing
Basic label and hint.svelte
<script lang="ts">
	import Field from '@tcpsystems/ui/foundation/Field';
	import Input from '@tcpsystems/ui/foundation/Input';
	let serviceName = $state('tcpsystems-api');
</script>

<Field label="Service name" hint="Used as the hostname for internal routing">
	{#snippet control(props)}
		<Input {...props} bind:value={serviceName} />
	{/snippet}
</Field>

Validation

Must be a valid DNS name
Name must start with a letter and contain only lowercase letters, numbers, and hyphens
Validation.svelte
<script lang="ts">
	import Field from '@tcpsystems/ui/foundation/Field';
	import Input from '@tcpsystems/ui/foundation/Input';
	let serviceName = $state('');
</script>

<Field label="Service name" hint="Must be a valid DNS name" error="Name must start with a letter and contain only lowercase letters, numbers, and hyphens" optional>
	{#snippet control(props)}
		<Input {...props} bind:value={serviceName} invalid="true" />
	{/snippet}
</Field>

API

Import
import Field from '@tcpsystems/ui/foundation/Field';
PropTypeDefault
mode?'field' | 'count''field'
label?string''
hint?stringnone
error?stringnone
optional?booleanfalse
value?string''
max?number0
id?stringnone
Snippet
control
HookKind
.tcp-char-countRoot class
data-stateData attribute