Skip to main content

TimePicker
component

A component used to select a time through a dialog.

[boolean, (visible: boolean) => void]
required

Controls the visible state, and a callback to set the visible state as false when the dialog closes.

'inline' | 'spinner'
Default: 'inline'

Whether to display the picker in inline (clock) mode or spinner mode. iOS only supports 'spinner'.

boolean
Default: false

(Android only) Whether the clock displays in 24 hour time instead of 12 hour time.

(selected: string) => void

A callback for changes.

string
Default: The current time

The selected time.

Was this section helpful?

TimePicker

import React, {useState} from 'react';
import {
Button,
TimePicker,
Screen,
Text,
reactExtension,
} from '@shopify/ui-extensions-react/point-of-sale';

const SmartGridModal = () => {
const [date, setDate] = useState(
new Date().toDateString(),
);
const visibleState = useState(false);

return (
<Screen name="Home" title="Home">
<Text>Selected date: {date}</Text>
<Button
title="Show"
onPress={() => {
visibleState[1](true);
}}
/>
<TimePicker
visibleState={visibleState}
onChange={(selected) => {
setDate(
new Date(selected).toDateString(),
);
}}
selected={date}
is24Hour={true}
inputMode={'spinner'}
/>
</Screen>
);
};

export default reactExtension(
'pos.home.modal.render',
() => <SmartGridModal />,
);

Preview