> ## Documentation Index
> Fetch the complete documentation index at: https://www.propeldata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Time Range Picker

> Select date ranges for analysis.

<div />

Wrap with the [Filter Provider](/docs/embeddable-ui/components/filter-provider) to apply the selected time range to child components.

<Tabs>
  <Tab title="Preview">
    <iframe
      width="100%"
      height="615"
      src="https://ui-kit-docs-examples.vercel.app/time-range-picker"
      allow="accelerometer; clipboard-write; gyroscope;"
      style={{
    overflow: 'hidden',
    border: '1px solid #ECECED',
  }}
      scrolling="no"
      marginWidth="0"
      marginHeight="0"
    />
  </Tab>

  <Tab title="Code">
    ```jsx /time-range-picker/page.tsx theme={"system"}
    import {
      TimeRangePicker,
      Flex,
      FilterProvider
    } from "@propeldata/ui-kit";

    export default async function TimeRangePickerExample() {
      return (
        <Flex p="7" justify="center" width="100%">
          <FilterProvider>
            <TimeRangePicker
              defaultValue={{ value: "last-30-days" }}
              defaultOpen
            />
          </FilterProvider>
        </Flex>
      );
    }
    ```
  </Tab>
</Tabs>

<div className="flex justify-center gap-8 mt-2">
  <a href="https://github.com/propeldata/ui-kit/blob/main/packages/ui-kit/src/components/TimeRangePicker/TimeRangePicker.tsx" target="_blank" className="flex items-center gap-2 text-xs">
    <Icon icon="github" size={18} />

    GitHub

    <Icon icon="arrow-up-right-from-square" size={12} />
  </a>

  <a href="https://ui-kit-git-sasha-060-storybook-updates-propeldata.vercel.app/?path=/docs/components-timerangepicker--overview" target="_blank" className="flex items-center gap-2 text-xs">
    <Icon icon="book" size={18} />

    Storybook

    <Icon icon="arrow-up-right-from-square" size={12} />
  </a>

  <a href="https://github.com/propeldata/ui-kit-docs-examples/blob/main/src/app/time-range-picker/page.tsx" target="_blank" className="flex items-center gap-2 text-xs">
    <Icon icon="github" size={18} />

    Example

    <Icon icon="arrow-up-right-from-square" size={12} />
  </a>
</div>

## Props API

<ParamField path="disableDateUntilNow" type={`boolean`}>
  If set to true, disables the option within the picker that allows users to select a range extending to the current date.
</ParamField>

<ParamField path="disableCustomRange" type={`boolean`}>
  If set to true, disables the option for users to select a custom date range.
</ParamField>

<ParamField path="disableCustomRelative" type={`boolean`}>
  If set to true, disables the option for selecting relative date ranges, such as "last n days."
</ParamField>

<ParamField path="disableOptions" type={`boolean`}>
  If set to true, disables all selectable options in the component, effectively making it read-only.
</ParamField>

<ParamField path="disabled" type={`boolean`}>
  If true, the entire component is disabled, and users cannot interact with it.
</ParamField>

