Skip to content
Protocore Design Systemv1.6.9

/// Charts

PeriodSelector

A 1D/1W/1M/1Y time-range toggle for chart headers, built on SegmentedControl with radiogroup semantics.

import { PeriodSelector } from "@protocore/pds";
View as Markdown

Import path

Unlike the recharts wrappers, PeriodSelector ships from the main `@protocore/pds` entry — it carries no recharts dependency, it is a thin SegmentedControl for chart headers.

import { PeriodSelector, ChartContainer } from "@protocore/pds";

Basics

Rendered on its own it shows the house 1D / 1W / 1M / 1Y ranges with the first selected. It is a single-select toggle: exactly one range stays active, and onValueChange fires with the chosen value.

In a chart header

Drop it into a ChartContainer actions slot to switch the range a chart plots. Pass a custom periods list when your ranges differ from the defaults.

Requests

When to use it

Use PeriodSelector for the *time-range switch* that sits in a chart or dashboard header. It is a preset over SegmentedControl — for any other small single-select toggle (a view mode, a unit) reach for SegmentedControl directly.

Usage

Do

  • Place it in a ChartContainer `actions` slot beside the chart it controls.
  • Keep range labels terse (`1D`, `1W`) — it is a toggle, not a menu.
  • Wire `onValueChange` to refetch or reslice the plotted data.
  • Override `periods` when your ranges differ from 1D/1W/1M/1Y.

Don't

  • Don't use it for multi-select — exactly one range stays active.
  • Don't pack in many long labels; use a Select for a large range list.
  • Don't forget an `aria-label` if the context isn't obvious.
  • Don't reach for it for non-range toggles — use SegmentedControl.

Accessibility

KeysAction
Arrow keysMove between ranges (Radix ToggleGroup roving focus).
TabMove focus into and out of the range group.
Enter / SpaceSelect the focused range.
  • Built on Radix ToggleGroup with radiogroup semantics; exposes `role=radiogroup` with `role=radio` segments.
  • Always keeps exactly one range selected — deselection is not possible.
  • Give an `aria-label` (defaults to `Time range`) so the group is named for assistive tech.

PeriodSelector props

PropTypeDefaultDescription
periodsPeriodOption[]1D / 1W / 1M / 1YThe periods, left to right. `PeriodOption` = `{ value: string; label: ReactNode; disabled?: boolean }`.
valuestringControlled selected value.
defaultValuestringfirst period's valueUncontrolled initial selected value.
onValueChange(value: string) => voidFired with the newly-selected period value.
disabledbooleanfalseDisable the whole control.
aria-labelstring"Time range"Accessible name for the range group.

Related

  • SegmentedControlCompact single-select toggle — a bordered row of mono uppercase segments where the active one inverts to a solid fill.
  • ChartContainerThe bordered, theme-aware frame that hosts a chart and exposes the --pds-chart-1..5 ramp.
  • LineChartA monochrome-plus-signal line chart over the shared --pds-chart-N ramp, recharts-backed.