@capgo/capacitor-date-picker

中文文档
8.1.14发布于 2026/10/15MPL-2.0TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 5.6万

Native Capacitor date picker for iOS, Android, and web with fixes for long-standing community issues.

原始使用文档
文档目录15 节
  1. ➡️ Get started for free
  2. Key features
  3. What We Fixed
  4. Demo
  5. Screenshots
  6. Install
  7. Usage
  8. Platform Notes
  9. API
  10. present(...)
  11. presentRange(...)
  12. hide()
  13. getPluginVersion()
  14. Interfaces
  15. Type Aliases

@capgo/capacitor-date-picker

Show the native date and time picker from your Capacitor app on iOS and Android, with a web fallback. Pick dates, times, year and month, or a date range with one call.

Capgo - Build Capacitor apps with AI, ship updates instantly

Capgo: push fixes to your Capacitor users in minutes, build signed iOS and Android apps without a Mac, and roll back in one click.

➡️ Get started for free

14-day unlimited free trial. No credit card required

🤖 Building with an AI coding agent? Install Capgo skills so Claude Code, Codex, Cursor, Copilot, or Gemini CLI know how to install and use @capgo/capacitor-date-picker in your Capacitor app: npx skills add Cap-go/capgo-skills. Then ask your agent: "Add @capgo/capacitor-date-picker to my Capacitor app and wire it up." Agent setup guides · Hosted MCP

Animated iOS demo showing the native date picker opening, selecting a date, and closing

Key features

  • Picker modes: date, time, dateAndTime, countDownTimer, yearAndMonth (iOS and web) and range.
  • Range picking: presentRange() returns a start and end date.
  • Customization: locale, light or dark theme, and minuteStep for time pickers.
  • Control: present() opens the picker and hide() closes it.
  • Platforms: iOS, Android and Web. Native pickers on iOS and Android, browser fallback on web.

Native date, time, date-time, year-month, and range picker for Capacitor 8 on iOS, Android, and web.

This is Capgo's maintained alternative to @capacitor-community/date-picker. The main difference is maintenance speed: we listen to community reports, fix issues fast, and ship updates instead of leaving long-standing GitHub issues open.

What We Fixed

  • Capacitor 8 support.
  • Web implementation with the same present() API.
  • Programmatic hide().
  • Dialog title support.
  • iOS rotation-safe layout.
  • iOS locale handling for inline day/month labels.
  • iOS yearAndMonth mode.
  • No iOS force unwrap crash on invalid dates.
  • ISO, Java/Unicode, and common Moment-style formats such as YYYY-MM-DD.
  • Date-only timezone handling without one-day shifts.
  • iOS min and max parsing with ISO strings.
  • Android nested android options.
  • Android is24h.
  • Android dateAndTime keeps the chosen date when moving to time.
  • Android dialog width/layout handling.
  • Android UI-thread dialog handling so native dialogs open reliably from Capacitor calls.
  • Minute steps for time pickers.
  • Range selection via presentRange().

Demo

iOSAndroid
Animated iOS demo showing the native date picker opening, selecting a date, and closingAnimated Android demo showing the native date picker opening, selecting a date, and closing

Screenshots

iOSAndroid
iOS native date pickerAndroid native date picker

Install

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins

Then use the following prompt:

Use the `capacitor-plugins` skill from `cap-go/capacitor-skills` to install the `@capgo/capacitor-date-picker` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

npm install @capgo/capacitor-date-picker
npx cap sync

Usage

import { DatePicker } from '@capgo/capacitor-date-picker';

const result = await DatePicker.present({
  mode: 'date',
  date: '2026-05-27',
  min: '2026-01-01',
  max: '2026-12-31',
  format: 'yyyy-MM-dd',
  title: 'Select a date',
});

console.log(result.value);
const time = await DatePicker.present({
  mode: 'time',
  is24h: true,
  minuteStep: 15,
  format: 'HH:mm',
});
const range = await DatePicker.presentRange({
  start: '2026-05-01',
  end: '2026-05-27',
  format: 'yyyy-MM-dd',
  startTitle: 'Start date',
  endTitle: 'End date',
});

console.log(range.start, range.end);

