Datepicker

Calendar-based input for selecting a single date or date range.

Overview

The Datepicker component is a core building block of the Byteion design system, providing a robust, accessibility-compliant interface for its specific UI capabilities.

Why this exists

Date selection is error-prone with free-text inputs. A datepicker enforces format, provides visual calendar context, and prevents invalid dates.

Mental model

A datepicker combines a text input with a calendar popup. Users can type or click a date. The input validates format and range.

When to use

• Booking and reservation dates • Date range filters • Date of birth or start-date fields • Any form requiring a valid date

When not to use

• Do not use for time-only selection • Avoid for month/year only — use separate selects • Do not use for date ranges without a dedicated range mode

Basic example

The following example demonstrates standard usage, fully compliant with Byteion's token-first approach.

Variants

Each variant communicates a different meaning. Choose based on priority, not aesthetics.

Single default variant.

Sizes

Size should match the importance and context of the component.

  • md — md size.

States

This component reacts seamlessly to the following interaction and data states:

  • default — Resting appearance before interaction.
  • hover — Pointer is over the element — visual feedback via color or shadow.
  • focus — Keyboard or tab focus — shows ring indicator for accessibility.
  • active — Currently selected or in use.
  • disabled — Non-interactive — grayed out, cursor not-allowed.
  • loading — Action in progress — spinner replaces icon, button is disabled.
  • open — Component is expanded or visible.
  • closed — Component is collapsed or hidden.

Anatomy

• Input — text field with date format • Calendar icon — triggers popup • Calendar panel — month grid • Navigation — prev/next month • Selected date indicator

Usage guidelines

  • Show format hint (MM/DD/YYYY).
  • Highlight today and selected date.
  • Disable dates outside the valid range.

Do and Don't

Do

  • Show the date format.
  • Disable out-of-range dates.
  • Highlight today.

Don't

  • Do not allow invalid dates.
  • Do not use free-text without validation.
  • Do not open calendar on input focus — use icon click.

Accessibility

Calendar grid uses arrow keys for navigation. Selected date has aria-selected.

Role:dialog

ARIA Attributes

  • aria-label
  • aria-haspopup
  • aria-expanded
  • aria-controls
  • aria-pressed

Keyboard Navigation

  • ArrowKeys: Navigates between items sequentially
  • Enter: Activates or submits the element

Customization

Selected date color follows --primary.

Compose with React cva()

Use the exportedcva() +cn() utilities to compose your own variant on top of the Byteion tokens.

import { cva, cn, type VariantProps } from '@byteion/react';

const myDatepicker = cva('base classes…', {
 variants: {
  accent: { soft:'border-primary-200', loud:'border-primary-500' },
 },
 defaultVariants: { accent:'soft' },
});

type Props = React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof myDatepicker>;

Compose with Vue cva()

Use the exportedcva() +cn() utilities inside standard Vue setup blocks.

<script setup lang="ts">
import { computed, useAttrs } from 'vue';
import { cva, type VariantProps } from '@byteion/vue';

interface Props { accent?:'soft' |'loud' }
const props = withDefaults(defineProps<Props>(), { accent:'soft' });
const attrs = useAttrs();

const myDatepicker = cva('base classes…', {
  variants: { accent: { soft:'border-primary-200', loud:'border-primary-500' } },
});

const cls = computed(() => myDatepicker({ accent: props.accent, class: attrs.class as string | undefined }));
</script>

Runtime events

Byteion keeps framework APIs idiomatic: HTML uses DOM custom events, React uses callback props, and Vue uses emitted events / v-model updates.

HTML / JS events

  • bi:datepicker:close
  • bi:datepicker:open
  • bi:datepicker:select

React callbacks

  • onValueChange(value: string | null) => void

Vue emits

  • update:modelValue[v: string]

Remote / AJAX

This component does not implement Byteion JS remote loading. Use normal HTML form submission, framework state, or your application data layer around it.

API Reference

Uses data attributes for toggle and date selection.

HTML Data Attributes

No custom data attributes required.

React Props · DatepickerProps

Extracted directly fromreact/src/components/Datepicker.tsx.

export interface DatepickerProps {
  /** Controlled date (YYYY-MM-DD). */
  value?: string | null;
  defaultValue?: string | null;
  onValueChange?: (value: string | null) => void;
  label?: ReactNode;
  helperText?: ReactNode;
  error?: ReactNode;
  placeholder?: string;
  disabled?: boolean;
  /** Format the date in the input. Default is the raw ISO string. */
  format?: (value: string) => string;
  /** Initial month when opening with no value. */
  initialMonth?: number;
  initialYear?: number;
  /** Render the calendar popup open initially. Useful for documentation showcases. */
  defaultOpen?: boolean;
  /** Limit the popup preview to N weeks. Primarily for docs parity. */
  compactWeeks?: number;
  /** Skip leading day cells in a curated compact preview. */
  compactStartOffset?: number;
  id?: string;
  className?: string;
  /** Minimum selectable date (ISO YYYY-MM-DD). */
  min?: string;
  /** Maximum selectable date (ISO YYYY-MM-DD). */
  max?: string;
  name?: string;
  'data-bi-date-range-start'?: boolean;
  'data-bi-date-range-end'?: boolean;
}

Vue Props · DatepickerProps

Extracted directly fromvue/src/components/Datepicker.vue.

export interface DatepickerProps {
  modelValue?: string;
  placeholder?: string;
  label?: string;
  helperText?: string;
  error?: string;
  disabled?: boolean;
  id?: string;
  min?: string;
  max?: string;
}

Developer tips

• Common mistake: allowing free-text date entry without format validation. • Edge case: handle timezone — store dates in UTC.

Common mistakes

Avoid hardcoded neutral colors, placeholder-only labels, duplicated primary actions, and missing keyboard states. Keep this component on Byteion tokens so dashboard, admin, POS, ERP, ecommerce back-office, Laravel, React, and Vue starter-kit screens can be rebranded without rewriting markup.

Production usage tips

Use the canonical HTML as the source of truth, keep React and Vue wrappers aligned with the documented variants, test dark mode and branded themes before release, and wire interactive behavior through data-bi-* attributes instead of styling hooks.

Premium examples

Advanced patterns available in Byteion Pro:

• Date range picker with visual range highlight • Quick-select presets (Last 7 days, This month)

Unlock Premium Patterns

Get access to copy-paste ready Pro blocks, SaaS templates, and advanced data-tables built with this component.

Explore Pro Components