<ParamField path="defaultValue" type={`DateRangeOptionsProps`}>
  Sets an initial default value for the picker using a structured object that defines a range of options.

  <Expandable title="DateRangeOptionsProps">
    <ParamField path="value" type={`string`}>
      A unique identifier for the date range option, used to distinguish between different options.
    </ParamField>

    <ParamField path="label" type={`string`}>
      A human-readable label that describes the date range option.
    </ParamField>

    <ParamField path="params" type={`TimeRangeInput`}>
      The value of the date range option, which can be either a specific date range or a relative time range.

      <Expandable title="TimeRangeInput">
        The fields required to specify the time range for a time series, counter, or leaderboard Metric query.

        If no relative or absolute time ranges are provided, Propel defaults to an absolute time range beginning with the earliest record in the Metric's Data Pool and ending with the latest record.

        If both relative and absolute time ranges are provided, the relative time range will take precedence.

        If a `LAST_N` relative time period is selected, an `n` ≥ 1 must be provided. If no `n` is provided or `n` \< 1, a `BAD_REQUEST` error will be returned.

        <ParamField path="timestamp" type="String">
          The timestamp field to use when querying. Defaults to the timestamp configured on the Data Pool or Metric, if any.
          Set this to filter on an alternative timestamp field.
        </ParamField>

        <ParamField path="relative" type="RelativeTimeRange">
          The relative time period.

          <Expandable title="RelativeTimeRange">
            The Relative time ranges are based on the current date and time.

            `THIS` - The current unit of time. For example, if today is June 8, 2022, and
            `THIS_MONTH` is selected, then data for June 2022 would be returned.

            `PREVIOUS` - The previous unit of time. For example, if today is June 8, 2022, and
            `PREVIOUS_MONTH` is selected, then data for May 2022 would be returned. It excludes
            the current unit of time.

            `NEXT` - The next unit of time. For example, if today is June 8, 2022, and
            `NEXT_MONTH` is selected, then data for July 2022 would be returned. It excludes
            the current unit of time.

            `LAST_N` - The last `n` units of time, including the current one. For example, if today
            is June 8, 2022 and `LAST_N_YEARS` with `n` = 3 is selected, then data for 2020, 2021, and
            2022 will be returned. It will include the current time period.

            <ParamField path=" ">
              * `THIS_HOUR`: Starts at the zeroth minute of the current hour and continues for 60 minutes.
              * `TODAY`: Starts at 12:00:00 AM of the current day and continues for 24 hours.
              * `THIS_WEEK`: Starts on Monday, 12:00:00 AM of the current week and continues for seven days.
              * `THIS_MONTH`: Starts at 12:00:00 AM on the first day of the current month and continues for the duration of the month.
              * `THIS_QUARTER`: Starts at 12:00:00 AM on the first day of the current calendar quarter and continues for the duration of the quarter.
              * `THIS_YEAR`: Starts on January 1st, 12:00:00 AM of the current year and continues for the duration of the year.
              * `PREVIOUS_HOUR`: Starts at the zeroth minute of the previous hour and continues for 60 minutes.
              * `YESTERDAY`: Starts at 12:00:00 AM on the day before the today and continues for 24 hours.
              * `PREVIOUS_WEEK`: Starts on Monday, 12:00:00 AM, a week before the current week, and continues for seven days.
              * `PREVIOUS_MONTH`: Starts at 12:00:00 AM on the first day of the month before the current month and continues for the duration of the month.
              * `PREVIOUS_QUARTER`: Starts at 12:00:00 AM on the first day of the calendar quarter before the current quarter and continues for the duration of the quarter.
              * `PREVIOUS_YEAR`: Starts on January 1st, 12:00:00 AM, the year before the current year, and continues for the duration of the year.
              * `NEXT_HOUR`:  Starts at the zeroth minute of the next hour and continues for 60 minutes.
              * `TOMORROW`: " Starts at 12:00:00 AM, the day after the current day, and continues for 24 hours.
              * `NEXT_WEEK`: Starts on Monday, 12:00:00 AM, the week after the current week, and continues for the duration of the week.
              * `NEXT_MONTH`: Starts at 12:00:00 AM on the first day of the next month and continues for the duration of the month.
              * `NEXT_QUARTER`: Starts at 12:00:00 AM on the first day of the next calendar quarter and continues for the duration of the quarter.
              * `NEXT_YEAR`: Starts on January 1st, 12:00:00 AM of the next year and continues for the duration of the year.
              * `LAST_N_MINUTES`: Starts at the zeroth second `n` - 1 minute(s) before the current minute and continues through the current minute. It includes this minute.
              * `LAST_N_HOURS`: Starts at the zeroth minute of the `n` - 1 hour(s) before the current hour, and continues through the current hour. It includes this hour.
              * `LAST_N_DAYS`: Starts at 12:00:00 AM, `n` - 1 day(s) before the current day, and continues through the current day. It includes today.
              * `LAST_N_WEEKS`: Starts on Monday, 12:00:00 AM, `n` - 1 week(s) before the current week, and continues through the current week. It includes this week.
              * `LAST_N_MONTHS`: Starts at 12:00:00 AM on the first day of the month, `n` - 1 month(s) before the current month, and continues through the current month. It includes this month.
              * `LAST_N_QUARTERS`: Starts at 12:00:00 AM on the first day of the calendar quarter `n` - 1 quarter(s) before the current quarter and continues through the current quarter. It includes this quarter.
              * `LAST_N_YEARS`: Starts on January 1st, 12:00:00 AM of the year `n` - 1 year(s) before the current year and continues through the current year. It includes this year.
              * `LAST_15_MINUTES`
              * `LAST_30_MINUTES`
              * `LAST_HOUR`
              * `LAST_4_HOURS`
              * `LAST_12_HOURS`
              * `LAST_24_HOURS`
              * `LAST_7_DAYS`
              * `LAST_30_DAYS`
              * `LAST_90_DAYS`
              * `LAST_3_MONTHS`
              * `LAST_6_MONTHS`
              * `LAST_YEAR`
              * `LAST_2_YEARS`
              * `LAST_5_YEARS`
            </ParamField>
          </Expandable>
        </ParamField>

        <ParamField path="n" type="Int">
          The number of time units for the `LAST_N` relative periods.
        </ParamField>

        <ParamField path="start" type="DateTime">
          The optional start timestamp (inclusive). Defaults to the timestamp of the earliest record in the Data Pool.
        </ParamField>

        <ParamField path="stop" type="DateTime">
          The optional end timestamp (exclusive). Defaults to the timestamp of the latest record in the Data Pool.
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

