react-thaizip

Read-only address display

Format an already-resolved Thai address as readable text, with no address-index loading

ThaiAddressDisplay is for pages that show an address you already have, such as an order summary or a user profile. It is purely presentational — no Base UI, and no address-index loading.

Install

npx react-thaizip add address-display

The command adds the component and utils only, to the directories recorded in thaizip.config.json — unlike the other components, this one does not pull in the address-index loading hook.

Basic usage

Import from the location generated in your project:

import { ThaiAddressDisplay, type ThaiAddressDisplayValue } from '@/components/thai-address-display'

export function OrderAddress({ address }: { address: ThaiAddressDisplayValue | null }) {
  return <ThaiAddressDisplay value={address} />
}

value takes an already-resolved address (ResolvedThaiAddress plus optional houseNo/moo/soi/street), or null when there is no address yet, which renders emptyText instead.

Full address

Address display

A read-only formatter for a resolved (optionally full) address.

99/9 Moo 4 Soi 2 สุขุมวิท, Khlong Tan Nuea > Watthana > Bangkok 10110

Multi-line layout

Use mode="multi-line" to render the house-number/moo/soi/street portion and the sub-district/district/province portion as separate rows.

<ThaiAddressDisplay value={address} mode="multi-line" />
Address display

A read-only formatter for a resolved (optionally full) address.

99/9 Moo 4 Soi 2 สุขุมวิทKhlong Tan Nuea > Watthana > Bangkok 10110

Thai output

Use locale="th" for Thai names. "หมู่"/"ซอย" automatically become the standard transliterations "Moo"/"Soi" only under locale="en" — the house number and street name always render exactly as supplied.

แสดงที่อยู่

ตัวจัดรูปแบบที่อยู่แบบอ่านอย่างเดียว จากที่อยู่ที่เลือกครบแล้ว (จะมีบ้านเลขที่หรือไม่ก็ได้)

99/9 หมู่ 4 ซอย2 สุขุมวิท, คลองตันเหนือ > วัฒนา > กรุงเทพมหานคร 10110

No house-level fields

When value has none of houseNo/moo/soi/street, only the sub-district/district/province portion is rendered.

Address display

A read-only formatter for a resolved (optionally full) address.

Khlong Tan Nuea > Watthana > Bangkok 10110

No address yet

Pass value={null} to render emptyText instead (the default is "No address" or "ไม่มีที่อยู่", based on locale).

Address display

A read-only formatter for a resolved (optionally full) address.

No address

Props

Value

PropTypeDescription
valueThaiAddressDisplayValue | nullThe address to render; null renders emptyText instead. The only required prop.
locale'th' | 'en'Drives the locality label and the default emptyText; defaults to 'th'.
mode'single-line' | 'multi-line''single-line' (default) joins the street portion and the locality with ', '; 'multi-line' renders them as two rows.
emptyTextstringReplacement text when value is null; defaults to 'No address' ('ไม่มีที่อยู่' when locale="th").

Class slots

PropApplied to
classNameThe root <address>
lineClassNameEach row in 'multi-line' mode

Ref

PropTypeDescription
refReact.Ref<HTMLElement>Forwarded to the <address> element.

See Customization to change the presentation. To let people choose or edit an address instead of only displaying it, see address form or cascade select.

On this page