← Back to Home

AI Date Picker

Intelligent date picker component with natural language processing, modular architecture, and accessibility-first design. Built with performance-optimized CSS modules and comprehensive TypeScript support.

Installation

npm install @thomarket/ai-date-picker

Usage Example

import { useState, useRef } from 'react';
import { DatePickerWithLLM, DatePickerRef } from '@thomarket/ai-date-picker';
import '@thomarket/ai-date-picker/styles.css';

function MyComponent() {
  const [date, setDate] = useState<Date | null>(null);
  const datePickerRef = useRef<DatePickerRef>(null);

  // Basic usage with LLM and enhanced animations
  return (
    <DatePickerWithLLM
      ref={datePickerRef}
      value={date}
      onChange={setDate}
      placeholder="Enter a date (e.g., 'next Friday', 'in 3 days')"
      useLLM={true}
      llmConfig={{
        apiKey: process.env.NEXT_PUBLIC_OPENAI_API_KEY,
        model: 'gpt-3.5-turbo',
        temperature: 0.1,
        maxTokens: 50
      }}
      showCalendar={true}
      showFeedback={true}
      variant="default"
      size="md"
      reduceMotion={false}
      className="w-full max-w-md"
      aria-label="AI-powered date picker"
    />
  );
}

// Advanced usage with ref methods
function AdvancedExample() {
  const datePickerRef = useRef<DatePickerRef>(null);

  const handleFocus = () => datePickerRef.current?.focus();
  const handleClear = () => datePickerRef.current?.clear();
  const handleParse = () => datePickerRef.current?.parseCurrentInput();

  return (
    <div className="space-y-4">
      <DatePickerWithLLM
        ref={datePickerRef}
        variant="outlined"
        size="lg"
        useLLM={false} // Fallback mode without LLM
      />
      
      <div className="flex gap-2">
        <button onClick={handleFocus}>Focus Input</button>
        <button onClick={handleClear}>Clear Value</button>
        <button onClick={handleParse}>Parse Input</button>
      </div>
    </div>
  );
}

// Minimal variant with accessibility focus
function AccessibleExample() {
  return (
    <DatePickerWithLLM
      variant="minimal"
      size="md"
      showCalendar={false}
      showFeedback={true}
      reduceMotion={true} // Accessibility-friendly
      placeholder="Enter date in natural language"
      aria-label="Accessible date picker with natural language input"
    />
  );
}

Live Demo

last Monday of 2025
No date selected
API Configuration:
Enter your OpenAI API key to test AI features. Leave empty to use fallback parsing.
Configuration:
LLM Mode
Calendar
Feedback
Reduce Motion
Variants:
Default
Outlined
Minimal
Sizes:
Small
Medium
Large
Natural Language Examples:
• "tomorrow"
• "next Friday"
• "in 3 days"
• "July 4th"
• "2024-12-31"
• "tomorrow at 4pm"
• "the day after tomorrow"

* Requires OpenAI API key for LLM functionality. All animations respect user motion preferences.