date-range-picker-cn
v0.0.5
Published
Date range picker components for shadcn-based React applications with both Base UI and Radix UI variants.
Maintainers
Readme
date-range-picker-cn
Date range picker components for shadcn-based React applications with both Base UI and Radix UI variants.
Packages
date-range-picker-cnexports the Base UI variant from the root entry pointdate-range-picker-cn/baseexposes Base UI components and types directlydate-range-picker-cn/radixexposes Radix UI components and types directly
Installation
You can install the component via the shadcn CLI or as a standard npm package.
Publishing to npm (OIDC)
npm supports trusted publishing from GitHub Actions using OpenID Connect (OIDC), so you can publish without storing long-lived npm tokens in GitHub secrets.
Prerequisites:
- npm CLI 11.5.1+ in CI (this repo’s workflow installs the latest npm)
- GitHub-hosted runners (OIDC trusted publishing does not work on self-hosted runners)
Setup:
- Publish once from your machine (OTP/token) so the package exists on npm.
- On npmjs.com → your package → Settings → Trusted Publisher, add GitHub Actions publisher:
- Owner:
peppyhop - Repository:
date-range-picker-cn - Workflow filename:
publish.yml
- Owner:
- Push a tag like
v0.0.3to trigger the publish workflow.
Workflow:
Using AI Agents
This library provides skills for AI coding agents via TanStack Intent. If you use an AI agent (like Cursor, Copilot, or Claude), run the following command to install the agent skills:
npx @tanstack/intent@latest installUsing shadcn CLI
# Base UI variant (default)
npx shadcn@latest add https://raw.githubusercontent.com/peppyhop/date-range-picker-cn/main/registry/date-range-picker.json
# Radix UI variant
npx shadcn@latest add https://raw.githubusercontent.com/peppyhop/date-range-picker-cn/main/registry/date-range-picker-radix.jsonUsing npm
react and react-dom are peer dependencies (React 18+).
Base UI variant (default export)
npm install date-range-picker-cn @base-ui/react react-day-pickerRadix UI variant
npm install date-range-picker-cn radix-ui react-day-pickerWeb configuration
Tailwind CSS (required)
This package ships Tailwind class names, so your Tailwind build must scan the package files in node_modules to generate the required styles.
- Tailwind v3: add the package to
contentintailwind.config.{js,ts}
export default {
content: [
"./src/**/*.{js,ts,jsx,tsx,mdx}",
"./node_modules/date-range-picker-cn/dist/**/*.{js,mjs,cjs}",
],
};- Tailwind v4: ensure your CSS entry includes the package as a source (adjust the relative path if needed)
@source "../node_modules/date-range-picker-cn/dist/**/*.{js,mjs,cjs}";shadcn/ui theme tokens
The components use shadcn/ui color tokens (for example bg-background, text-foreground, border-border). Make sure your app defines the corresponding CSS variables (as in shadcn/ui).
Next.js App Router
Use the picker from a Client Component (a file that starts with use client).
Usage
import { DateRangePicker } from "date-range-picker-cn";
export function Example() {
return <DateRangePicker initialDateFrom={new Date()} placeholder="Select date range..." />;
}import { DateRangePicker } from "date-range-picker-cn/radix";
export function Example() {
return <DateRangePicker align="end" showCompare={false} />;
}Icons
Both variants render built-in SVG icons by default. If you want to use your own icon set, pass the icons prop (for example, from lucide-react).
API Docs
- Generated API docs live in
docs/api npm run docs:apirefreshes the generated markdown locally- Pushes to
mainautomatically regenerate and commit API docs when the public API changes
Conventional Commits
This repository validates commit messages against the Conventional Commits specification.
Examples:
feat: add preset rangesfix: correct compare range calculationdocs: refresh usage exampleschore: update typedoc config
Development
npm install
npm run devUseful scripts:
npm run buildnpm run lintnpm run format:checknpm run docs:api
