interface DateFieldProps {
    autoComplete: string;
    autoFocus?: boolean;
    calendarButtonAriaLabel?: string;
    children?: ReactNode;
    className?: string;
    color?: "primary" | "secondary";
    customAttribute?: {
        attribute: string;
        value: string | number;
    };
    customCalendarButtonRef?: Ref<HTMLButtonElement>;
    customTranslation?: DeepPartial<Translation>;
    defaultValue?: any;
    disabled?: boolean;
    endIcon?: Element;
    error?: boolean;
    errorHelperText?: string;
    FormHelperTextProps?: FormHelperTextProps;
    fullWidth?: boolean;
    helperText?: string;
    id: string;
    InputLabelProps?: Partial<InputLabelProps>;
    inputProps?: InputBaseComponentProps;
    InputProps?: Partial<InputProps> | Partial<OutlinedInputProps> | Partial<FilledInputProps>;
    inputRef?: Ref<any>;
    isCalendarOpen?: boolean;
    isLoading?: boolean;
    isSearchField?: boolean;
    label?: ReactNode;
    lang: "sv" | "en";
    margin?: "none" | "normal" | "dense";
    maxDate?: string;
    maxRows?: string | number;
    minDate?: string;
    minRows?: string | number;
    multiline?: boolean;
    numeric?: boolean;
    onAccept?: ((value: string) => void);
    onChange?: ((event: ChangeEvent<HTMLInputElement>) => void);
    onClick?: ((event: MouseEvent<Element, MouseEvent>) => void);
    onFocus?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
    onKeyDown?: ((event: KeyboardEvent<HTMLInputElement>) => void);
    onKeyUp?: ((event: KeyboardEvent<HTMLInputElement>) => void);
    onMouseLeave?: (() => void);
    onMouseOver?: (() => void);
    onToggleCalendar?: (() => void);
    placeholder?: string;
    required?: boolean;
    rounded?: boolean;
    rows?: string | number;
    select?: boolean;
    SelectProps?: Partial<SelectProps>;
    showCalendarButton?: boolean;
    skeletonSx?: SxProps<Theme>;
    startIcon?: Element;
    sx?: SxProps<Theme>;
    timeZone?: string;
    translation?: {
        optional: string;
    };
    type?: string;
    valid?: boolean;
    value: string;
    variant?: "filled" | "standard" | "outlined";
}

Hierarchy (view full)

Properties

autoComplete: string

TODO: Use explicit types via HTMLInputElement["autocomplete"] after upgrading to Typescript 5.1

autoFocus?: boolean

If true, the input element will be focused during the first mount. Use with caution as it can cause accessibility issues.

calendarButtonAriaLabel?: string

Aria label for calendar button.

children?: ReactNode
className?: string

Optional CSS class name.

color?: "primary" | "secondary"

The color of the component. It supports those theme colors that make sense for this component.

customAttribute?: {
    attribute: string;
    value: string | number;
}

Used for tests. Clickable and requested subcomponents will be suffixed with "-[ComponentName]".

customCalendarButtonRef?: Ref<HTMLButtonElement>

Use this if you want to bypasss internal focus handling

customTranslation?: DeepPartial<Translation>

Translation object used for screen reader texts.

defaultValue?: any

The default value of the input element.

disabled?: boolean

If true, the component is disabled.

endIcon?: Element

Place an icon to end the text field with

error?: boolean

Indicates if the component is in an error state, applying error-specific styling for validation feedback.

errorHelperText?: string

Helper text message that will be displayed on error.

FormHelperTextProps?: FormHelperTextProps

Props applied to the FormHelperText element.

fullWidth?: boolean

If true, the input will take up the full width of its container.

helperText?: string

The helper text content.

id: string

The id of the input element. Use this prop to make label and helperText accessible for screen readers. This is mandatory for WCAG 2.1 compliance.

InputLabelProps?: Partial<InputLabelProps>

Props applied to the InputLabel element.

inputProps?: InputBaseComponentProps

Attributes applied to the input element.

InputProps?: Partial<InputProps> | Partial<OutlinedInputProps> | Partial<FilledInputProps>

Props applied to the Input element. Depending on the variant prop value, it will be a FilledInput, OutlinedInput, or Input component.

inputRef?: Ref<any>

ref attribute that will be set on the input element

isCalendarOpen?: boolean

Determines if the calendar is open.

isLoading?: boolean

If true, a loading skeleton will be rendered instead of the component.

isSearchField?: boolean

Set this to true if the component is used as search field.

label?: ReactNode

The label content.

lang: "sv" | "en"

Language used for localization and date formatting.

margin?: "none" | "normal" | "dense"

If dense or normal, will adjust vertical spacing of this and contained components.

maxDate?: string

Disable all dates after this. Expected in 'yyyy-MM-dd' format.

maxRows?: string | number

Maximum number of rows to display when multiline option is set to true.

minDate?: string

Disable all dates before this. Expected in 'yyyy-MM-dd' format.

minRows?: string | number

Minimum number of rows to display when multiline option is set to true.

multiline?: boolean

If true, a textarea element will be rendered instead of an input.

numeric?: boolean

If the input is used for numeric data. Displays numeric keyboard on mobile devices.

onAccept?: ((value: string) => void)

Callback that is fired when input value passes validation

onChange?: ((event: ChangeEvent<HTMLInputElement>) => void)

Callback when field changes.

onClick?: ((event: MouseEvent<Element, MouseEvent>) => void)

Click listener for the text field wrapper. IMPORTANT! Only use in special circumstances, e.g. in TravellerField component

onFocus?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>

Callback when field is focused.

onKeyDown?: ((event: KeyboardEvent<HTMLInputElement>) => void)
onKeyUp?: ((event: KeyboardEvent<HTMLInputElement>) => void)
onMouseLeave?: (() => void)
onMouseOver?: (() => void)
onToggleCalendar?: (() => void)

Function to run on open calendar button.

placeholder?: string

The short hint displayed in the input before the user enters a value.

required?: boolean

If true, the label is displayed as required and the input element` will be required.

rounded?: boolean

Makes the input rounded

rows?: string | number

Number of rows to display when multiline option is set to true.

select?: boolean

Render a Select element while passing the Input element to Select as input parameter. If this option is set you must pass the options of the select as children.

SelectProps?: Partial<SelectProps>

Props applied to the Select element.

showCalendarButton?: boolean

Determines whether to display the Calendar IconButton within the DateField.

skeletonSx?: SxProps<Theme>

Custom styles for Skeleton.

startIcon?: Element

Place an icon to start the text field with

sx?: SxProps<Theme>

The system prop that allows defining system overrides as well as additional CSS styles.

timeZone?: string

Set timezone for the DateField

translation?: {
    optional: string;
}

Provide local translations to be used in TextField

type?: string

Type of the input element. It should be a valid HTML5 input type.

valid?: boolean

If true, a green checkmark icon will be displayed inside the text field.

value: string

DateField value.

variant?: "filled" | "standard" | "outlined"

The variant to use.