intlList
intlList(value, options?) builds a localized list string from multiple values. Use it for breadcrumb-like segments, summaries, or UI helper text like shipping/payment terms.
It maps directly to: Intl.ListFormat
Input shape
value can be:
string[]- space-separated text (
"A B C")
ts
1import { intlList } from '@beforesemicolon/intl'2 3intlList(['shipping', 'tax', 'discounts'])4intlList('shipping tax discounts')Signature
ts
1function intlList(2 value: string[] | string,3 options?: {4 locale?: string5 scope?: IntlRuntime6 type?: 'conjunction' | 'disjunction' | 'unit' | 'and' | 'or' | 'none'7 style?: 'long' | 'short' | 'narrow'8 localeMatcher?: 'lookup' | 'best fit'9 }10): stringInvalid or empty input returns ''.
Option map
| Option | Type | Default | Effect |
|---|---|---|---|
locale | string | runtime locale | Locale for this list |
scope | IntlRuntime | getIntl() | Use scoped runtime for locale fallback |
type | conjunction | disjunction | unit | and | or | none | conjunction | Grammar behavior |
style | long | short | narrow | long | Full vs compact list text |
localeMatcher | lookup | best fit | best fit | Locale negotiation algorithm |
and, or, and none are convenience aliases for conjunction, disjunction, and unit behavior.
Examples
Default behavior
ts
1intlList(['A', 'B', 'C'])2intlList('A B C', { locale: 'en-US' })Type variations
ts
1intlList(['A', 'B', 'C'], { type: 'conjunction', style: 'long' }) // and2intlList(['A', 'B', 'C'], { type: 'or', style: 'short' }) // or3intlList(['A', 'B', 'C'], { type: 'none', style: 'narrow' }) // punctuation onlyScope and locale overrides
ts
1import { createIntl, intlList } from '@beforesemicolon/intl'2 3const scoped = createIntl({ locale: 'fr-FR', messages: {} })4 5intlList(['A', 'B', 'C'], { scope: scoped })6intlList('A B C', { locale: 'de-DE', style: 'short' })Empty output rules
ts
1intlList([]) // ''2intlList('') // ''