Validation List Item

A validation list item is one rule inside a validation-list, with a status of pending, passed, or failed exposed via a data-status attribute for consumer styling.

Use it inside ValidationList to represent each individual validation rule that the user must satisfy.

Example

ValidationListItem
Show demo markup
<div class="validation-list-item" aria-label="one validation rule in a validation list with a status of pending, passed, or failed">ValidationListItem</div>
Usage example
<script lang="ts">
  import ValidationList from '../ValidationList/ValidationList.svelte';
  import ValidationListItem from './ValidationListItem.svelte';
</script>

<ValidationList label="Password requirements">
  <ValidationListItem status="passed">At least 8 characters</ValidationListItem>
  <ValidationListItem status="pending">One uppercase letter</ValidationListItem>
  <ValidationListItem status="failed">One number</ValidationListItem>
</ValidationList>
Show Svelte source
// In your Svelte component:
import ValidationListItem from "lily-design-system-svelte-headless/components/ValidationListItem/ValidationListItem.svelte";

<ValidationListItem>
  <!-- ValidationListItem content -->
</ValidationListItem>

Usage

Pending rule:

<ValidationListItem status="pending">At least 8 characters</ValidationListItem>

Passed rule:

<ValidationListItem status="passed">At least one number</ValidationListItem>

Failed rule with screen-reader override:

<ValidationListItem status="failed" label="Symbol requirement not met">
  At least one symbol
</ValidationListItem>

Composition

This component is part of the *List *ListItem composition pattern. It must be a child of ValidationList.

Props

  • status: "pending" | "passed" | "failed" (default: "pending")
  • label: string (optional) -- aria-label override
  • children: slot -- rule text (e.g., "At least 8 characters")
  • ...restProps: any additional HTML attributes

Keyboard Interactions

  • None — the item is not interactive
  • Tab moves focus past the item

ARIA

  • Implicit listitem role from <li> element
  • aria-label is rendered when label is supplied
  • data-status exposes the rule state for consumer styling and consumer JS
  • Status changes are announced through the parent validation-list's aria-live="polite"

When to Use

  • Use as a child of ValidationList to represent one validation rule.
  • Use to expose pending / passed / failed state via data-status for visual treatment.

When Not to Use

  • Do not use outside a ValidationList.
  • Do not use as a generic checklist item — use CheckListItem instead.

Headless

Renders only the <li> and its data-status. The status icon (dot, check, cross) and color treatment are entirely the consumer's responsibility, driven by [data-status="pending"], [data-status="passed"], and [data-status="failed"] selectors.

Styles

Consumer CSS targets the validation-list-item class with [data-status] attribute selectors:

.validation-list-item[data-status="pending"] { /* pending styles */ }
.validation-list-item[data-status="passed"] { /* passed styles */ }
.validation-list-item[data-status="failed"] { /* failed styles */ }

Testing

  • Verify the component renders an <li> element with class validation-list-item
  • Verify data-status defaults to "pending"
  • Verify data-status reflects the status prop
  • Verify aria-label is rendered when label is supplied
  • Verify children render inside the item
  • Verify additional HTML attributes pass through to the root <li>

Advice

  • Designers: Use color plus an icon to signal each status — never color alone. Pending should look passive (gray dot), passed should look successful (green check), failed should look corrective (red cross).
  • Developers: Update the status prop reactively as the user types. The parent ValidationList's aria-live="polite" ensures the change is announced.

Implementation Notes

  • Renders a native <li> element with class validation-list-item
  • status prop is one of "pending", "passed", or "failed" (default "pending")
  • status is rendered as a data-status attribute on the <li> for consumer styling
  • label prop is optional — when supplied it sets aria-label (overriding the children text as the accessible name)
  • Children render the rule text (e.g., "At least 8 characters")
  • Pass-through attributes are forwarded to the root <li>

Related components

  • validation-list — a live-feedback list of input validation rules with pending, passed, and failed states

References

  • US Web Design System Validation: https://designsystem.digital.gov/components/validation/
  • HTML <li>: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/li
  • WCAG 1.4.1 Use of Color: https://www.w3.org/WAI/WCAG22/Understanding/use-of-color

Canonical contract

Generated from this component's canonical metadata — the machine-checked source the implementations are held to.

Metadata

  • Component: validation-list-item
  • PascalCase: ValidationListItem
  • Description: one validation rule in a validation list with a status of pending, passed, or failed
  • Status: beta — implemented and unit-tested in all seven frameworks with an axe-clean demo page; not yet exercised in composed flows
  • HTML tag: <li>
  • CSS class: .validation-list-item
  • Interactive: no

ARIA

  • Implicit listitem role from the <li> element
  • aria-label is rendered only when label is provided
  • data-status exposes rule state for consumer styling

Keyboard

  • None — the item is not interactive
  • Tab moves focus past the item

Props

  • status: "pending" | "passed" | "failed" (default: "pending")
  • label: string (optional) -- aria-label override
  • children: slot -- rule text
  • ...restProps: any additional HTML attributes