NextUI Provider


Here's the API reference for the NextUIProvider.

Props

navigate provides a client side router to all nested components such as Link, Menu, Tabs, Table, etc.

type: ((path: string) => void) | undefined

locale

The locale to apply to the children.

type: string | undefined

Here's the supported locales. By default, It is en-US.

const localeValues = [
'fr-FR', 'fr-CA', 'de-DE', 'en-US', 'en-GB', 'ja-JP',
'da-DK', 'nl-NL', 'fi-FI', 'it-IT', 'nb-NO', 'es-ES',
'sv-SE', 'pt-BR', 'zh-CN', 'zh-TW', 'ko-KR', 'bg-BG',
'hr-HR', 'cs-CZ', 'et-EE', 'hu-HU', 'lv-LV', 'lt-LT',
'pl-PL', 'ro-RO', 'ru-RU', 'sr-SP', 'sk-SK', 'sl-SI',
'tr-TR', 'uk-UA', 'ar-AE', 'ar-DZ', 'AR-EG', 'ar-SA',
'el-GR', 'he-IL', 'fa-AF', 'am-ET', 'hi-IN', 'th-TH'
];

Here's an example to set a Spanish locale.

"use client";
import {type ReactNode} from "react";
import {NextUIProvider} from "@nextui-org/react";
export function AppProvider(props: AppProviderProps) {
const {children, className} = props;
return (
<NextUIProvider locale="es-ES" className={className}>
{children}
</NextUIProvider>
);
}
interface AppProviderProps {
children: ReactNode;
className?: string;
}

defaultDates

The default dates range that can be selected in the calendar.

type: { minDate?: CalendarDate | undefined; maxDate?: CalendarDate | undefined; }

  • minDate

    The minimum date that can be selected in the calendar.

    type: CalendarDate | undefined

    default: new CalendarDate(1900, 1, 1)

  • maxDate

    The maximum date that can be selected in the calendar.

    type: CalendarDate | undefined

    default: new CalendarDate(2099, 12, 31)

createCalendar

This function helps to reduce the bundle size by providing a custom calendar system.

By default, this includes all calendar systems supported by @internationalized/date. However, if your application supports a more limited set of regions, or you know you will only be picking dates in a certain calendar system, you can reduce your bundle size by providing your own implementation of createCalendar that includes a subset of these Calendar implementations.

For example, if your application only supports Gregorian dates, you could implement a createCalendar function like this:

import {GregorianCalendar} from '@internationalized/date';
function createCalendar(identifier) {
switch (identifier) {
case 'gregory':
return new GregorianCalendar();
default:
throw new Error(`Unsupported calendar ${identifier}`);
}
}

This way, only GregorianCalendar is imported, and the other calendar implementations can be tree-shaken.

type: ((calendar: SupportedCalendars) => Calendar | null) | undefined

Types

CalendarDate

A CalendarDate represents a date without any time components in a specific calendar system from @internationalized/date.

SupportedCalendars

Supported react-aria i18n calendars.

type SupportedCalendars =
| "buddhist"
| "ethiopic"
| "ethioaa"
| "coptic"
| "hebrew"
| "indian"
| "islamic-civil"
| "islamic-tbla"
| "islamic-umalqura"
| "japanese"
| "persian"
| "roc"
| "gregory";