<ParamField path="value" type={`DateRangeOptionsProps`}>
  Controls the current value of the picker through a structured object, enabling controlled component behavior.

  <Expandable title="DateRangeOptionsProps">
    <ParamField path="value" type={`string`}>
      A unique identifier for the date range option, used to distinguish between different options.
    </ParamField>

    <ParamField path="label" type={`string`}>
      A human-readable label that describes the date range option.
    </ParamField>

    <ParamField path="params" type={`TimeRangeInput`}>
      The value of the date range option, which can be either a specific date range or a relative time range.

      <Expandable title="TimeRangeInput">
        The fields required to specify the time range for a time series, counter, or leaderboard Metric query.

        If no relative or absolute time ranges are provided, Propel defaults to an absolute time range beginning with the earliest record in the Metric's Data Pool and ending with the latest record.

        If both relative and absolute time ranges are provided, the relative time range will take precedence.

        If a `LAST_N` relative time period is selected, an `n` ≥ 1 must be provided. If no `n` is provided or `n` \< 1, a `BAD_REQUEST` error will be returned.

        <ParamField path="timestamp" type="String">
          The timestamp field to use when querying. Defaults to the timestamp configured on the Data Pool or Metric, if any.
          Set this to filter on an alternative timestamp field.
        </ParamField>

        <ParamField path="relative" type="RelativeTimeRange">
          The relative time period.

          <Expandable title="RelativeTimeRange">
            The Relative time ranges are based on the current date and time.

            `THIS` - The current unit of time. For example, if today is June 8, 2022, and
            `THIS_MONTH` is selected, then data for June 2022 would be returned.

            `PREVIOUS` - The previous unit of time. For example, if today is June 8, 2022, and
            `PREVIOUS_MONTH` is selected, then data for May 2022 would be returned. It excludes
            the current unit of time.

            `NEXT` - The next unit of time. For example, if today is June 8, 2022, and
            `NEXT_MONTH` is selected, then data for July 2022 would be returned. It excludes
            the current unit of time.

            `LAST_N` - The last `n` units of time, including the current one. For example, if today
            is June 8, 2022 and `LAST_N_YEARS` with `n` = 3 is selected, then data for 2020, 2021, and
            2022 will be returned. It will include the current time period.

            <ParamField path=" ">
              * `THIS_HOUR`: Starts at the zeroth minute of the current hour and continues for 60 minutes.
              * `TODAY`: Starts at 12:00:00 AM of the current day and continues for 24 hours.
              * `THIS_WEEK`: Starts on Monday, 12:00:00 AM of the current week and continues for seven days.
              * `THIS_MONTH`: Starts at 12:00:00 AM on the first day of the current month and continues for the duration of the month.
              * `THIS_QUARTER`: Starts at 12:00:00 AM on the first day of the current calendar quarter and continues for the duration of the quarter.
              * `THIS_YEAR`: Starts on January 1st, 12:00:00 AM of the current year and continues for the duration of the year.
              * `PREVIOUS_HOUR`: Starts at the zeroth minute of the previous hour and continues for 60 minutes.
              * `YESTERDAY`: Starts at 12:00:00 AM on the day before the today and continues for 24 hours.
              * `PREVIOUS_WEEK`: Starts on Monday, 12:00:00 AM, a week before the current week, and continues for seven days.
              * `PREVIOUS_MONTH`: Starts at 12:00:00 AM on the first day of the month before the current month and continues for the duration of the month.
              * `PREVIOUS_QUARTER`: Starts at 12:00:00 AM on the first day of the calendar quarter before the current quarter and continues for the duration of the quarter.
              * `PREVIOUS_YEAR`: Starts on January 1st, 12:00:00 AM, the year before the current year, and continues for the duration of the year.
              * `NEXT_HOUR`:  Starts at the zeroth minute of the next hour and continues for 60 minutes.
              * `TOMORROW`: " Starts at 12:00:00 AM, the day after the current day, and continues for 24 hours.
              * `NEXT_WEEK`: Starts on Monday, 12:00:00 AM, the week after the current week, and continues for the duration of the week.
              * `NEXT_MONTH`: Starts at 12:00:00 AM on the first day of the next month and continues for the duration of the month.
              * `NEXT_QUARTER`: Starts at 12:00:00 AM on the first day of the next calendar quarter and continues for the duration of the quarter.
              * `NEXT_YEAR`: Starts on January 1st, 12:00:00 AM of the next year and continues for the duration of the year.
              * `LAST_N_MINUTES`: Starts at the zeroth second `n` - 1 minute(s) before the current minute and continues through the current minute. It includes this minute.
              * `LAST_N_HOURS`: Starts at the zeroth minute of the `n` - 1 hour(s) before the current hour, and continues through the current hour. It includes this hour.
              * `LAST_N_DAYS`: Starts at 12:00:00 AM, `n` - 1 day(s) before the current day, and continues through the current day. It includes today.
              * `LAST_N_WEEKS`: Starts on Monday, 12:00:00 AM, `n` - 1 week(s) before the current week, and continues through the current week. It includes this week.
              * `LAST_N_MONTHS`: Starts at 12:00:00 AM on the first day of the month, `n` - 1 month(s) before the current month, and continues through the current month. It includes this month.
              * `LAST_N_QUARTERS`: Starts at 12:00:00 AM on the first day of the calendar quarter `n` - 1 quarter(s) before the current quarter and continues through the current quarter. It includes this quarter.
              * `LAST_N_YEARS`: Starts on January 1st, 12:00:00 AM of the year `n` - 1 year(s) before the current year and continues through the current year. It includes this year.
              * `LAST_15_MINUTES`
              * `LAST_30_MINUTES`
              * `LAST_HOUR`
              * `LAST_4_HOURS`
              * `LAST_12_HOURS`
              * `LAST_24_HOURS`
              * `LAST_7_DAYS`
              * `LAST_30_DAYS`
              * `LAST_90_DAYS`
              * `LAST_3_MONTHS`
              * `LAST_6_MONTHS`
              * `LAST_YEAR`
              * `LAST_2_YEARS`
              * `LAST_5_YEARS`
            </ParamField>
          </Expandable>
        </ParamField>

        <ParamField path="n" type="Int">
          The number of time units for the `LAST_N` relative periods.
        </ParamField>

        <ParamField path="start" type="DateTime">
          The optional start timestamp (inclusive). Defaults to the timestamp of the earliest record in the Data Pool.
        </ParamField>

        <ParamField path="stop" type="DateTime">
          The optional end timestamp (exclusive). Defaults to the timestamp of the latest record in the Data Pool.
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

