Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Buttons

  • Button
  • ShimmerButton
  • InteractiveHoverButton
  • RainbowButton
  • PulsatingButton
  • RippleButton
  • ButtonGroup
  • SocialButton

Basic Inputs

  • Input
  • Textarea
  • CellEditor
  • Select
  • Checkbox
  • CheckboxGroup
  • Radio
  • Switch
  • Toggle
  • Segmented
  • Slider
  • NumberField
  • ElasticSlider

Advanced Inputs

  • MathTextarea
  • QuestionEditor
  • QuestionAnswer
  • MathField
  • SecretField
  • PasswordGenerator
  • Combobox
  • RemoteSelect
  • Listbox
  • Mentions
  • InputOTP
  • Rating
  • Upload
  • RegionSelect
  • ImageCropper
  • ScopeMatrix
  • Transfer
  • Cascader
  • TreeSelect
  • RegionCascader
  • CountrySelect
  • MarkdownEditor
  • Novel editor
  • RichTextEditor
  • CodeEditor
  • IssueReporter
  • ColorPicker
  • ColorField
  • ColorSwatchPicker
  • Choicebox
  • EmojiPicker
  • VoiceRecord
  • IconPicker
  • InspectorPanel

Date and Time

  • Calendar
  • DatePicker
  • DateTimePicker
  • DateRangePicker
  • TimePicker
  • TimeField

Form Frameworks

  • Form
  • ModalForm / DrawerForm
  • ProForm
  • StepsForm
  • LoginForm
  • AuthPanel
  • ClickCaptcha
  • Label
  • Field
  • SearchForm

CountrySelect

country-select

Searches and selects countries with codes, flags, and optional calling prefixes.

Usage

Basic usage

Single-select the country/region, and the search will match all fields of Chinese/English/code/area code.

tsx
<CountrySelect defaultValue="CN" className="w-72" />

Show area code

showDialCode Fill in the international area code on the right side of the drop-down line.

tsx
<CountrySelect defaultValue="US" showDialCode className="w-72" />

Multiple choice (chips)

multiple has been selected to be echoed as chips, and you can continue to search and add.

🇨🇳China
🇺🇸United States
🇯🇵Japan
tsx
<CountrySelect multiple defaultValue={["CN", "US", "JP"]} className="w-80" />

Size

size supports sm / md / lg.

tsx
<>
  <CountrySelect size="sm" defaultValue="GB" className="w-72" />
  <CountrySelect size="lg" defaultValue="FR" className="w-72" />
</>

Disabled / Invalid state

disabled blocks interaction; invalid trigger becomes danger stroke.

tsx
<>
  <CountrySelect disabled defaultValue="FR" className="w-72" />
  <CountrySelect invalid className="w-72" />
</>

When to use

Use CountrySelect to choose one or more countries or regions from 250 built-in entries with flag emoji, Chinese and English names, and dialing codes. Search accepts either language, ISO codes, and dialing codes. Use Combobox for a custom flat list or RegionCascader for Chinese provinces and cities.

Import

ts
import { CountrySelect, getCountry, flagEmoji, countrySearchText, filterCountries, countries } from "@hulianui/ui"

Props

NameTypeDefaultDescription
valuestring | string[]-Controlled value: single selection is ISO2 code string; multiple selection is code array
defaultValuestring | string[]-uncontrolled initial value
multiplebooleanfalseMultiple selection (chips)
showEnglishbooleantrueWhether to display the English name in the option line
showDialCodebooleanfalseWhether the item line displays the international area code
placeholderstring"\u9009\u62e9\u56fd\u5bb6/\u5730\u533a"Trigger placeholder; the built-in Chinese copy means “Select a country or region.”
searchPlaceholderstring"\u641c\u7d22\u56fd\u5bb6 / \u533a\u53f7\u2026"Search placeholder; the built-in Chinese copy means “Search country or dialing code…”.
size"sm" | "md" | "lg""md"Trigger size
disabledbooleanfalseDisable
invalidbooleanfalseInvalid state
classNamestring-Additional class name for the trigger.

Events

EventTypeDescription
onChange(next: string | string[]) => voidSelect change callback; single selection returns string, multiple selection returns string[]

Usage guidelines

  • value and onChange use string in single-select mode and string[] in multi-select mode. The callback exposes the union type, so narrow it from multiple or with an as type assertion before treating it as an array.
  • Stored values are ISO 3166-1 alpha-2 codes such as "CN", not display names. Resolve display data with getCountry(code).
  • Native attributes that are not listed in Props (aria-*, data-*, id, title, …) land on the trigger (the input inside the chips shell in multiple mode) rather than on the outer container, because that is the element which takes focus and is announced. The aria-required injected by <Field required> travels the same way (#293).

Related

SecretField · Combobox · Listbox · Mentions · InputOTP · Rating

Playground

value:(empty)
<CountrySelect value={code} onChange={setCode} showDialCode />
{/* Multiple selection */}
<CountrySelect multiple value={codes} onChange={setCodes} />
PreviousRegionCascaderFormsNextMarkdownEditor

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Events
    • Usage guidelines
    • Related
  • Playground