-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(docs): docs changes #2868
Merged
Merged
feat(docs): docs changes #2868
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
28b608d
feat(docs): add example how to set locale (#2867)
wingkwong 4034042
docs(guide): add an explanation for the installation guide (#2769)
Nozomi-Hijikata 4baf0a9
fix: change sort priority - cmdk (#2873)
kuri-sun c00da77
docs: remove unsupported props in range calendar and date range picke…
wingkwong 0570a8a
docs: refactor typing in form.ts (#2882)
carnoxen 64ca1b6
chore(docs): supplement errorMessage behaviour in input (#2892)
wingkwong 9ee9f6e
refactor(docs): revise NextUI Provider structure
wingkwong b155c7c
chore(docs): add updated tag
wingkwong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,80 +5,167 @@ description: API References for NextUI Provider | |
|
||
# NextUI Provider | ||
|
||
API reference for the `NextUIProvider`. | ||
|
||
------ | ||
|
||
Here's the API reference for the `NextUIProvider`. | ||
## Import | ||
|
||
<ImportTabs | ||
commands={{ | ||
main: 'import {NextUIProvider} from "@nextui-org/react";', | ||
individual: 'import {NextUIProvider} from "@nextui-org/system";', | ||
}} | ||
/> | ||
|
||
## Usage | ||
|
||
```jsx | ||
import * as React from "react"; | ||
import {NextUIProvider} from "@nextui-org/react"; | ||
|
||
function App() { | ||
return ( | ||
<NextUIProvider> | ||
<YourApplication /> | ||
</NextUIProvider> | ||
); | ||
} | ||
``` | ||
|
||
## Props | ||
|
||
### navigate | ||
<Spacer y={6}/> | ||
|
||
`navigate` provides a client side router to all nested components such as Link, Menu, Tabs, Table, etc. | ||
`navigate` | ||
|
||
**type**: `((path: string) => void) | undefined` | ||
- **Description**: Provides a client side router to all nested components such as Link, Menu, Tabs, Table, etc. | ||
- **Type**: `((path: string) => void) | undefined` | ||
|
||
### locale | ||
<Spacer y={2}/> | ||
|
||
The locale to apply to the children. The [BCP47](https://www.ietf.org/rfc/bcp/bcp47.txt) language code for the locale. By default, It is `en-US`. | ||
`locale` | ||
|
||
**type**: `string | undefined` | ||
- **Description**: The locale to apply to the children. | ||
- **Type**: `string | undefined` | ||
- **Default**: `en-US` | ||
|
||
### defaultDates | ||
|
||
The default dates range that can be selected in the calendar. | ||
Here's the supported locales. By default, It is `en-US`. | ||
|
||
**type**: `{ minDate?: CalendarDate | undefined; maxDate?: CalendarDate | undefined; }` | ||
```tsx | ||
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' | ||
]; | ||
``` | ||
|
||
- minDate | ||
Here's an example to set a Spanish locale. | ||
|
||
The minimum date that can be selected in the calendar. | ||
```tsx | ||
"use client"; | ||
|
||
**type**: `CalendarDate | undefined` | ||
import {type ReactNode} from "react"; | ||
import {NextUIProvider} from "@nextui-org/react"; | ||
|
||
**default**: `new CalendarDate(1900, 1, 1)` | ||
export function AppProvider(props: AppProviderProps) { | ||
const {children, className} = props; | ||
|
||
- maxDate | ||
return ( | ||
<NextUIProvider locale="es-ES" className={className}> | ||
{children} | ||
</NextUIProvider> | ||
); | ||
} | ||
|
||
The maximum date that can be selected in the calendar. | ||
interface AppProviderProps { | ||
children: ReactNode; | ||
className?: string; | ||
} | ||
``` | ||
|
||
**type**: `CalendarDate | undefined` | ||
<Spacer y={2}/> | ||
|
||
**default**: `new CalendarDate(2099, 12, 31)` | ||
`defaultDates` | ||
|
||
### createCalendar | ||
- **Description**: The default dates range that can be selected in the calendar. | ||
- **Type**: `{ minDate?: CalendarDate | undefined; maxDate?: CalendarDate | undefined; }` | ||
- **Default**: `{ minDate: new CalendarDate(1900, 1, 1), maxDate: new CalendarDate(2099, 12, 31) }` | ||
|
||
This function helps to reduce the bundle size by providing a custom calendar system. | ||
<Spacer y={2}/> | ||
|
||
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. | ||
`createCalendar` | ||
|
||
For example, if your application only supports Gregorian dates, you could implement a `createCalendar` | ||
function like this: | ||
- **Description**: | ||
This function helps to reduce the bundle size by providing a custom calendar system. | ||
|
||
```tsx | ||
import {GregorianCalendar} from '@internationalized/date'; | ||
|
||
function createCalendar(identifier) { | ||
switch (identifier) { | ||
case 'gregory': | ||
return new GregorianCalendar(); | ||
default: | ||
throw new Error(`Unsupported calendar ${identifier}`); | ||
} | ||
} | ||
``` | ||
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: | ||
|
||
```tsx | ||
import {GregorianCalendar} from '@internationalized/date'; | ||
|
||
function createCalendar(identifier) { | ||
switch (identifier) { | ||
case 'gregory': | ||
return new GregorianCalendar(); | ||
default: | ||
throw new Error(`Unsupported calendar ${identifier}`); | ||
} | ||
} | ||
Comment on lines
+112
to
+125
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure the The |
||
``` | ||
|
||
This way, only GregorianCalendar is imported, and the other calendar implementations can be tree-shaken. | ||
|
||
- **Type**: `((calendar: SupportedCalendars) => Calendar | null) | undefined` | ||
|
||
<Spacer y={2}/> | ||
|
||
`disableAnimation` | ||
|
||
This way, only GregorianCalendar is imported, and the other calendar implementations can be tree-shaken. | ||
- **Description**: Disables animations globally. This will also avoid `framer-motion` features to be loaded in the bundle which can potentially reduce the bundle size. | ||
- **Type**: `boolean` | ||
- **Default**: `false` | ||
|
||
**type**: `((calendar: SupportedCalendars) => Calendar | null) | undefined` | ||
<Spacer y={2}/> | ||
|
||
`disableRipple` | ||
|
||
- **Description**: Disables ripple effect globally. | ||
- **Type**: `boolean` | ||
- **Default**: `false` | ||
|
||
<Spacer y={2}/> | ||
|
||
`skipFramerMotionAnimations` | ||
|
||
- **Description**: | ||
Controls whether `framer-motion` animations are skipped within the application. | ||
This property is automatically enabled (`true`) when the `disableAnimation` prop is set to `true`, | ||
effectively skipping all `framer-motion` animations. To retain `framer-motion` animations while | ||
using the `disableAnimation` prop for other purposes, set this to `false`. However, note that | ||
animations in NextUI Components are still omitted if the `disableAnimation` prop is `true`. | ||
- **Type**: `boolean` | ||
- **Default**: Same as `disableAnimation` | ||
|
||
--- | ||
|
||
## Types | ||
|
||
### CalendarDate | ||
`CalendarDate` | ||
|
||
A [CalendarDate](https://react-spectrum.adobe.com/internationalized/date/CalendarDate.html) represents a date without any time components in a specific calendar system from `@internationalized/date`. | ||
- **Description**: A [CalendarDate](https://react-spectrum.adobe.com/internationalized/date/CalendarDate.html) represents a date without any time components in a specific calendar system from `@internationalized/date`. | ||
- **Type**: `import {CalendarDate} from '@internationalized/date';` | ||
|
||
### SupportedCalendars | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure consistency in the description of the
NextUIProvider
.The description "API reference for the
NextUIProvider
." could be expanded to provide more context about whatNextUIProvider
does, rather than just stating that this is an API reference.