Display a date input widget that can be configured to accept a single date or a date range.
Method Signatures and Parameters | |
Jt.dateInput(String label) | label (String) A short label explaining to the user what this date input is for. Markdown is supported, see |
Chainable builder methods | |
value(java.time.LocalDate value) | The value of this widget when it first renders. Can be a specific date or |
minValue(java.time.LocalDate minValue) | The minimum selectable date. If |
maxValue(java.time.LocalDate maxValue) | The maximum selectable date. If |
help(String help) | A tooltip that gets displayed next to the text. If this is |
onChange(function.Consumer<java.time.LocalDate> onChange) | An optional callback invoked when the date input's value changes. The value passed to the callback is the previous value of the component. |
format(String format) | Controls how dates are displayed in the interface. Supported formats: |
disabled(boolean disabled) | Disable the date input if set to true. When disabled, users cannot interact with the widget. |
labelVisibility(JtComponent.LabelVisibility labelVisibility) | The visibility of the label. The default is |
width(String width) | Controls the widget's width. Can be |
width(int widthPixels) | The width of the element in pixels. The element will have a fixed width. If the specified width is greater than the width of the parent container, the width of the element matches the width of the parent container. |
key(String key) | A string to use as the unique key for the widget. If this is omitted, a key will be generated for the widget based on its content. No two widgets may have the same key. |
No description | |
use() | Put the widget in the app, in the |
use(JtContainer container) | Put the widget in the app, in the provided container. |
Returns after .use() | |
(LocalDate) | The current LocalDate value of the component. |
Examples
Simple date input
import tech.catheu.jeamlit.core.Jt;
import java.time.LocalDate;
import java.time.Period;
public class DateInputApp {
public static void main(String[] args) {
LocalDate birthday = Jt.dateInput("Your birthday").use();
if (birthday != null) {
int age = Period.between(birthday, LocalDate.now()).getYears();
Jt.text("You are " + age + " years old").use();
}
}
}
Still have questions?
Go to our discussions forum for helpful information and advice from Jeamlit experts.