pub struct DatePicker<Msg: Clone> {
pub value: Date,
pub view_year: i32,
pub view_month: u8,
pub today: Option<Date>,
pub on_change: Option<Arc<dyn Fn(Date) -> Msg>>,
pub on_navigate: Option<Arc<dyn Fn(i32, u8) -> Msg>>,
pub locale: Locale,
pub width: Option<f32>,
}Expand description
Calendar date selector.
Fields§
§value: Date§view_year: i32§view_month: u8§today: Option<Date>§on_change: Option<Arc<dyn Fn(Date) -> Msg>>§locale: Locale§width: Option<f32>Implementations§
Source§impl<Msg: Clone + 'static> DatePicker<Msg>
impl<Msg: Clone + 'static> DatePicker<Msg>
Sourcepub fn new(value: Date) -> Self
pub fn new(value: Date) -> Self
Create a date picker with the given selected date. The view
month defaults to the same month as value; override with
Self::view when the user is browsing without selecting.
Sourcepub fn view(self, year: i32, month: u8) -> Self
pub fn view(self, year: i32, month: u8) -> Self
Override the visible month. Call this from your view function
with whatever (year, month) your application state stores
for “the calendar’s current page”.
Sourcepub fn today(self, today: Date) -> Self
pub fn today(self, today: Date) -> Self
Mark a specific date as “today” — drawn with a subtle accent ring even if it is not selected.
Sourcepub fn on_change(self, f: impl Fn(Date) -> Msg + 'static) -> Self
pub fn on_change(self, f: impl Fn(Date) -> Msg + 'static) -> Self
Day-tap callback. Required for the picker to be interactive.
Arrow-tap callback. The runtime calls f(new_year, new_month)
when the user taps prev / next. Wire to your view-month state.
Sourcepub fn locale(self, l: Locale) -> Self
pub fn locale(self, l: Locale) -> Self
Override the locale (month / day-of-week names + week start).
Sourcepub fn width(self, w: f32) -> Self
pub fn width(self, w: f32) -> Self
Outer width the picker will be laid out at. Used to shrink the header / day-of-week / day-cell font sizes so the widest labels (“30”, “September 2026”, “Mié”) still fit without ellipsis. When unset, the picker uses the design defaults and may truncate inside very narrow rects.
Trait Implementations§
Source§impl<Msg: Clone + 'static> From<DatePicker<Msg>> for Element<Msg>
impl<Msg: Clone + 'static> From<DatePicker<Msg>> for Element<Msg>
Source§fn from(d: DatePicker<Msg>) -> Self
fn from(d: DatePicker<Msg>) -> Self
Auto Trait Implementations§
impl<Msg> Freeze for DatePicker<Msg>
impl<Msg> !RefUnwindSafe for DatePicker<Msg>
impl<Msg> !Send for DatePicker<Msg>
impl<Msg> !Sync for DatePicker<Msg>
impl<Msg> Unpin for DatePicker<Msg>
impl<Msg> !UnwindSafe for DatePicker<Msg>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more