Date Picker Themes
@pglejzer/datepicker-ui, the companion of timepicker-ui, ships ten themes. Set ui.theme and import index.css or a single theme file.
Ten themes
#The themes are basic, m3-green, crane, crane-straight, m2, glassmorphic, pastel, ai, cyberpunk and blueprint. basic is the default and follows Material Design 3 in light and dark. Use the select in the demo to switch the theme.
One version and two schemes
#basic and blueprint follow ui.colorScheme. The other themes have one version and keep their own scheme, so ui.colorScheme has no effect on them.
Glassmorphic
glassmorphic blurs what is behind the picker, so it needs a coloured background there.The themes are named like the ones in timepicker-ui, but datepicker-ui has no dark or blueprint-dark. For a dark picker, use basic or blueprint with a dark color scheme.
CSS files
#| Import | Contains |
|---|---|
| @pglejzer/datepicker-ui/index.css | The core and every theme |
| @pglejzer/datepicker-ui/main.css | The core only, which is enough for basic |
| @pglejzer/datepicker-ui/theme-m3-green.css | One theme, to load next to main.css |
The other theme files follow the same pattern: theme-crane.css, theme-crane-straight.css, theme-m2.css, theme-glassmorphic.css, theme-pastel.css, theme-ai.css, theme-cyberpunk.css and theme-blueprint.css. To load a single theme, import main.css first:
import DatepickerUI from "@pglejzer/datepicker-ui";import "@pglejzer/datepicker-ui/main.css";import "@pglejzer/datepicker-ui/theme-m2.css";new DatepickerUI("#date", { ui: { theme: "m2" } }).create();
Color scheme
#ui.colorScheme is "light", "dark" or "auto" (the default). With "auto" the scheme is detected when the picker opens, in this order:
- The first mostly opaque
background-colorfound on the input or one of its ancestors decides, and dark means low luminance. - Without one, the page
color-schemedecides.darkis dark,light darkfollows the OS setting and anything else is light.
An inline picker re-detects when the page changes its class, style, data-theme or data-color-scheme, or when the OS setting changes. This site passes the scheme explicitly, so the demos follow the site dark mode toggle.
new DatepickerUI("#date", {ui: { theme: "basic", colorScheme: "dark" },}).create();
Custom theme
#A theme sets CSS variables. Add your own selector with ui.cssClass:
new DatepickerUI("#date", { ui: { cssClass: "brand" } }).create();
.brand {--dp-ui-sys-color-primary: #006a6a;--dp-ui-sys-color-on-primary: #ffffff;--dp-ui-sys-color-secondary-container: #cce8e7;--dp-ui-container-shape-docked: 8px;}
The class is added to the surface root, which is the <dialog> for a modal and the .dp-ui__container element otherwise. The full list of variables is on the CSS Variables page.