InputDate

输入日期并通过日历选择。

实时预览

正在加载预览…

参数配置

全部字段 52

InputDateOptions

Styles · 0
CalendarOptions
Styles · 0

InputDateOptions2

Styles · 0
CalendarOptions
Styles · 0

Go 代码

Go
// Inside a view; c is *ui.Context, t is nui.Theme.
// Keep s (example state) outside the view. See the complete example.
nui.InputDate(c.Key("date"), t, &s.Value, &s.Date, nui.InputDateOptions{InputOptions: nui.InputOptions{Label: "Project name", Placeholder: "Type something…", Color: nui.ColorDefault, Size: nui.SizeDefault, Variant: nui.VariantDefault, Disabled: false, ReadOnly: false, Loading: false}, HideCalendar: false})
nui.InputDateRange(c.Key("range"), t, &s.Range, &s.RangeInput, nui.InputDateOptions{InputOptions: nui.InputOptions{Label: "Date range", Placeholder: "Type something…", Color: nui.ColorDefault, Size: nui.SizeDefault, Variant: nui.VariantDefault, Disabled: false, ReadOnly: false, Loading: false}, HideCalendar: false})

使用说明

上方编辑单个日期,下方 InputDateRange 编辑日期区间。可以输入日期或展开日历;两个示例共用外观、禁用、只读和 hideCalendar 快捷参数,值和编辑状态分别持久保存。

API 参考

InputDate

源码
func InputDate(c *ui.Context, t Theme, value *Optional[Date], s *DateInputState, o InputDateOptions) ui.Element

InputDateRange

源码
func InputDateRange(c *ui.Context, t Theme, value *DateSelection, s *DateRangeInputState, o InputDateOptions) ui.Element

InputDateOptions

源码
type InputDateOptions struct {
	HideCalendar bool
	InputOptions
	Calendar      CalendarOptions
	OnValueChange func(Optional[Date])
}
字段类型说明
HideCalendarbool

Go 零值: false

隐藏日期输入的日历入口。

Labelstring

Go 零值: ""

控件标签或可访问名称。

Placeholderstring

Go 零值: ""

没有输入或选择时的占位文字。

ErrorMessagestring

Go 零值: ""

显式提供的错误说明。

Disabledbool

Go 零值: false

禁用组件及其交互。

ReadOnlybool

Go 零值: false

允许读取和选择内容,但禁止编辑。

Invalidbool

Go 零值: false

使用无效输入的视觉状态。

Passwordbool

Go 零值: false

遮蔽输入内容。

Clearablebool

Go 零值: false

显示清空操作或允许清除当前值。

ClearLabelstring

Go 零值: ""

清空操作的可访问名称。

ColorColor

Go 零值: ColorDefault

语义颜色;默认值继承主题或组件配色。

VariantVariant

Go 零值: VariantDefault

组件外观样式,支持范围取决于组件。

SizeSize

Go 零值: SizeDefault

组件尺寸;默认值继承主题或组件尺寸。

Leading*ui.SVG

Go 零值: nil

内容前方的 SVG 图标。

Trailing*ui.SVG

Go 零值: nil

内容后方的 SVG 图标。

Loadingbool

Go 零值: false

显示加载状态;是否阻止操作由组件决定。

LoadingIcon*ui.SVG

Go 零值: nil

覆盖默认加载图标。

Highlightbool

Go 零值: false

突出显示控件或选中项目。

MaxLengthint

Go 零值: 0

输入长度上限,原生文本以 UTF-16 单元计数;零表示不限。

OnChangefunc(string)

Go 零值: nil

值发生变化时通知应用的回调。

OnSubmitfunc(string)

Go 零值: nil

提交表单或输入时通知应用的回调。

OnClearfunc()

Go 零值: nil

清空值时通知应用的回调。

UIStyles

Go 零值: zero value

以部件名称为键覆盖外观和间距。

Stylefunc(root, editor, leading, trailing ui.Element)

Go 零值: nil

同步配置当前构建的部件;不要保留 Element。

CalendarCalendarOptions

Go 零值: zero value

内嵌日历的配置。

OnValueChangefunc(Optional[Date])

Go 零值: nil

解析后的值变化时通知应用的回调。