# TimePicker
## Description
A BitTimePicker offers a drop-down control that’s optimized for picking a single time from a clock view. You can customize the time picker to fit your scenario, for example by changing the time format or limiting the selectable times.
## Parameters
| Name | Type | Default Value | Description |
| :--- | :--- | :------------ | :---------- |
| AllowTextInput | `bool` | false | Whether the TimePicker allows input a time string directly or not. |
| CalloutAriaLabel | `string` | Clock | Aria label for time picker popup for screen reader users. |
| CalloutHtmlAttributes | `Dictionary<string, object>` | new Dictionary<String, Object>() | Capture and render additional attributes in addition to the main callout's parameters. |
| Classes | `BitTimePickerClassStyles` | null | Custom CSS classes for different parts of the TimePicker. |
| CloseButtonIcon | `BitIconInfo?` | null | Gets or sets the close button icon using custom CSS classes for external icon libraries. Takes precedence over CloseButtonIconName when both are set. |
| CloseButtonIconName | `string?` | Cancel | Gets or sets the name of the close button icon from the built-in Fluent UI icons. |
| CloseButtonTitle | `string` | Close time picker | The title of the close button (tooltip). |
| Culture | `CultureInfo` | CultureInfo.CurrentUICulture | CultureInfo for the TimePicker. |
| DecreaseHourIcon | `BitIconInfo?` | null | Gets or sets the decrease hour button icon using custom CSS classes for external icon libraries. Takes precedence over DecreaseHourIconName when both are set. |
| DecreaseHourIconName | `string?` | ChevronDownSmall | Gets or sets the name of the decrease hour button icon from the built-in Fluent UI icons. |
| DecreaseMinuteIcon | `BitIconInfo?` | null | Gets or sets the decrease minute button icon using custom CSS classes for external icon libraries. Takes precedence over DecreaseMinuteIconName when both are set. |
| DecreaseMinuteIconName | `string?` | ChevronDownSmall | Gets or sets the name of the decrease minute button icon from the built-in Fluent UI icons. |
| DropDirection | `BitDropDirection` | BitDropDirection.TopAndBottom | Determines the allowed drop directions of the callout. |
| HasBorder | `bool` | true | Determines if the TimePicker has a border. |
| HourStep | `int` | 1 | Determines increment/decrement steps for time-picker's hour. |
| Icon | `BitIconInfo?` | null | Gets or sets the icon to display using custom CSS classes for external icon libraries. Takes precedence over IconName when both are set. |
| IconName | `string?` | Clock | Gets or sets the name of the icon to display from the built-in Fluent UI icons. |
| IconLocation | `BitIconLocation` | BitIconLocation.Right | TimePicker icon location. |
| IconTemplate | `RenderFragment?` | null | Custom TimePicker icon template. |
| IncreaseHourIcon | `BitIconInfo?` | null | Gets or sets the increase hour button icon using custom CSS classes for external icon libraries. Takes precedence over IncreaseHourIconName when both are set. |
| IncreaseHourIconName | `string?` | ChevronDownSmall | Gets or sets the name of the increase hour button icon from the built-in Fluent UI icons. |
| IncreaseMinuteIcon | `BitIconInfo?` | null | Gets or sets the increase minute button icon using custom CSS classes for external icon libraries. Takes precedence over IncreaseMinuteIconName when both are set. |
| IncreaseMinuteIconName | `string?` | ChevronDownSmall | Gets or sets the name of the increase minute button icon from the built-in Fluent UI icons. |
| IsOpen | `bool` | false | Whether or not this TimePicker is open. |
| Label | `string?` | null | Label for the TimePicker. |
| LabelTemplate | `RenderFragment?` | null | Used to customize the label for the TimePicker. |
| MinuteStep | `int` | 1 | Determines increment/decrement steps for time-picker's minute. |
| OnClick | `EventCallback` | | Callback for when clicking on TimePicker input. |
| OnFocus | `EventCallback` | | Callback for when focus moves into the TimePicker input. |
| OnFocusIn | `EventCallback` | | Callback for when focus moves into the TimePicker input. |
| OnFocusOut | `EventCallback` | | Callback for when clicking on TimePicker input. |
| OnSelectTime | `EventCallback<TimeSpan?>` | | Callback for when the on selected time changed. |
| Placeholder | `string?` | null | Placeholder text for the DatePicker. |
| Responsive | `bool` | false | Enables the responsive mode in small screens. |
| ShowCloseButton | `bool` | false | Whether the BitTimePicker's close button should be shown or not. |
| Styles | `BitTimePickerClassStyles` | null | Custom CSS styles for different parts of the TimePicker. |
| Standalone | `bool` | false | Whether the BitTimePicker is rendered standalone or with the input component and callout. |
| TimeFormat | `BitTimeFormat` | BitTimeFormat.TwentyFourHours | The time format of the time-picker, 24H or 12H. |
| Underlined | `bool` | false | Whether or not the Text field of the TimePicker is underlined. |
| ValueFormat | `string?` | null | The format of the time in the TimePicker like "HH:mm". |
| DefaultValue | `TValue?` | null | The default value of the input to be used in uncontrolled mode (i.e. when the Value is not bound), typically used alongside the OnChange callback. |
| DisplayName | `string?` | null | Gets or sets the display name for this field. |
| InputHtmlAttributes | `IReadOnlyDictionary<string, object>?` | null | Gets or sets a collection of additional attributes that will be applied to the created element. |
| Name | `string?` | null | Gets or sets the name of the element. Allows access by name from the associated form. |
| NoValidate | `bool` | false | Disables the validation of the input. |
| OnChange | `EventCallback<TValue?>` | | Callback for when the input value changes. |
| ReadOnly | `bool` | false | Makes the input read-only. |
| Required | `bool` | false | Makes the input required. |
| Value | `TValue?` | null | Gets or sets the value of the input. This should be used with two-way binding. |
| AriaLabel | `string?` | null | Gets or sets the accessible label for the component, used by assistive technologies. |
| Class | `string?` | null | Gets or sets the CSS class name(s) to apply to the rendered element. |
| Dir | `BitDir?` | null | Gets or sets the text directionality for the component's content. |
| HtmlAttributes | `Dictionary<string, object>` | new Dictionary<string, object>() | Captures additional HTML attributes to be applied to the rendered element, in addition to the component's parameters. |
| Id | `string?` | null | Gets or sets the unique identifier for the component's root element. |
| IsEnabled | `bool` | true | Gets or sets a value indicating whether the component is enabled and can respond to user interaction. |
| Style | `string?` | null | Gets or sets the CSS style string to apply to the rendered element. |
| TabIndex | `string?` | null | Gets or sets the tab order index for the component when navigating with the keyboard. |
| Visibility | `BitVisibility` | BitVisibility.Visible | Gets or sets the visibility state (visible, hidden, or collapsed) of the component. |
## Public Members
| Name | Type | Default Value | Description |
| :--- | :--- | :------------ | :---------- |
| InputElement | `ElementReference` | | The ElementReference of the input element. |
| FocusAsync() | `() => ValueTask` | | Gives focus to the input element. |
| FocusAsync(bool preventScroll) | `(bool preventScroll) => ValueTask` | | Gives focus to the input element. |
| UniqueId | `Guid` | Guid.NewGuid() | Gets the readonly unique identifier for the component's root element, assigned when the component instance is constructed. |
| RootElement | `ElementReference` | | Gets the reference to the root HTML element associated with this component. |
## Enums
### BitVisibility Enum
| Name | Value | Description |
| :--- | :--- | :---------- |
| Visible | 0 | Show content of the component. |
| Hidden | 1 | Hide content of the component,though the space it takes on the page remains. |
| Collapsed | 2 | Hide content of the component,though the space it takes on the page gone. |
### BitIconLocation Enum
| Name | Value | Description |
| :--- | :--- | :---------- |
| Left | 0 | Show the icon at the left side. |
| Right | 1 | Show the icon at the right side. |
### BitTimePickerEditMode Enum
| Name | Value | Description |
| :--- | :--- | :---------- |
| Normal | 0 | Can edit hours and minutes. |
| OnlyMinutes | 1 | Can edit only minutes. |
| OnlyHours | 1 | Can edit only hours. |
### BitTimeFormat Enum
| Name | Value | Description |
| :--- | :--- | :---------- |
| TwentyFourHours | 0 | Show time pickers in 24 hours format. |
| TwelveHours | 1 | Show time pickers in 12 hours format. |
### BitDropDirection Enum
| Name | Value | Description |
| :--- | :--- | :---------- |
| All | 0 | The direction determined automatically based on the available spaces in all directions. |
| TopAndBottom | 1 | Show the callout at the top or bottom side. |
### BitVisibility Enum
| Name | Value | Description |
| :--- | :--- | :---------- |
| Visible | 0 | The content of the component is visible. |
| Hidden | 1 | The content of the component is hidden, but the space it takes on the page remains (visibility:hidden). |
| Collapsed | 2 | The component is hidden (display:none). |
### BitDir Enum
| Name | Value | Description |
| :--- | :--- | :---------- |
| Ltr | 0 | Ltr (left to right) is to be used for languages that are written from the left to the right (like English). |
| Rtl | 1 | Rtl (right to left) is to be used for languages that are written from the right to the left (like Arabic). |
| Auto | 2 | Auto lets the user agent decide. It uses a basic algorithm as it parses the characters inside the element until it finds a character with a strong directionality, then applies that directionality to the whole element. |
## Sub Classes
### BitTimePickerClassStyles Properties
| Name | Type | Default Value | Description |
| :--- | :--- | :------------ | :---------- |
| Root | `string?` | null | Custom CSS classes/styles for the root element of the BitTimePicker. |
| Focused | `string?` | null | Custom CSS classes/styles for the focused state of the BitTimePicker. |
| Label | `string?` | null | Custom CSS classes/styles for the Label of the BitTimePicker. |
| InputWrapper | `string?` | null | Custom CSS classes/styles for the input wrapper of the BitTimePicker. |
| InputContainer | `string?` | null | Custom CSS classes/styles for the input container of the BitTimePicker. |
| Input | `string?` | null | Custom CSS classes/styles for the input of the BitTimePicker. |
| Icon | `string?` | null | Custom CSS classes/styles for the icon of the BitTimePicker. |
| Overlay | `string?` | null | Custom CSS classes/styles for the overlay of the BitTimePicker. |
| Callout | `string?` | null | Custom CSS classes/styles for the callout of the BitTimePicker. |
| CalloutContainer | `string?` | null | Custom CSS classes/styles for the callout container of the BitTimePicker. |
| TimeInputContainer | `string?` | null | Custom CSS classes/styles for the time input container of the BitTimePicker. |
| HourInputContainer | `string?` | null | Custom CSS classes/styles for the hour input container of the BitTimePicker. |
| IncreaseHourButton | `string?` | null | Custom CSS classes/styles for the increase hour button of the BitTimePicker. |
| IncreaseHourIcon | `string?` | null | Custom CSS classes/styles for the increase hour icon of the BitTimePicker. |
| HourInput | `string?` | null | Custom CSS classes/styles for the hour input of the BitTimePicker. |
| DecreaseHourButton | `string?` | null | Custom CSS classes/styles for the decrease hour button of the BitTimePicker. |
| DecreaseHourIcon | `string?` | null | Custom CSS classes/styles for the decrease hour icon of the BitTimePicker. |
| HourMinuteSeparator | `string?` | null | Custom CSS classes/styles for the hour minute separator of the BitTimePicker. |
| MinuteInputContainer | `string?` | null | Custom CSS classes/styles for the minute input container of the BitTimePicker. |
| IncreaseMinuteButton | `string?` | null | Custom CSS classes/styles for the increase minute button of the BitTimePicker. |
| IncreaseMinuteIcon | `string?` | null | Custom CSS classes/styles for the increase minute icon of the BitTimePicker. |
| MinuteInput | `string?` | null | Custom CSS classes/styles for the minute input of the BitTimePicker. |
| DecreaseMinuteButton | `string?` | null | Custom CSS classes/styles for the decrease minute button of the BitTimePicker. |
| DecreaseMinuteIcon | `string?` | null | Custom CSS classes/styles for the decrease minute icon of the BitTimePicker. |
| AmPmContainer | `string?` | null | Custom CSS classes/styles for the AM/PM container of the BitTimePicker. |
| AmButton | `string?` | null | Custom CSS classes/styles for the AM button of the BitTimePicker. |
| PmButton | `string?` | null | Custom CSS classes/styles for the PM button of the BitTimePicker. |
| CloseButton | `string?` | null | Custom CSS classes/styles for the close button of the BitTimePicker. |
| CloseButtonIcon | `string?` | null | Custom CSS classes/styles for the close button icon of the BitTimePicker. |
### BitIconInfo Properties
| Name | Type | Default Value | Description |
| :--- | :--- | :------------ | :---------- |
| Name | `string?` | null | Gets or sets the name of the icon. |
| BaseClass | `string?` | null | Gets or sets the base CSS class for the icon. For built-in Fluent UI icons, this defaults to "bit-icon". For external icon libraries like FontAwesome, you might set this to "fa" or leave empty. |
| Prefix | `string?` | null | Gets or sets the CSS class prefix used before the icon name. For built-in Fluent UI icons, this defaults to "bit-icon--". For external icon libraries, you might set this to "fa-" or leave empty. |
## Examples
\n**Basic**:
```razor
```
\n**Time format**:
```razor
```
\n**Text input**:
```razor
```
\n**Icon**:
```razor
```
\n**Formatting**:
```razor
```
\n**Binding**:
```razor
```
\n**ReadOnly**:
```razor
```
```csharp
private TimeSpan? readOnlyTime = new(2, 50, 0);
```
\n**Validation**:
```razor
Submit
```
```csharp
public class FormValidationTimePickerModel
{
[Required]
public DateTimeOffset? Date { get; set; }
}
private FormValidationCircularTimePickerModel formValidationTimePickerModel = new();
private async Task HandleValidSubmit()
{
await Task.Delay(3000);
formValidationTimePickerModel = new();
StateHasChanged();
}
```
\n**Responsive**:
```razor
```
\n**Templates**:
```razor
Custom label
```
```csharp
private BitTimePicker timePicker;
private async Task OpenCallout()
{
await timePicker.OpenCallout();
}
```
\n**Hour/minute step**:
```razor
```
\n**External Icons**:
```razor
```
\n**Style & Class**:
```razor
```
```csharp
private TimeSpan? classesValue;
```
\n**RTL**:
```razor
```
Selected time: @selectedTime.ToString()
```
```csharp
private TimeSpan? selectedTime = new(5, 12, 15);
```
\n**Standalone**:
```razor