Skip to content
Source
Sign inSign up
TanStack/form
Open History to see the last commit

FieldError.tsx

21 lines521 Bytes

1import { For } from 'solid-js'
2import type { Accessor } from 'solid-js'
3import type { AnyFieldApi } from '@tanstack/solid-form'
4​
5export function FieldError(props: { field: Accessor<AnyFieldApi> }) {
6 return (
7 <small
8 role={props.field().meta.isInvalid ? 'alert' : undefined}
9 aria-live="polite"
10 >
11 <For each={props.field().errors}>
12 {(error, index) => (
13 <>
14 {index() > 0 ? '\n' : ''}
15 {error.message}
16 </>
17 )}
18 </For>
19 </small>
20 )