<ParamField path="locale" type={`string`}>
  The locale used to format the date and time values, e.g. "en-US".
</ParamField>

<ParamField path="options" type={`(defaultOptions: DateRangeOptionsProps[]) => DateRangeOptionsProps[] | undefined`}>
  A function that allows for customizing the list of quick selection options based on default options provided.
</ParamField>

<ParamField path="onChange" type={`(option: DateRangeOptionsProps) => void`}>
  A callback function that is fired when the selected value changes, providing the new value as an argument.
</ParamField>

<ParamField path="defaultOpen" type={`boolean`}>
  If true, the select is open by default.
</ParamField>

<Expandable title="Theme Provider Props">
  <ParamField path="appearance" type={`ThemeAppearances`}>
    The initial theme used as a base. It provides a default set of styling
    from which customizations can be applied.

    <Expandable title="ThemeAppearances">
      <ParamField path="ThemeAppearances" type={`"light" | "dark"`} />
    </Expandable>
  </ParamField>

  <ParamField path="accentColor" type={`AccentColors`}>
    The global theme accent color. This color is used to highlight elements

    <Expandable title="AccentColors">
      <ParamField path="AccentColors" type={`"amber" | "blue" | "bronze" | "brown" | "crimson" | "cyan" | "gold" | "grass" | "gray" | "green" | "indigo" | "iris" | "jade" | "lime" | "mint" | "orange" | "pink" | "plum" | "purple" | "red" | "ruby" | "sky" | "teal" | "tomato" | "violet" | "yellow"`} />
    </Expandable>
  </ParamField>

  <ParamField path="grayColor" type={`GrayColors`}>
    The global theme gray color. This color is used for text and background colors

    <Expandable title="GrayColors">
      <ParamField path="GrayColors" type={`"auto" | "gray" | "mauve" | "slate" | "sage" | "olive" | "sand"`} />
    </Expandable>
  </ParamField>

  <ParamField path="radius" type={`Radii`}>
    The global theme radius color. This color is used for border radius

    <Expandable title="Radii">
      <ParamField path="Radii" type={`"none" | "small" | "medium" | "large" | "full"`} />
    </Expandable>
  </ParamField>

  <ParamField path="scaling" type={`Scalings`}>
    The global theme scaling. This value is used to scale components

    <Expandable title="Scalings">
      <ParamField path="Scalings" type={`"90%" | "95%" | "100%" | "105%" | "110%"`} />
    </Expandable>
  </ParamField>

  <ParamField path="panelBackground" type={`PanelBackgrounds`}>
    The global theme panel background. This value is used to set the panel background

    <Expandable title="PanelBackgrounds">
      <ParamField path="PanelBackgrounds" type={`"solid" | "translucent"`} />
    </Expandable>
  </ParamField>
</Expandable>