Platform Notes

  • iOS uses UIDatePicker with Auto Layout so the picker survives screen rotation.
  • Android uses platform DatePickerDialog and TimePickerDialog; range selection is two native date selections.
  • Web uses native browser inputs in a small modal wrapper.
  • minuteStep is rounded to a platform-supported interval on iOS.

API

present(...)

present(options?: DatePickerOptions | undefined) => Promise<DatePickerResult>

Present the date picker.

ParamType
optionsDatePickerOptions

Returns: Promise<DatePickerResult>


presentRange(...)

presentRange(options?: DatePickerRangeOptions | undefined) => Promise<DatePickerRangeResult>

Present a range picker. Native platforms use two native date selections; web shows start and end controls in one dialog.

ParamType
optionsDatePickerRangeOptions

Returns: Promise<DatePickerRangeResult>


hide()

hide() => Promise<void>

Close the currently visible picker, if any.


getPluginVersion()

getPluginVersion() => Promise<PluginVersionResult>

Returns the platform implementation version marker.

Returns: Promise<PluginVersionResult>


Interfaces

DatePickerResult

PropTypeDescription
valuestring | nullFormatted value. Null means the picker was dismissed.

DatePickerOptions

PropTypeDescription
minstringMinimum selectable value.
maxstringMaximum selectable value.
datestringInitial selected value.
iosDatePickerIosOptionsPlatform-specific iOS options override top-level options.
androidDatePickerAndroidOptionsPlatform-specific Android options override top-level options.

DatePickerIosOptions

PropTypeDescriptionDefault
styleDatePickerIosStyleiOS picker style."inline"
titleFontColorstring
titleBgColorstring
bgColorstring
fontColorstringPicker text color on iOS. Uses private textColor KVC when supported; otherwise falls back to tintColor (accent only, not guaranteed wheel label text).
buttonBgColorstring
buttonFontColorstring
mergedDateAndTimebooleanShow date and time in one UIDatePicker when possible.

DatePickerAndroidOptions

PropTypeDescription
themeDatePickerThemeAndroid dialog theme resource name or built-in theme key.

DatePickerRangeResult

PropTypeDescription
startstring | nullFormatted start value. Null means the picker was dismissed.
endstring | nullFormatted end value. Null means the picker was dismissed.
valuestring | nullConvenience "start/end" value when both dates are selected.

DatePickerRangeOptions

PropTypeDescription
startstringInitial range start value.
endstringInitial range end value.
startTitlestringTitle used while choosing the start date.
endTitlestringTitle used while choosing the end date.

PluginVersionResult

PropType
versionstring

Type Aliases

DatePickerIosStyle

'wheels' | 'inline' | 'compact' | 'automatic'

DatePickerTheme

'light' | 'dark' | string

版本与发布记录

@capgo/capacitor-date-picker 共发布 11 个版本,首次发布于 2026/05/28;过去 12 个月发布了 11 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
8.1.14latest2026/10/1525 天前
8.1.132026/10/1327 天前
8.1.122026/10/1030 天前
8.1.112026/10/1030 天前
8.1.102026/10/091 个月前
8.1.82026/10/081 个月前

关于 @capgo/capacitor-date-picker 的常见问题

@capgo/capacitor-date-picker 是什么?

Native Capacitor date picker for iOS, Android, and web with fixes for long-standing community issues.

如何安装 @capgo/capacitor-date-picker?

在项目目录运行 npm install @capgo/capacitor-date-picker,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capgo/capacitor-date-picker 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@capgo/capacitor-date-picker 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@capgo/capacitor-date-picker 可以商用吗?

@capgo/capacitor-date-picker 使用 MPL-2.0 许可。弱 Copyleft:可以商用,也可以和闭源代码一起使用;但如果分发时修改了 MPL 授权的文件,这些文件的修改需以 MPL 开源。以上为概括,不构成法律意见,请以许可原文为准。

@capgo/capacitor-date-picker 的下载量有多少?

根据 npm 官方下载统计,@capgo/capacitor-date-picker 在 2026/10/09 – 2026/11/07 这 30 天内被下载 56,418 次,日均约 1,881 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@capgo/capacitor-date-picker 还在维护吗?

最新版本 8.1.14 发布于 2026/10/15(25 天前);至今共发布 11 个版本,其中过去 12 个月发布了 11 个;首次发布于 2026/05/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。