---
title: "DateRangePicker 组件 — zenit Zig UI"
description: "选择 start / end 两端日期。范围顺序、双输入状态、日历高亮和浮层生命周期由一个组件协调。"
url: https://zenit.z.express/zh/components/daterange
language: zh-CN
alternate_en: https://zenit.z.express/components/daterange.md
alternate_es: https://zenit.z.express/es/components/daterange.md
alternate_ja: https://zenit.z.express/ja/components/daterange.md
alternate_ko: https://zenit.z.express/ko/components/daterange.md
alternate_fr: https://zenit.z.express/fr/components/daterange.md
alternate_de: https://zenit.z.express/de/components/daterange.md
project: zenit v0.1.0-alpha (Zig 0.15.2, macOS)
source: https://github.com/version-next/zenit
---

# DateRangePicker

`ui.widgets.DateRangePicker`

选择 start / end 两端日期。

[Video](https://zenit.z.express/media/stories/daterange.mp4?v=ce0dbf06cf)

**BEHAVIOR CONTRACT**

范围顺序、双输入状态、日历高亮和浮层生命周期由一个组件协调。

**RECORDED INTERACTION**

Harness 点击 Start date，范围日历展开。

`examples/storybook/stories.zig:2469`

```zig
// ── DateRangePicker ──
pub fn buildDateRangePicker(scope: *ui.Scope, cx: *ui.Cx) anyerror!*ui.Node {
    const drp = try W.DateRangePicker(.{ .initial_year = 2026, .initial_month = 5 }).mount(scope, cx);
    return drp.wrapper;
}
```

[在 GitHub 查看源码examples/storybook/stories.zig:2469](https://github.com/version-next/zenit/blob/HEAD/examples/storybook/stories.zig#L2469)

这是 Storybook 中该 story 的原样代码（zenit 5f9add5+wip 2026-09-30）。其中 `W` 即 `ui.widgets`，`col` / `row` / `label` 是 Storybook 内的布局小工具。

### DateRangePickerProps

`ui.widgets.DateRangePicker`

[src/ui/components/date\_range\_picker/mod.zig:27](https://github.com/version-next/zenit/blob/HEAD/src/ui/components/date_range_picker/mod.zig#L27)

```zig
fn DateRangePicker(props: DateRangePickerProps) DateRangePickerBuilder
```

| 字段 | 类型 | 默认值 | 说明 |
| --- | --- | --- | --- |
| `placeholder_start` | `[]const u8` | `"Start date"` | — |
| `placeholder_end` | `[]const u8` | `"End date"` | — |
| `start_date` | `?SimpleDate` | `null` | — |
| `end_date` | `?SimpleDate` | `null` | — |
| `initial_year` | `u16` | `2025` | — |
| `initial_month` | `u8` | `1` | — |
| `width` | `f32` | `320` | — |
| `size` | `theme.ControlSize` | `.md` | 控件尺寸（与 Button / Input / Select 同一 ControlSize，默认 md） |
| `disabled` | `bool` | `false` | — |
| `on_change` | `?core.HandlerRef` | `null` | — |
| `calendar_icon_asset` | `?svg_assets.Asset` | `null` | — |
| `prev_icon_asset` | `?svg_assets.Asset` | `null` | — |
| `next_icon_asset` | `?svg_assets.Asset` | `null` | — |
| `test_id` | `?[]const u8` | `null` | — |

### DateRangePickerResult

`ui.widgets.DateRangePicker`

[src/ui/components/date\_range\_picker/mod.zig:133](https://github.com/version-next/zenit/blob/HEAD/src/ui/components/date_range_picker/mod.zig#L133)

| 字段 | 类型 | 默认值 | 说明 |
| --- | --- | --- | --- |
| `wrapper` | `*Node` | — | — |
| `state` | `*DateRangePickerState` | — | — |
