#date #widgets #egui #picker #datepicker #date-picker

egui-datepicker

Adds date picker widget for egui gui library

4 releases (2 breaking)

0.3.0 Jan 14, 2022
0.2.0 Dec 1, 2021
0.1.1 Oct 19, 2021
0.1.0 Oct 18, 2021

#543 in GUI

47 downloads per month

MIT/Apache

14KB
212 lines

egui-datepicker

Latest version

This library provide a simple date picker widget for egui with some customization. Checkout the gif to see widget in action!

⚡️ Quickstart

Add egui-datepicker as dependency to your project

[dependencies]
egui-datepicker = "0.3"

Import necessary structs

use egui_datepicker::{DatePicker, Date, Utc};

or if you already include chrono in your project

use egui_datepicker::DatePicker;
use chrono::{Date, offset::Utc};

Add date field with selected time offset in app struct

struct MyApp {
    date: Date<Utc>,
}

Add widget in update function

fn update(/*snip*/) {
    /*snip*/
    ui.add(DatePicker::new("datepicker-unique-id", &mut self.date));
    /*snip*/
}

👀 Customization

You can set first day of week to sunday with

DatePicker::new(/*snip*/).sunday_first(true)

Make popup window movable

DatePicker::new(/*snip*/).movable(true)

Set different date format

DatePicker::new(/*snip*/).date_format("%d/%m/%Y")

⚠️ License

egui-datepicker is licensed under MIT OR Apache-2.0

Dependencies

~5–9MB
~166K SLoC