Chalk UI
Getting started
Customization
Dark Mode
CLI
Components
Accordion
Address Input
Alert
App Layout
Autocomplete
Avatar
Badge
Breadcrumbs
Button
Calendar
Card
Carousel
Chart (Area)
Chart (Bar)
Chart (Donut)
Chart (Line)
Checkbox
Checkbox Group
Collapsible
Combobox
Command
Currency Input
DataGrid
Date Picker
Date Range Picker
Disclosure
Drawer
Dropdown Menu
Form
Horizontal Draggable Scroll
Hover Card
Loading Spinner
Loading Overlay
Modal
Native Select
Navigation Menu
Number Input
Page Header
Pagination
Phone Input
Popover
Progress Bar
Radio Group
Scroll Area
Select
Separator
Simple Dropzone
Skeleton
Static Tabs
Stats
Switch
Table
Tabs
Text Input
Textarea
Timeline
Toaster
Tooltip
Vertical Menu

Phone Input

A text input component for entering international telephone numbers. Based on the ReactPhoneNumberInput.

Source

Installation

npx @rahimstack@latest add phone-input

Usage

Uncontrolled

  • Input type: tel
  • Value type: string
  • The selected country will also be submitted as a separate field of name {input_name}_country.

API Reference

const PhoneInputAnatomy = defineStyleAnatomy({
    root: cva([
        "UI-PhoneInput__root",
        "rounded-l-none z-[2]",
    ]),
    container: cva([
        "UI-PhoneInput__container",
        "relative flex items-center w-full",
    ]),
    countrySelect: cva([
        "UI-PhoneInput__countrySelect",
        "w-[3rem] z-[3] relative flex-none cursor-pointer truncate rounded-r-none border-r-transparent opacity-0",
        "focus-visible:opacity-100 transition duration-200 ease-in-out",
    ], {
        variants: {
            hasLeftAddon: {
                true: "rounded-l-none",
                false: null,
            },
        },
    }),
    flagSelect: cva([
        "UI-PhoneInput__flagSelect",
        "absolute top-0 left-0 w-[3rem] z-[0] flex-none cursor-pointer truncate rounded-r-none border-r-0",
    ], {
        variants: {
            hasLeftAddon: {
                true: "rounded-l-none border-l-0",
                false: null,
            },
        },
    }),
    flagImage: cva([
        "UI-PhoneInput__flagImage",
        "w-6 absolute h-full inset-y-0 z-[0]",
    ]),
})