#025
Phone and CEP
A PhoneField and a CepField that looks up an address asynchronously and prints the resolved street, district and city.
Hand this to your AI. It names the exact library parts, timings and accessibility promises of this demo.
Build the "Phone and CEP" pattern (@codeatlasdev/ui demo #025, inputs/masked-field) in my app.
Call get_demo({ ids: ["#025"] }) first and keep its structure. It needs @codeatlasdev/[email protected].
Use: Brazilian address and contact forms that autofill street data from a postal code lookup.
Keep these library parts, with the props and tokens the demo uses:
- CepField, PhoneField, CepAddress from "@codeatlasdev/ui/forms"
Behaviour to keep:
- `<PhoneField label="WhatsApp" bind:value={phone} />`
- `<CepField` with `label="CEP"` and `description="Try 01310-100."`
- `bind:lookupPending={pending}`, `onlookup={lookup}` and `onresolve={(a) => (address = a)}`
- `async function lookup(raw: string)` waits 600 ms and returns a `CepAddress` only for `01310100`, otherwise `null`
- Result line shows `Looking up…` while pending, then `logradouro`, `bairro`, `localidade` and `uf`
Reduced motion: the demo handles it; keep that branch.
Keyboard: operable; keep the focus order and key handling.
Change only the copy and the data. Use the theme tokens (--ca-*), never raw colours. Library parts
- CepField
@codeatlasdev/ui/forms - PhoneField
@codeatlasdev/ui/forms
How it is built
- `<PhoneField label="WhatsApp" bind:value={phone} />`
- `<CepField` with `label="CEP"` and `description="Try 01310-100."`
- `bind:lookupPending={pending}`, `onlookup={lookup}` and `onresolve={(a) => (address = a)}`
- `async function lookup(raw: string)` waits 600 ms and returns a `CepAddress` only for `01310100`, otherwise `null`
- Result line shows `Looking up…` while pending, then `logradouro`, `bairro`, `localidade` and `uf`
Related
Loading source.