Skip to content

Form Association (FACE) Playbook ​

A Contact Form demonstrating Form Associated Custom Elements (FACE) across React, Vue, and Lit — ag-input, ag-radio, ag-checkbox, ag-selection-button-group, and ag-toggle submitting natively with the parent <form>, programmatic validation via form.elements, form.reset() restoring all fields without manual state management, and CSS :state() pseudo-classes for styling from outside the shadow DOM.

New to FACE?

Read the Form Association guide first — it explains the core concepts, framework-specific gotchas, and how to inspect FACE in action.

Live Examples ​

Open React in StackBlitzOpen Vue in StackBlitzOpen Lit in StackBlitz

Working Examples ​

Three complete implementations are available in the repository:

FrameworkSourceRun
Reactreact-example/cd react-example && npm install && npm run dev
Vuevue-example/cd vue-example && npm install && npm run dev
Litlit-example/cd lit-example && npm install && npm run dev

Each example logs form.elements, the validateAll result, and the FormData entries to the console so you can watch FACE work in real time.

Form Fields ​

FieldnameComponentValidation
Full NamefullNameag-input (text)required
Email Addressemailag-input (email)required
Phonephoneag-input (tel)optional
Messagemessageag-input (textarea)required
Preferred contact methodcontactMethodag-radio group (email/phone/either)required
Newsletter signupsubscribeag-checkboxoptional
Newsletter frequencyfrequencyag-selection-button-group (radio)required
Terms & Conditionstermsag-togglerequired

Components Used ​

ComponentPurpose
ag-inputText, email, tel, and textarea fields (FACE-enabled)
ag-radioRequired radio group — preferred contact method (FACE-enabled)
ag-checkboxOptional newsletter signup (FACE-enabled)
ag-selection-button-groupRadio group for newsletter frequency (FACE-enabled)
ag-toggleRequired terms acceptance (FACE-enabled)
ag-buttonSubmit and Clear actions
ag-cardForm and result containers
ag-dividerVisual separator

:state() CSS Demo

The form includes a live :state() demo — ag-radio, ag-checkbox, and ag-toggle get a green dashed outline when :state(checked) and a red dashed outline when :state(invalid). The submit handler logs each element's :state(checked) and :state(invalid) values to the console.

Supported in Chrome 125+, Firefox 126+, and Safari 17.4+. See the Form Association guide for details.

Generate Your Own with an LLM ​

Use the PROMPT files to build a Contact Form from scratch:

PromptOutputUse when
PROMPT-3-FRAMEWORKS.mdreact-example/, vue-example/, lit-example/Build all three at once
PROMPT-REACT.mdReact appReact only
PROMPT-VUE.mdVue appVue only
PROMPT-LIT.mdLit appLit only
bash
cd v2/playbooks/form-association
claude  # or your LLM of choice

# Then ask:
> Please follow the instructions in PROMPT-3-FRAMEWORKS.md

Further Reading ​