# Naive UI
Naive UI is a Vue 3 component library.
To know how to install it, see [Installation](https://www.naiveui.com/en-US/docs/installation.md).
It is fairly complete, themeable, written in typescript, not too slow.
## Fairly Complete
There are more than 90 components. Hope they can help you write less code.
What's more, they are all treeshakable.
## Theme Customizable
We provide an advanced type safe theme system that is built with typescript. All you need is to provide a theme overrides object in JS. Then all the stuffs will be done by us.
What's more, no less/sass/css variables, no webpack loaders are required. And you can try the theme editor on the bottom right of the page.
## Uses TypeScript
All the stuff in Naive UI is written in TypeScript. It can work with your typescript project seamlessly.
What's more, you don't need to import any CSS to use the components.
## Fast
I try to make it not rather slow. At least select, tree, transfer, table and cascader work with virtual list.
What's more, ..., no more. Just enjoy it.
## Community
- [Discord](https://discord.gg/Pqv7Mev5Dd)
- 钉钉一群 33482509 (已满)
- 钉钉二群 35886835 (已满)
- 钉钉三群 32377370 (已满)
- 钉钉四群 8165002788 (已满)
- 钉钉五群 31205022250 (已满)
- 钉钉六群 62720001971 (已满)
- 钉钉七群 172000005810
## Contributing
Please see [CONTRIBUTING.md](https://github.com/tusen-ai/naive-ui/blob/main/CONTRIBUTING.md).
## License
Naive UI is licensed under the [MIT license](https://opensource.org/licenses/MIT).
---
# Installation
> Please note that naive-ui only supports Vue3. If you are using Vue2, you may look at other libraries.
## npm
Use npm to install.
```bash
npm i naive-ui
```
## UMD
Please refer to [Using UMD](https://www.naiveui.com/en-US/docs/umd.md).
## Fonts
```bash
npm i vfonts
```
## Icons
naive-ui recommends using [xicons](https://www.xicons.org) as icon library.
## Design Resources

[Naive UI (Sketch)](https://naive-ui.oss-accelerate.aliyuncs.com/NaiveUI-Design-Library-en-US.sketch)
---
# Usage in SFC
If you want to use the Single File Component(SFC) style, you can directly import components from Naive UI or install it globally to a Vue app.
## Import Directly (Recommended)
You can import a component directly and use it. In this form, only components imported will be bundled.
If you want to know how to import themes and locales, please see [Import on Demand](https://www.naiveui.com/en-US/docs/import-on-demand.md).
```html
naive-ui
```
If you can use vue setup script, you can use it like this.
```html
naive-ui
```
## Install Globally (Not Recommended)
### Install All Components
No tree-shaking. Bundle will have redundant codes.
If you want to install globally but don't want all components, please see [Import on Demand](https://www.naiveui.com/en-US/docs/import-on-demand.md).
```js
import naive from 'naive-ui'
import { createApp } from 'vue'
const app = createApp(App)
app.use(naive)
```
After the installation, you can use all the components in your SFC like this.
```html
naive-ui
```
### Volar support (2.24.2)
If you are using Volar, you can specify global component types by configuring `compilerOptions.types` in `tsconfig.json`.
```json
// tsconfig.json
{
"compilerOptions": {
// ...
"types": ["naive-ui/volar"]
}
}
```
---
# Using UMD
> **Warning**
>
> There is a self-closing bug in UMD version of naive. Please close tags explicitly like ``.
After version `2.30.3`, you can use UMD version of naive.
If you want to use a minified version of naive, use `https://unpkg.com/naive-ui@version/dist/index.prod.js` as `src`. `version` is the version of naive-ui you want to use. If you don't specify a version, latest version would be used.
It's preferable to link to a specific version of the package, as always relying on the latest version may lead to breaking changes.
Here's a basic [demo](https://jsbin.com/saxubitaki/1/edit?html,output):
```html
{{ message }}
```
---
# Configuring Fonts
Naive UI works with [vfonts](https://github.com/07akioni/vfonts). You can use fonts from `vfonts` easily which includes general fonts and monospace fonts.
Just import fonts from in your app's entry file. Then it will work.
```js
// entry js file of your app
// ...
// General Font
import 'vfonts/Lato.css'
// Monospace Font
import 'vfonts/FiraCode.css'
// then it works
// ...
```
Note: Different fonts from vfonts have different font weights. If you want to use `Lato` or `OpenSans` you need to configure the global font weight of naive-ui.
```html
```
## Change Global Fonts by Customizing Theme
If you don't use `vfont` and want change global fonts by customzing theme, you need to use `n-global-style` to achieve that. Components' font won't be responsive to `theme-overrides` without `n-global-style`.
Note: Make `vfont` work without `n-global-style` is a compromised design (I think this is a correct behavior). In the next major version, global reset style won't contain font related style. They'll be all put inside `n-global-style` component.
---
# Import on Demand (Tree Shaking)
Naive UI supports tree shaking for components, locales and themes.
By default the component theme is light, locale is enUS, and no extra imports are needed.
For more info about theming, see [Customizing Theme](https://www.naiveui.com/en-US/docs/customize-theme.md).
## Import Directly
```html
```
## Auto Import
You can use the `unplugin-auto-import` plugin to automatically import APIs.
If you develop using SFC, you can use the `unplugin-vue-components` plugin to automatically import components on demand.The plugin will automatically parse the components used in the template and import the components.
```ts
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
import Components from 'unplugin-vue-components/vite'
// vite.config.ts
import { defineConfig } from 'vite'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
AutoImport({
imports: [
'vue',
{
'naive-ui': [
'useDialog',
'useMessage',
'useNotification',
'useLoadingBar'
]
}
]
}),
Components({
resolvers: [NaiveUiResolver()]
})
]
})
```
## Install on Demand Globally
```js
import {
// create naive ui
create,
// component
NButton
} from 'naive-ui'
import { createApp } from 'vue'
const naive = create({
components: [NButton]
})
const app = createApp()
app.use(naive)
```
After the installation, you can use the components you installed in SFC like this.
```html
naive-ui
```
---
# Supported Platforms
## Browsers
IE is not supported.
Modern browsers such as `Edge`, `Firefox`, `Chrome`, `Safari` are tested on the latest 2 versions.
No strict tests are being implemented on other versions due to the constraint of development resources, but naive-ui is expected to work on those browsers whose version is not too old (eg. in 2 years). If you find any problems please feel free to create an issue.
## Vue
Only Vue 3 (>3.0.5) is supported.
## TypeScript
Requires version > 4.1.
---
# Common Issues
## 1. The difference between @update:xxx and on-update:xxx
### Case 1
If you are not using `v-model:xxx` with `on-update:xxx` on the same component, there is no difference between `@update:xxx` and `on-update:xxx` when used in templates.
In Naive UI, all API documents use the `on-update:xxx` format, because `@` is just a shorthand provided by Vue.
If you prefer camelCase, you can use `onUpdate:xxx`.
If you are using JSX, you can use `onUpdateXxx` (all `onUpdate:xxx` have an equivalent implementation of `onUpdateXxx`).
### Case 2
If you are using `v-model:xxx`, you should use `@update:xxx` on the same component.
✅ example ``.
❌ example ``.
That is because `v-model:value="xxx"` will be transformed to `:onUpdate:value="xxx"`. If you are using `@update:value="yyy"` together, it will be `:onUpdate:value="[xxx, yyy]"`, and then Naive UI would take care of if.
However if you are using `on-update:value="yyy"`, Vue would generate code like `:onUpdate:value="xxx" :on-update-value="yyy"` and the second one would override the first one in Vue runtime. The `v-model:value` would be broken.
If you have any problems, feel free to create a PR or issue on GitHub.
## 2. How to use in Single File Component(SFC)?
please see [Usage in SFC](https://www.naiveui.com/en-US/docs/usage-sfc.md)
---
# Controlled manner & uncontrolled manner
A component's manner can be controlled or uncontrolled. Uncontrolled manner means you only listen to its change but not control its value. Controlled manner means you control the component's value.
## Uncontrolled manner
In this situation, you don't set ``'s `value` but only listen to its change. Component's value will be controlled by itself.
```html
```
## Controlled manner
In the situation, you listen to component's value & change at the same time. If you don't update `value`, component's value won't be changed. Its value is controlled by you.
```html
```
### `v-model`
A component with `v-model` works in controlled manner, since `v-model` is the same as `:model-value` and `@update:model-value`.
## Uncontrolled manner in naive-ui
Different library has different behavior on how to distinguish controlled or uncontrolled manner. In naive-ui, if `value` is `undefined` or not passed, it will be uncontrolled. That is to say, if you set a component's value to `undefined` won't clear it but transform it from controlled manner to uncontrolled manner. If you need to clear it, at most time you can use `null`.
### Not only `value`
Any props pair like `xxx` & `@update:xxx` can work both in controlled manner or uncontrolled manner.
---
# LLMs
The docs are also published as Markdown for LLMs and agents, following [llms.txt](https://llmstxt.org).
## Files
| File | Content |
| --- | --- |
| [llms.txt](https://www.naiveui.com/llms.txt) | An index of every page, grouped as in this site's menu, each with a one-line description |
| [llms-full.txt](https://www.naiveui.com/llms-full.txt) | Every page in one file |
| [zh-CN/llms.txt](https://www.naiveui.com/zh-CN/llms.txt), [zh-CN/llms-full.txt](https://www.naiveui.com/zh-CN/llms-full.txt) | The same in Chinese |
## A page as Markdown
Add `.md` to the address of any docs or component page, for example [/en-US/components/button.md](https://www.naiveui.com/en-US/components/button.md). Component pages include the API and the full source of every demo.
The button next to each page title copies the page as Markdown, copies its Markdown link, or opens it.
## With an agent
Give the agent the address of `llms.txt` (`https://www.naiveui.com/llms.txt`) and let it read the pages it needs. `llms-full.txt` holds the source of every demo, so it is large: use it with tools that index a whole file.
---
# JSX & TSX
## Enable JSX & TSX
For how to enable JSX & TSX, please look at your toolchain's docs.
## Use Component
We recommend importing components directly when using JSX.
```js
import { NButton } from 'naive-ui'
import { defineComponent } from 'vue'
export default defineComponent({
render() {
return {{ default: () => 'Star Kirby' }}
}
})
```
## Props look like @update:\*
In naive-ui, all props look like `on-update:*` has a corresponding `onUpdate*` prop (since in JSX `on-update:*` and `onUpdate:*` are not valid prop names).
If you find it doesn't exist, I must have forgotten to make it. Please create an issue or PR.
For example, `` in template can be written in ``.
---
# Server-Sider Rendering
Since naive-ui is using CSS in JS, in SSR mode it needs some extra configuration.
## Caveat
When using SSR under any framework, it is essential to ensure that the project meets the following conditions:
1. During the build process, any direct or indirect references to the `@css-render/*` and `css-render` packages must have a version of `>=0.15.14`.
2. During the build process, each direct or indirect reference to any `@css-render/*` and `css-render` package should ultimately point to a single target (a package should not have multiple versions or multiple copies of the same version).
You can search for `css-render` in the lock file to check for duplicate packages.
Failure to meet these conditions may result in SSR build failures.
If you encounter issues due to this, you can resolve the problem by directing all related packages to the same version using the `resolution` field in the `package.json` file.
## Nuxt.js
See [Nuxt.js](https://www.naiveui.com/en-US/docs/nuxtjs.md).
## Vitepress
See [Vitepress](https://www.naiveui.com/en-US/docs/vitepress.md).
## Vite SSG/SSE
See [Vite SSG/SSE](https://www.naiveui.com/en-US/docs/vite-ssge.md).
## Vite Example
If you are using Vite, please see [example](https://github.com/07akioni/naive-ui-vite-ssr).
## Webpack Example
If you are using Webpack, please see [example](https://github.com/tusen-ai/naive-ui/tree/main/playground/ssr).
## Inline Style Optimization
By default, naive-ui bind inline theme style on components, it may increase SSR rendered HTML size. You may use `inline-theme-disabled` prop on `n-config-provider` to disable it. For pros & cons see `n-config-provider`'s doc.
## Known Issues
The following components has some bugs in SSR scene, please avoid using them if possible. We will fix them gradually.
- `n-scrollbar`, `n-data-table` (It works after vue >= 3.2.36)
- `n-anchor`
- `n-avatar-group`
- `n-watermark`
- `n-affix`
- `n-transfer`
---
# Nuxt.js
## Caveat
This document pertains to SSR (Server-Side Rendering). Please familiarize yourself with the [SSR Caveats](https://www.naiveui.com/en-US/docs/ssr.md#Caveat) before proceeding.
## Nuxt.js Demo
You can refer to [example](https://github.com/07akioni/naive-ui-nuxt-demo).
## Using Nuxt Module
This is the same approach which previous demo uses.
Install the [module](https://github.com/07akioni/nuxtjs-naive-ui) to your Nuxt application with one command:
```bash
# npm
npx nuxi module add nuxtjs-naive-ui
# pnpm
pnpm dlx nuxi module add nuxtjs-naive-ui
```
## Using Auto Import in Nuxt
You can also use the `unplugin-auto-import` plugin to automatically import APIs and the `unplugin-vue-components` plugin to automatically import components on demand. In this case, the `nuxt.config.ts` file will have a few additional configuration lines compared to the example above.
```ts
import AutoImport from 'unplugin-auto-import/vite'
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
import Components from 'unplugin-vue-components/vite'
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
modules: ['nuxtjs-naive-ui'],
vite: {
plugins: [
AutoImport({
imports: [
{
'naive-ui': [
'useDialog',
'useMessage',
'useNotification',
'useLoadingBar'
]
}
]
}),
Components({
resolvers: [NaiveUiResolver()]
})
]
}
})
```
---
# Vitepress
## Caveat
This document pertains to SSR (Server-Side Rendering). Please familiarize yourself with the [SSR Caveats](https://www.naiveui.com/en-US/docs/ssr.md#Caveat) before proceeding.
## Example
This is a [demo](https://github.com/07akioni/naive-ui-vitepress-demo) for using `naive-ui` in `vitepress` with SSR enabled.
You can directly use the demo.
## Key process from scratch
If you want to build your own demo from scratch, follow the next steps:
### 0. Install `@css-render/vue3-ssr`
Make sure its version `>=0.15.14`.
```bash
# npm
npm install --save-dev @css-render/vue3-ssr
# pnpm
pnpm install --save-dev @css-render/vue3-ssr
```
### 1. Add this content to `.vitepress/theme/index.js`
```js
// .vitepress/theme/index.js
import { setup } from '@css-render/vue3-ssr'
import { NConfigProvider } from 'naive-ui'
import { useRoute } from 'vitepress'
import DefaultTheme from 'vitepress/theme'
import { defineComponent, h, inject } from 'vue'
const { Layout } = DefaultTheme
const CssRenderStyle = defineComponent({
setup() {
const collect = inject('css-render-collect')
return {
style: collect()
}
},
render() {
return h('css-render-style', {
innerHTML: this.style
})
}
})
const VitepressPath = defineComponent({
setup() {
const route = useRoute()
return () => {
return h('vitepress-path', null, [route.path])
}
}
})
const NaiveUIProvider = defineComponent({
render() {
return h(
NConfigProvider,
{ abstract: true, inlineThemeDisabled: true },
{
default: () => [
h(Layout, null, { default: this.$slots.default?.() }),
import.meta.env.SSR ? [h(CssRenderStyle), h(VitepressPath)] : null
]
}
)
}
})
export default {
extends: DefaultTheme,
Layout: NaiveUIProvider,
enhanceApp: ({ app }) => {
if (import.meta.env.SSR) {
const { collect } = setup(app)
app.provide('css-render-collect', collect)
}
}
}
```
### 2. Add this content to `.vitepress/config.mts`
```ts
import { defineConfig } from 'vitepress'
const fileAndStyles: Record = {}
export default defineConfig({
// ...
vite: {
ssr: {
noExternal: ['naive-ui', 'date-fns', 'vueuc']
}
},
postRender(context) {
const styleRegex = /((.|\s)+)<\/css-render-style>/
const vitepressPathRegex = /(.+)<\/vitepress-path>/
const style = styleRegex.exec(context.content)?.[1]
const vitepressPath = vitepressPathRegex.exec(context.content)?.[1]
if (vitepressPath && style) {
fileAndStyles[vitepressPath] = style
}
context.content = context.content.replace(styleRegex, '')
context.content = context.content.replace(vitepressPathRegex, '')
},
transformHtml(code, id) {
const html = id.split('/').pop()
if (!html)
return
const style = fileAndStyles[`/${html}`]
if (style) {
return code.replace(/<\/head>/, `${style}`)
}
}
})
```
### 3. Start using naive-ui in your markdown file
```md
...
Hello World
...
```
---
# Vite SSG/SSE
## Caveat
This document pertains to SSR (Server-Side Rendering). Please familiarize yourself with the [SSR Caveats](https://www.naiveui.com/en-US/docs/ssr.md#Caveat) before proceeding.
## Setup Guide
If you are using `vite-sse` or `vite-ssg`. Follow the following steps to setup `naive-ui`.
### 1. Install `naive-ui`, `@css-render/vue3-ssr`
```bash
# pnpm
pnpm i naive-ui @css-render/vue3-ssr
# npm
npm i naive-ui @css-render/vue3-ssr
```
### 2. Modify `vite.config.ts`
Add following content. If there exists content already, merge them.
```ts
import { setup } from '@css-render/vue3-ssr'
defineConfig({
ssr: {
noExternal: ['naive-ui', 'vueuc', 'date-fns']
},
ssgOptions: {
async onBeforePageRender(_, __, appCtx) {
const { collect } = setup(appCtx.app)
;(appCtx as any).__collectStyle = collect
return undefined
},
async onPageRendered(_, renderedHTML, appCtx) {
return renderedHTML.replace(
/<\/head>/,
`${(appCtx as any).__collectStyle()}`
)
}
}
})
```
Then you can using naive-ui in `vite-ssg` or `vite-sse` project.
---
# Customizing theme
Naive-ui provides `n-config-provider` to customize the theme.
By default all of the components are light themed, without any configuration.
To learn more about `n-config-provider`, see [Config Provider](https://www.naiveui.com/en-US/components/config-provider.md).
## Use dark theme
Set `n-config-provider`'s `theme` prop to `darkTheme` imported from naive-ui to set dark theme inside `n-config-provider`.
If `theme` is `undefined` it won't affect the theme of components inside.
```html
```
You may need to include `` if you want to apply the dark theme globally, not just to the components.
To learn more, see [n-global-style](https://www.naiveui.com/en-US/docs/customize-theme.md#Sync-style-of-the-body-element).
## Get theme vars
Whether it's the default light theme (`lightTheme`), the modified dark theme (`darkTheme`), or the custom theme we adjusted, you can get theme variables within the scope of the theme using [useThemeVars](https://www.naiveui.com/en-US/docs/theme.md#use-theme-vars).
## Customizing theme vars (design tokens)
No CSS (Scss, Less) needed.
The configured global theme variables will overwrite the theme variables that take effect on descendant components.
Set `n-config-provider`'s `theme-overrides` to customize theme vars. Naive-ui exports type `GlobalThemeOverrides` to help you define `theme-overrides`.
For available vars please follow the type hint of `GlobalThemeOverrides`.
If you want to view more theme variables, you can view them in the edit button at the bottom right corner of the Naive UI homepage.
You can modify the corresponding theme variable, you can get the themeOverrides object after export.
```html
```
## Customizing theme vars in TypeScript
If you are using ts to write code, this one is more suitable for you.
```html
```
## Customizing component theme vars
The use of component theme variables is the same as the use of global theme variables, and the component theme variables will override the global theme variables.
```html
theme
```
## Customizing theme vars under different themes
If you want to use different theme variables on light and dark theme at the same time, you can take a look at this.
```html
```
## Use the peers vars
In many cases, another component will be reused inside a component, so the theme variable of peers appears.
The theme variables related to peers have not been exposed yet. Use `GlobalThemeOverrides` to view the peers variables of the corresponding component.
The specific available peers will be updated later.
```html
```
## Sync style of the body element
For the following reasons, you may need to set some styles on `document.body`.
1. Naive-ui will mount some global style that is unresponsive (to theme, not media query). For example `font-family`. The style works fine by default, however they won't change when theme is changed.
2. `n-config-provider` can't sync global style (for example, body's background color) outside it.
You can use `n-global-style` to sync common global style to the body element. In the following example, `n-global-style` will sync the theme provided by `n-config-provider` to `document.body`.
```html
```
## Theme editor
Naive-ui provides a theme editor to help you edit theme and export the corresponding configuration. It can be placed inside `n-config-provider`.
The theme editor is not included in global installation (`app.use(naive)`). You need to import it explicitly to use it.
```html
```
---
# Internationalization
Naive-ui provides `n-config-provider` to customize the internationalization. By default, all components are in English.
To learn more about `n-config-provider`, see [Config Provider](https://www.naiveui.com/en-US/components/config-provider.md).
## Configure
Set `n-config-provider`'s `locale` prop to `enUS` imported from naive-ui to set Chinese theme inside `n-config-provider`.
Set `n-config-provider`'s `date-locale` prop to `dateEnUS` imported from naive-ui to set Chinese theme's date inside `n-config-provider`.
```html
```
## Supported languages
PRs are welcomed for locales that are not supported yet!
The following list is sorted by 'Config' column.
| Language | Config | Date config | Version |
| ---------------------------- | ------ | ----------- | ------- |
| Afrikaans (South Africa) | afZA | dateAfZA | |
| Amharic (Ethiopia) | amET | dateAmET | |
| Arabic (العربية) | arDZ | dateArDZ | 2.34.0 |
| Azerbaijani (Azərbaycanca) | azAZ | dateAzAZ | 2.39.0 |
| Belarusian (Belarus) | beBY | dateBeBY | |
| Bulgarian (Bulgaria) | bgBG | dateBgBG | |
| Bengali (Bangladesh) | bnBD | dateBnBD | |
| Catalan (Spain) | caES | dateCaES | |
| Czech (Czechia) | csCZ | dateCsCZ | 2.38.2 |
| Danish (Denmark) | daDK | dateDaDK | 2.43.0 |
| German (Germany) | deDE | dateDeDE | |
| Greek (Greece) | elGR | dateElGR | |
| English (British) | enGB | dateEnGB | 2.25.1 |
| English | enUS | dateEnUS | |
| Esperanto | eo | dateEo | 2.25.2 |
| Spanish (Argentina) | esAR | dateEsAR | 2.24.2 |
| Spanish (Spain) | esES | dateEsES | |
| Estonian | etEE | dateEtEE | 2.38.0 |
| Basque (Spain) | euES | dateEuES | |
| Persian | faIR | dateFaIR | 2.34.4 |
| Finnish (Finland) | fiFI | dateFiFI | |
| Filipino (Philippines) | filPH | dateFilPH | |
| French | frFR | dateFrFR | |
| Galician (Spain) | glES | dateGlES | |
| Gujarati (India) | guIN | dateGuIN | |
| Hebrew (Israel) | heIL | dateHeIL | |
| Hindi (India) | hiIN | dateHiIN | |
| Croatian (Croatia) | hrHR | dateHrHR | |
| Hungarian (Hungary) | huHU | dateHuHU | |
| Armenian (Armenia) | hyAM | dateHyAM | |
| Bahasa Indonesia | idID | dateIdID | |
| Icelandic (Iceland) | isIS | dateIsIS | |
| Italiano | itIT | dateItIT | 2.24.2 |
| Japanese | jaJP | dateJaJP | |
| Georgian (Georgia) | kaGE | dateKaGE | |
| Kazakh (Kazakhstan) | kkKZ | dateKkKZ | |
| Khmer (Cambodia) | kmKH | dateKmKH | 2.41.0 |
| Kannada (India) | knIN | dateKnIN | |
| Korean (South Korea) | koKR | dateKoKR | 2.28.1 |
| Kyrgyz (Kyrgyzstan) | kyKG | dateKyKG | |
| Lao (Laos) | loLA | dateLoLA | |
| Lithuanian (Lithuania) | ltLT | dateLtLT | |
| Latvian (Latvia) | lvLV | dateLvLV | |
| Macedonian (North Macedonia) | mkMK | dateMkMK | |
| Malayalam (India) | mlIN | dateMlIN | |
| Mongolian (Mongolia) | mnMN | dateMnMN | |
| Marathi (India) | mrIN | dateMrIN | |
| Malay (Malaysia) | msMY | dateMsMY | |
| Burmese (Myanmar) | myMM | dateMyMM | |
| Norwegian Bokmål (Norway) | nbNO | dateNbNO | |
| Nepali (Nepal) | neNP | dateNeNP | |
| Dutch (Netherlands) | nlNL | dateNlNL | 2.29.0 |
| Norwegian Nynorsk (Norway) | nnNO | dateNnNO | |
| Punjabi (India) | paIN | datePaIN | |
| Polish (Poland) | plPL | datePlPL | 2.25.2 |
| Portuguese (Brazil) | ptBR | datePtBR | 2.28.1 |
| Portuguese (Portugal) | ptPT | datePtPT | |
| Romansh (Switzerland) | rmCH | dateRmCH | |
| Romanian (Romania) | roRO | dateRoRO | |
| Russian | ruRU | dateRuRU | |
| Sinhala (Sri Lanka) | siLK | dateSiLK | |
| Slovak | skSK | dateSkSK | 2.25.3 |
| Slovenian (Slovenia) | slSI | dateSlSI | |
| Albanian (Albania) | sqAL | dateSqAL | |
| Serbian (Serbia) | srRS | dateSrRS | |
| Swedish | svSE | dateSvSE | 2.35.0 |
| Swahili (Kenya) | swKE | dateSwKE | |
| Tamil (India) | taIN | dateTaIN | |
| Telugu (India) | teIN | dateTeIN | |
| Thai (Thailand) | thTH | dateThTH | 2.27.0 |
| Turkish | trTR | dateTrTR | 2.34.0 |
| Uyghur (China) | ugCN | dateUgCN | |
| Ukrainian | ukUA | dateUkUA | |
| Urdu (Pakistan) | urPK | dateUrPK | |
| Uzbek (Uzbekistan) | uzUZ | dateUzUZ | 2.39.0 |
| Vietnamese (Vietnam) | viVN | dateViVN | 2.30.7 |
| Chinese (Simplified) | zhCN | dateZhCN | |
| Chinese (Traditional) | zhTW | dateZhTW | |
| Zulu (South Africa) | zuZA | dateZuZA | |
## Customize the existing locale
You can use `createLocale` to customize the existing locale.
```html
```
---
# Create Themed Component
You may not want to use only the provided components and want to write themed components.
Naive UI provides some tools for developers to create themed components easier.
## Demos
### Provide Theme
Use `n-config-provider` to set the theme of all its descendant components.
```vue
Dark
Light
```
### Use Naive Element
Naive UI has `n-element` component. See [Element](https://www.naiveui.com/en-US/components/element.md).
```vue
Dark
Light
I am a Span.
```
### useThemeVars
Naive UI provides `useThemeVars`. It contains common theme variables.
```vue
{{ themeVars }}
```
---
# Potential Style Conflict
## Style Element Position
Sometimes you want to control where the style element should be inserted.
For example. If you have a tailwind reset style, you don't want it to be inserted after naive-ui's style. Since it may override button's style, etc.
You can create a `` element inside `head` element, then naive-ui's style will be inserted right before it.
Also, naive-ui uses [vueuc](https://github.com/07akioni/vueuc). If you need, its style can be controlled by `` (generally it's not needed).
```html
```
## About Tailwind's Preflight Style Override
You may find adding a meta tag to your static html files doesn't work (naive's style would still be overriden), since your toolchain may always insert tailwind's style at the end of the head tag. In this situation, you need to insert the meta tag dynamically right before the app is mounted.
```ts
const meta = document.createElement('meta')
meta.name = 'naive-ui-style'
document.head.appendChild(meta)
vueApp.mount('#app')
```
## Disable Preflight Style (CSS Reset)
To make naive-ui work for most users out of box, mounting any component of naive would create global preflight style. However it may not be expected. If you want to disable it, using `n-config-provider` like this.
```html
```
---
# Third-Party Libraries
Naive UI is a high-quality Vue component library of unified design specifications. We prefer to provide only UI components with a unified specification and visual presentation. So we recommend the following great resources from the community that complement Naive UI.
If you want to contribute excellent resources, you can create a pull request of this page in naive-ui's github repo.
| Resources | Descriptions |
| --- | --- |
| [Naive UI Admin](https://github.com/jekip/naive-ui-admin) | A free open source out-of-box UI solution for enterprise applications. |
| [Admin Work](https://github.com/qingqingxuan/admin-work) | A free open source, powerful, easy to use, beautiful back-office management system solution. |
| [Soybean Admin](https://github.com/honghuangdc/soybean-admin) | A beautiful vue admin template, based on Vue3 + Vite + Naive UI + TypeScript. |
| [Rengar Admin](https://github.com/RengarJS/rengar-admin) | A mid-backend management system template based on Vue 3.5 + Vite 7 + TypeScript + Naive UI + Pinia + UnoCSS, which is concise without excessive encapsulation and has simple and easy-to-understand code. |
| [GoView](https://github.com/dromara/go-view) | A free open source and powerful yet accessible data visualization tool. |
| [Vue Naive Admin](https://github.com/zclzone/vue-naive-admin) | A lightweight backend management template base on Vue3 + Vite4 + Pinia + Unocss + Naive UI. |
| [Vue Bag Admin](https://vite.itnavs.com/admin/) | 🎉vue-bag-admin,Using Vite4, Vue3, TypeScript, JavaScript construction, support a variety of writing and call, a complete framework system, responsive background management system |
| [Celeris Web](https://github.com/kirklin/celeris-web) | Celeris Web, based on Vue 3 and Vite, is a free and open-source front-end framework with Naive UI components and TypeScript support, featuring a Monorepo structure. It also integrates with OpenAI, providing natural language processing capabilities for modern web development. |
| [Nova admin](https://github.com/chansee97/nova-admin) | a clean and concise back-end management template based on Vue3, Vite5, Typescript, and Naive UI. It implements complete functionality in a simple way, while also considering code standards, readability, and avoiding excessive encapsulation to facilitate secondary development. |
| [chatgpt-web](https://github.com/Chanzhaoyu/chatgpt-web) | ChatGPT demo web page built with Express and Vue3 |
| [pro-naive-ui](https://github.com/Zheng-Changfu/pro-naive-ui) | Based on Naive UI secondary encapsulation, more functions are extended on the original components |
| [vue3-dynamic-form](https://github.com/yayaluoya/vue3-dynamic-form) | A dynamic form designer based on Vue3, Naive UI, to implement a lot of basic controls, can be very convenient to customize the control. |
| [astral-3d-editor](https://github.com/mlt131220/Astral3DEditor) | 3D scene building tool based on Vue3 + Naive UI + ThreeJS + Vite5 + Typescript, supporting CAD & BIM analysis, including weather system, particle system, plug-in center... |
| [it-tools](https://github.com/CorentinTh/it-tools) | Developed based on Vue3 and the Naive UI component library, it brings together a variety of practical online tools |
| [Lithe Admin](https://github.com/tenianon/lithe-admin) | A lightweight and elegant backend management template, built using Vue3 + Naive UI + Vite + TypeScript + Pinia, featuring a Tailwind CSS Color color scheme and a frosted texture design. |
| [Vue Simple Template](https://github.com/gitboyzcf/vue3-simple-template) | A simple universal starter template based on Vue 3.5 + Vite 8 + Naive UI + TypeScript + Pinia + Vue Router + Tailwind CSS 4 + Pnpm. |
---
# Avatar
On the Internet, nobody knows you're a dog.
## Demos
### Size
Avatar has `small`, `medium` and `large` sizes. You could also use a custom px number for size.
```vue
```
### Shape
Avatar can be `round`.
```vue
```
### Color
You can set colors related to things you want to eat.
```vue
M
```
### Badge
Using it with `badge` would be nice (if you like tons of notifications).
```vue
App
```
### Icon
I like using an icon in an avatar.
```vue
```
### Content size
Text is resized to fit the avatar.
```vue
{{ value }}
{{ value }}
```
### Fallback
Show 07akioni if loading fails.
```vue
```
### Avatar Group
Crowded people.
---
Please note that the demo uses `NGAvatarGroup` which is available since naive-ui `2.43.0`.
The `NGAvatarGroup` is the same as `NAvatarGroup` except with a generic `options` prop which can make slots & props types more accurate in Vue files.
The component is only available in Vue >= `3.3` and in `.vue` files.
If your environment doesn't support [Vue Generic Components](https://blog.vuejs.org/posts/vue-3-3#generic-components), please use `NAvatarGroup` instead.
The `NGAvatarGroup` should be imported from `'naive-ui/generic'`.
```vue
{{ name }}
+{{ rest }}
```
### Lazy load
Load the images only after they enter the viewport. There are two ways to use it: one is to use the `lazy` property alone, which will be set to the value of the [HTMLImageElement.loading](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/loading) property, and the other is to use `lazy` together with the `intersection-observer-options` configuration to implement lazy loading using the [IntersectionObserver](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver) API.
```vue
use
lazy
along
use
lazy
with
intersection-observer-options
```
## API
### Avatar Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| bordered | `boolean` | `false` | Whether to display a avatar with border. | |
| color | `string` | `undefined` | The background color of the avatar. | |
| fallback-src | `string` | `undefined` | Image URL to show when avatar fails to load. | |
| img-props | `ImgHTMLAttributes` | `undefined` | The props of the img element inside the component. | 2.34.0 |
| intersection-observer-options | `{ root?: Element \| Document \| string \| null, rootMargin?: string, threshold?: number \| number[]; }` | `undefined` | Intersection observer's config to be applied when `lazy=true`. | 2.31.0 |
| lazy | `boolean` | `false` | Load image after it enters viewport. When used alone, it will be assigned the property value of [HTMLImageElement.loading](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/loading). Alternatively, it can be used in conjunction with the `intersection-observer-options` configuration to achieve lazy loading. | 2.31.0 |
| object-fit | `'fill' \| 'contain' \| 'cover' \| 'none' \| 'scale-down'` | `'fill'` | Object-fit type of the image in the container. | |
| render-fallback | `() => VNodeChild` | `undefined` | Render function of fallback content. | 2.33.4 |
| render-placeholder | `() => VNodeChild` | `undefined` | Render function of placeholder. | 2.33.4 |
| round | `boolean` | `false` | Whether to display a rounded avatar. | |
| size | `'small' \| 'medium' \| 'large' \| number` | `'medium'` | Avatar's size. |
| src | `string` | `undefined` | Avatar's image source. | |
| on-error | `(e: Event) => void` | `undefined` | Callback executed when the avatar image fails to load. | |
### AvatarGroup Props
The generic type is `` (available since `2.43.0`).
It is only supported in `.vue` files with `Vue >= 3.3`. You can use it by `importing NGAvatarGroup from 'naive-ui/generic'`. Otherwise, please use the regular `n-avatar-group` component.
```ts
interface AvatarGroupOption {
src: string
}
```
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| expand-on-hover | `boolean` | `false` | Expand on hover. | 2.37.0 |
| max | `number` | `undefined` | Max avatar count in the group. | |
| max-style | `Object \| string` | `undefined` | The style of the overflow placeholder. | |
| options | `Array` | `[]` | Avatar group options. | |
| size | `'small' \| 'medium' \| 'large' \| number` | `'medium'` | Avatar's size. | 2.43.0 |
| vertical | `boolean` | `false` | Whether display a vertical avatar group. | |
### Avatar Slots
| Name | Parameters | Description | Version |
| --- | --- | --- | --- |
| default | `()` | The content of the avatar. | |
| fallback | `()` | Content if avatar load fails. | 2.33.4 |
| placeholder | `()` | Placeholder shown when image is not loaded. | 2.31.0 |
### AvatarGroup Slots
| Name | Parameters | Description |
| --- | --- | --- |
| avatar | `(info: { option: { src: string } })` | Avatar of the avatar group. |
| default | `()` | The content of the avatar group. |
| rest | `(info: { options: Array<{ src: string }>, rest: number })` | Overflow indicator of the avatar group. |
---
# Button
Button is used to trigger some actions.
## Demos
### Basic
There are `default`, `primary`, `tertiary`, `info`, `success`, `warning` and `error` button types.
```vue
Default
Tertiary
Primary
Info
Success
Warning
Error
```
### Secondary button
```vue
Default
Tertiary
Primary
Info
Success
Warning
Error
Default
Primary
Info
Success
Warning
Error
```
### Tertiary button
```vue
Default
Primary
Info
Success
Warning
Error
Default
Primary
Info
Success
Warning
Error
```
### Quaternary button
```vue
Default
Primary
Info
Success
Warning
Error
Default
Primary
Info
Success
Warning
Error
```
### Dashed
Use `dashed` to show a dashed button.
```vue
Default
Primary
Info
Success
Warning
Error
```
### Size
Buttons can be `tiny`, `small`, `medium` and `large` in size.
```vue
Small Small
Small
Not Small
Not Not Small
```
### Text button
It just looks like text.
```vue
The Engine is Still Spitting Smoke
```
### Tag
You can render buttons with different tags. For example ``.
```vue
Anyway.News
```
### Disabled
Buttons can be disabled.
```vue
Disabled
```
### Icon
Icons can be used in buttons. You can use `render-icon` prop or `icon` slot.
```vue
+100$
+100$
```
### Events
Handle events of buttons.
```vue
Click Me
```
### Shape
Buttons can have different shapes.
```vue
Round
Rect
```
### Ghost
Ghost buttons have transparent backgrounds.
```vue
Default
Primary
Info
Success
Warning
Error
```
### Loading
Buttons can have loading states.
```vue
Click Me
Click Me
```
### Custom color
These two colors look like a toadstool.
```vue
#8a2be2
#ff69b4
#8a2be2
#ff69b4
#8a2be2
#ff69b4
```
### Button group
Buttons can be grouped.
```vue
Live a
Sufficient
Life
With
Enough
Happiness
Life
Is
Good
Eat
One More
Apple
```
### Use icons as buttons
Sometimes you may want to use an icon as a button and customize its size. You can use the `text` prop and `font-size` style to set it.
```vue
```
### Using popover in disabled state
The native disabled button won't trigger some mouse events so `n-popover` can't listen to it. If you need to use it, you can use `tag` prop to change button's behavior.
```vue
Disabled button as div
Lpsum
```
## API
### Button Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| attr-type | `'button' \| 'submit' \| 'reset'` | `'button'` | The `type` attribute of the button's DOM. | |
| block | `boolean` | `false` | Whether the button is displayed as block. | |
| bordered | `boolean` | `true` | Whether the button shows the border. | |
| circle | `boolean` | `false` | Whether the button is round. | |
| color | `string` | `undefined` | Button color (support `#FFF`, `#FFFFFF`, `yellow`,`rgb(0, 0, 0)` formatted colors). | |
| dashed | `boolean` | `false` | Whether the button's border is a dashed line. | |
| disabled | `boolean` | `false` | Whether the button is disabled. | |
| focusable | `boolean` | `true` | Whether the button is focusable. | |
| ghost | `boolean` | `false` | Whether the button is ghost. | |
| native-focus-behavior | `boolean` | Browser is not Safari | Whether to follow button's native focus behavior. Since safari's button can't be focused by click, naive-ui uses some tricks to make it focusable on safari. If you don't need the behavior or need the button to be draggable, you can enable the prop. | 2.28.3 |
| icon-placement | `'left' \| 'right'` | `'left'` | The position of the icon in the button. | |
| keyboard | `boolean` | `true` | Whether is supports keyboard operation. | |
| quaternary | `boolean` | `false` | Whether the button is quaternary button. | |
| loading | `boolean` | `false` | Whether the button shows the loading status. | |
| spin-props | `{ strokeWidth?: number, stroke?: string, scale?: number, radius?: number }` | `undefined` | Loading icon properties. | 2.44.0 |
| render-icon | `() => VNodeChild` | `undefined` | Render function that renders button icon. | 2.34.0 |
| round | `boolean` | `false` | Whether the button shows rounded corners. | |
| secondary | `boolean` | `false` | Whether the button is secondary button. | |
| size | `'tiny' \| 'small' \| 'medium' \| 'large'` | `'medium'` | Button size. | |
| strong | `boolean` | `false` | Whether to use strong text in the button. | |
| tertiary | `boolean` | `false` | Whether the button is tertiary button. | |
| text | `boolean` | `false` | Whether to display as a text button. | |
| text-color | `string` | `undefined` | Button text color (support `#FFF`, `#FFFFFF`, `yellow`,`rgb(0, 0, 0)` formatted colors). | |
| type | `'default' \| 'tertiary' \| 'primary' \| 'success' \| 'info' \| 'warning' \| 'error'` | `'default'` | Button type. | |
| tag | `string` | `'button'` | What tag need the button be rendered as. | |
### ButtonGroup Props
| Name | Type | Default | Description |
| --- | --- | --- | --- |
| size | `'tiny' \| 'small' \| 'medium' \| 'large'` | `undefined` | The buttons' size in button group. If set, the button's size prop inner group won't work. |
| vertical | `boolean` | `false` | Directions of buttons in the group. |
### Button Slots
| Name | Parameters | Description |
| ------- | ---------- | ---------------------------------- |
| default | `()` | The default content of the button. |
| icon | `()` | The icon of the button. |
### ButtonGroup Slots
| Name | Parameters | Description |
| ------- | ---------- | -------------------------------------- |
| default | `()` | The button group is filled by default. |
---
# Card
Just put something in it.
## Demos
### Basic
A basic card.
```vue
Card Content
```
### Size
Card has `small`, `medium`, `large`, `huge` sizes.
```vue
Card Content
Card Content
Card Content
Card Content
```
### Cover
Card can have a cover.
```vue
Card Content
```
### Hoverable
```vue
Card Content
```
### Slots
Card has many slots to help you write less code.
```vue
#header-extra
Card Content
#footer
#action
```
### Border
Card can be used without border.
```vue
Card Content
```
### Segmented
`content`, `footer` can be segmented or `soft` segmented. `action` can be segmented. Segment border will appear at the top of segmented parts.
```vue
#header-extra
Card Content
#footer
#action
```
### Closable
You may need this when using it in a modal.
```vue
Card Content
```
### No title
Nobody said a card must have a title.
```vue
No title
```
### Content Scroll
Enable `content-scrollable` to keep scrolling inside the content area only. Header and footer stay fixed. It is usually used with a fixed card height.
```vue
Task {{ i }}: only content area scrolls.
Footer actions stay fixed
```
### Loading
Use `n-skeleton` to simulate loading effect.
```vue
Lorem Ipsum
Lorem ipsum dolor sit amet,
consectetur adipiscing elit,
sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua.
Ut enim ad minim veniam,
quis nostrud exercitation ullamco
```
### Custom
Card provides `content-style`, `header-style`, `footer-style` to help you customize style. For example you want an card with no padding to put whatever you want.
```vue
PARKLIFE
ROCKLIFE
```
### Embedded effect
In light mode, sometimes you may need to make background a bit darker to distinguish card from white background.
```vue
Tonight I'm a rock 'n' roll star
Tonight I'm a rock 'n' roll star
```
## Card
### Card Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| action | `() => VNodeChild` | `undefined` | Operating area content, must be a render function. | 2.38.2 |
| bordered | `boolean` | `true` | Whether to show the card border. | |
| closable | `boolean` | `false` | Is it allowed to close. | |
| close-focusable | `boolean` | `false` | Whether the close button can be focused. | 2.43.0 |
| content | `string \| (() => VNodeChild)` | `undefined` | Card content, can be a render function. | 2.38.2 |
| content-class | `string` | `undefined` | The class of the card content area. | 2.36.0 |
| content-scrollable | `boolean` | `false` | Whether only the card content area is scrollable (recommended with fixed height). | 2.44.0 |
| content-style | `Object \| string` | `undefined` | The style of the card content area. | |
| cover | `() => VNodeChild` | `undefined` | Cover content, must be a render function. | 2.38.2 |
| embedded | `boolean` | `false` | Use a darker background color to show the embedding effect (only for bright themes) | |
| footer | `() => VNodeChild` | `undefined` | Footer content, must be a render function. | 2.38.2 |
| footer-class | `string` | `undefined` | The class of the bottom area of the card. | 2.36.0 |
| footer-style | `Object \| string` | `undefined` | The style of the bottom area of the card. | |
| header-class | `string` | `undefined` | The class of the card head area. | 2.36.0 |
| header-style | `Object \| string` | `undefined` | The style of the card head area. | |
| header-extra | `() => VNodeChild` | `undefined` | Header extra content, must be a render function. | 2.38.2 |
| header-extra-class | `string` | `undefined` | The class of the card head extra area. | 2.36.0 |
| header-extra-style | `Object \| string` | `undefined` | The style of the card head extra area. | 2.25.0 |
| hoverable | `boolean` | `false` | Whether to show shadow when hovering on the card. | |
| segmented | `boolean \| { [part in 'content' \| 'footer' \| 'action']?: boolean \| 'soft' }` | `false` | Segment divider settings of the card. | |
| size | `'small' \| 'medium' \| 'large' \| 'huge'` | `'medium'` | Card size. | |
| tag | `string` | `'div'` | What tag need the card be rendered as. | 2.34.3 |
| title | `string \| (() => VNodeChild)` | `undefined` | Card title. | Render function since 2.38.2 |
| on-close | `() => void` | `undefined` | Callback function triggered upon closing the card. | |
### Card Slots
| Name | Parameters | Description |
| ------------ | ---------- | ----------------------- |
| cover | `()` | Cover content. |
| header | `()` | Header content. |
| header-extra | `()` | Header extra content. |
| default | `()` | Card content. |
| footer | `()` | Footer content. |
| action | `()` | Operating area content. |
---
# Carousel
It's usually used to display good news.
## Demos
### Basic
```vue
```
### Arrow
Set `show-arrow` to show the arrow。
```vue
```
### Autoplay
Set `autoplay`, it can autoplay。
```vue
```
### Dots
Set `dot-type` to change the style of the dots. You can use `:show-dots="false"` to hide the dots.
Set `dot-placement` to change the position of the dots.
```vue
{{ _type }}
{{ _placement }}
{{ _direction }}
Show arrow
No arrow
```
### Vertical
```vue
```
### Space between
```vue
```
### Slides per view
Please note that this prop will conflict with `loop`. If you need to customize the number of displays per view, then the `loop` prop will be disabled.
```vue
```
### Auto slides per view
```vue
```
### Centered
Set `centered-slides` to center all `slides`, this is only useful when `effect` is `slide` and `card`.
```vue
```
### Effect
If you want to customize the transition effect, you can use `transition-props` and set `effect` to `custom`.
```vue
{{ effect }}
```
### Customizing transition
If you want to customize the transition effect, you can use `transition-props` and set `effect` to `'custom'`. For transition props, see [reference](https://v3.vuejs.org/api/built-in-components.html#transition).
```vue
```
### Hover
Set the `trigger` to `hover` to trigger the switch when the mouse passes over the dots.
```vue
```
### Keyboard
Whether to switch the carousel by pressing the key, it is only valid when the focus is on Dots.
```vue
{{ _direction }}
```
### Mousewheel
```vue
```
### Simulate drag
Carousel enable the `Touch` event simulation by default. If you need the carousel chart to respond to mouse drag, you can use `draggable` prop.
```vue
```
### Customzing arrow and dots
```vue
```
### Customize card
You can use `next-slide-style` and `prev-slide-style` to adjust the ratio of front & back cards size ratio.
```vue
```
### Custom Dots
```vue
{{ currentIndex + 1 }} / {{ total }}
```
## API
### Carousel Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| autoplay | `boolean` | `false` | Whether to scroll automatically. | |
| centered-slides | `boolean` | `false` | Whether to center the current view carousel. | 2.24.0 |
| current-index | `number` | `undefined` | current index. | 2.24.0 |
| default-index | `number` | `0` | default index. | 2.24.0 |
| direction | `'horizontal' \| 'vertical'` | `'horizontal'` | Carousel shows the direction. | |
| dot-placement | `'top' \| 'bottom' \| 'left' \| 'right'` | `'bottom'` | Dot placement in the panel. | 2.24.0 |
| dot-type | `'dot' \| 'line'` | `'dot'` | Dot style. | 2.24.0 |
| draggable | `boolean` | `false` | Whether to switch the carousel by dragging the mouse. | 2.24.0 |
| effect | `'slide' \| 'fade' \| 'card' \| 'custom'` | `'slide'` | Transition effect when switching between carousel. | 2.24.0, `'card'` 2.24.2 |
| interval | `number` | `5000` | Auto play interval (ms). | |
| keyboard | `boolean` | `false` | Whether to switch the carousel by pressing the key, it only works when the focus is on Dots. | 2.24.0 |
| loop | `boolean` | `true` | Whether to loop. | 2.24.0 |
| mousewheel | `boolean` | `false` | Whether to switch the carousel through the mouse wheel. | 2.24.0 |
| next-slide-style | `object \| string` | `undefined` | Next slide's style. | 2.27.0 |
| prev-slide-style | `object \| string` | `undefined` | Previous slide's style. | 2.27.0 |
| show-arrow | `boolean` | `false` | Whether to show arrow buttons. | 2.24.0 |
| show-dots | `boolean` | `true` | Whether to show dots. | 2.24.0 |
| slides-per-view | `'auto' \| number` | `1` | Number of carousels displayed on per view. | 2.24.0 |
| space-between | `number` | `0` | The spacing between the carousels. | 2.24.0 |
| touchable | `boolean` | `true` | Whether to switch the carousel by touch. | 2.24.0 |
| transition-style | `{ transitionDuration?: string, transitionTimingFunction?: string }` | `{ transitionDuration: '300ms' }` | The style of the transition effect. | 2.24.0 |
| transition-props | `TransitionProps` | `undefined` | Custom transition effect properties, [reference](https://v3.vuejs.org/api/built-in-components.html#transition). | 2.24.0 |
| trigger | `'click' \| 'hover'` | `'click'` | The method of manual switching. | |
| on-update:current-index | `(currentIndex: number, lastIndex: number) => void` | `undefined` | Callback function when the current index changes. | 2.24.0 |
### Carousel Slots
| Name | Parameters | Description | Version |
| --- | --- | --- | --- |
| default | `()` | Carousel content. |
| arrow | `(info: { total: number, currentIndex: number, to: (index: number) => void, prev: () => void, next: () => void })` | Arrow. | 2.24.0 |
| dots | `(info: { total: number, currentIndex: number, to: (index: number) => void })` | Dots. | 2.24.0 |
### Carousel Methods
| Name | Type | Description | Version |
| --- | --- | --- | --- |
| to | `(index: number) => void` | Slide to index. | 2.24.0 |
| prev | `() => void` | Slide to previous page. | 2.24.0 |
| next | `() => void` | Slide to next page. | 2.24.0 |
| getCurrentIndex | `() => number` | Get current index. | 2.24.0 |
---
# Collapse
I saw it appears in many side control panels.
## Demos
### Basic
```vue
good
nice
very good
```
### Arrow placement
Use `arrow-placement` to set the placement of arrow.
```vue
good
nice
very good
```
### Accordion
Like an accordion.
```vue
good
good
```
### Nested
It can be nested.
```vue
good
good
good
```
### Display directive
Set `display-directive` to `if` or `show` to determine whether to keep the DOM inside `n-collapse-item` when inactive.
```vue
good
good
good
```
### Click on item header
```vue
Bronze
Okay
Silver
Good
Gold
Excellent
```
### Customize icon
```vue
good
nice
very good
```
### Default expanded
It should be noted that even if only one panel you want to set to be expanded, `default-expanded-names` should also be passed in an array, unless `accordion` is set to `true`.
```vue
pass
pass fastly
stop
warn
```
### Extra info in header
Put some info on the right side of the item.
```vue
good
good
nice
nice
very good
very good
```
### Disabled
```vue
good
nice
very good
```
### Trigger areas
If you want to customize expansion trigger areas of collapse, you can use `trigger-areas` property.
```vue
main
extra
arrow
Extra
good
Extra
nice
Extra
very good
```
## API
### Collapse Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| accordion | `boolean` | `false` | Only allow one panel open at a time. |
| arrow-placement | `'left' \| 'right'` | `'left'` | Arrow placement side of text. |
| default-expanded-names | `string \| number \| Array \| null` | `null` | Pre-expanded panels that can still be collapsed. If `accordion` mode is set, it should be a non-array value. |
| display-directive | `'if' \| 'show'` | `'if'` | The display directive to use when `n-collapse-item` renders content. `'if'` corresponds to `v-if` and `'show'` corresponds to `v-show`. |
| expanded-names | `string \| number \| Array \| null` | `undefined` | Expanded panels that cannot be collapsed. If `accordion` mode is set, it should be a non-array value. |
| trigger-areas | `Array<'main' \| 'arrow' \| 'extra'>` | `['main', 'arrow', 'extra']` | Expansion trigger areas. If you don't want to trigger expansion on some areas, you can use the prop. | 2.37.1 |
| on-item-header-click | `(data: { name: string \| number, expanded: boolean, event: MouseEvent }) => void` | `undefined` | Callback function triggered when the title is clicked. |
| on-update:expanded-names | `(expandedNames: Array \| string \| number \| null) => void` | `undefined` | Callback function triggered when the expanded-names array is changed. |
### CollapseItem Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| disabled | `boolean` | `false` | Whether the item is disabled. | 2.32.2 |
| display-directive | `'if' \| 'show'` | `undefined` | The display directive to use when it is rendering its content. `'if'` corresponds to `v-if` and `'show'` corresponds to `v-show`. When it is set to `undefined` the value will follow its outer `n-collapse`. | |
| name | `string \| number` | random string | Item identifier (should be unique). | |
| title | `string` | `undefined` | Title. | |
### Collapse Slots
| Name | Parameters | Description |
| --- | --- | --- |
| arrow | `(props: { collapsed: boolean })` | Custom icons for folding panels. |
| default | `()` | The contents of the collapsible panel. |
| header | `(props: { collapsed: boolean })` | The content of the header of the collapsed panel node. |
### CollapseItem Slots
| Name | Parameters | Description |
| --- | --- | --- |
| arrow | `(props: { collapsed: boolean })` | The custom icon of the node header of the collapsible panel. |
| default | `()` | The contents of the collapsible panel node. |
| header | `(props: { collapsed: boolean })` | The content of the header of the collapsed panel node. |
| header-extra | `(props: { collapsed: boolean })` | The extra content of the header of the collapsed panel node. |
---
# Divider
Divide something.
## Demos
### Basic
```vue
Oops
Oops
```
### Title
```vue
Oops
Left
Oops
Right
Oops
Dashed
Oops
```
### Vertical
```vue
It isnot clearto see, emmm...
```
## API
### Divider Props
| Name | Type | Default | Description |
| --- | --- | --- | --- |
| dashed | `boolean` | `false` | Whether to show dashed line. |
| title-placement | `'left' \| 'right' \| 'center'` | `'center'` | Title placement. |
| vertical | `boolean` | `false` | Whether to show vertical direction. |
### Divider Slots
| Name | Parameters | Description |
| ------- | ---------- | --------------------- |
| default | `()` | The title of divider. |
---
# Dropdown
When you have some functions to trigger.
## Demos
### Basic
A basic dropdown.
```vue
Go For a Trip
```
### Icon
Dropdown options can also have icons!
```vue
User Profile
```
### Trigger
Different trigger methods for dropdown.
```vue
Hover!Click!
Oh! I'll Handle it Manually!
```
### Cascade
Dropdown can be cascaded.
```vue
People & Food
```
### Arrow
Show an arrow with the dropdown.
```vue
Go For a Trip
```
### Placement
Dropdown options can be aligned using the `placement` property.
```vue
Go For a Trip
```
### Size
A dropdown has different sizes.
```vue
SmallMediumLargeHuge
```
### Batch Render
Note: `render-label` works for group type label, which can be set in `option.type`.
```vue
Batch Rendered
```
### Manual Position
Note: When using manual position, `trigger` must be set to `'manual'`. In addition, you need to listen to the update:show callback to update the value of show, ensuring that shortcut operations such as the Esc key can close the menu normally.
```vue
Right Click
```
### Pure Render Content
You can simply render some content unrelated to option data. In this case, you can add an option with `type='render'`.
```vue
2021 Week 36
```
### Custom Option Props
Bind anything you want.
```vue
Go For a Trip
```
### Add Tooltip for Option
You can use `render-option` to add tooltip for an option.
```vue
Go For a Trip
```
## API
### Dropdown Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| animated | `boolean` | `true` | Use an animation when showing options. | |
| inverted | `boolean` | `false` | Use the inverted style. | |
| children-field | `string` | `'children'` | Field name of children. | |
| keyboard | `boolean` | `true` | Whether the component supports keyboard operation. (Be careful about the potential conflicts with other components keyboard operations) | |
| key-field | `string` | `'key'` | Field name of key. | |
| label-field | `string` | `'label'` | Field name of label. | |
| node-props | `(option: DropdownOption \| DropdownGroupOption) => HTMLAttributes` | `undefined` | Option HTML attributes generator. | 2.29.1 |
| menu-props | `(option: DropdownOption \| undefined, options: (DropdownOption \| DropdownGroupOption)[]) => HTMLAttributes` | `undefined` | Menu HTML attributes generator. | 2.31.0 |
| options | `Array` | `[]` | Dropdown options. | |
| render-icon | `(option: DropdownOption) => VNodeChild` | `undefined` | Render function that renders option icons. | |
| render-label | `(option: DropdownOption) => VNodeChild` | `undefined` | Render function that renders option labels. | |
| render-option | `(props: { node: VNode, option: DropdownOption \| DropdownGroupOption }) => VNodeChild` | `undefined` | Render function that renders option itself. | 2.29.1 |
| size | `'small'\|'medium'\|'large'\|'huge'` | `'medium'` | Dropdown size. | |
| on-clickoutside | `(e: MouseEvent) => void` | `undefined` | Callback function triggered when there is a click outside of the component. | |
| on-select | `(key: string \| number, option: DropdownOption) => void` | `undefined` | Callback function for after an option is selected. | |
For other props, for example `placement`, please see [Popover Props](https://www.naiveui.com/en-US/components/popover.md#Popover-Props). Note that `raw` is not available.
#### DropdownOption Type
| Property | Type | Description | Version |
| --- | --- | --- | --- |
| children? | `Array` | Child options. | |
| disabled? | `boolean` | Whether to disable the option. | |
| icon? | `() => VNodeChild` | Custom render function of an option icon. | |
| key? | `string \| number` | Option ID (should be unique). | |
| label? | `string \| () => VNodeChild` | Displayed label value. | |
| props? | `HTMLAttributes` | Customize option props. | |
| show? | `boolean` | Whether to show the option. | 2.33.3 |
#### DropdownDividerOption Type
| Property | Type | Description | Version |
| --- | --- | --- | --- |
| key? | `string \| number` | Divider ID (should be unique). | |
| show? | `boolean` | Whether to show the option. | 2.33.3 |
| type | `'divider'` | The type of the DropdownDividerOption. | |
#### DropdownGroupOption Type
| Property | Type | Description | Version |
| --- | --- | --- | --- |
| children? | `Array` | Children options of DropdownGroupOption. | |
| icon? | `() => VNodeChild` | Custom rendering function of the group icon. | |
| label? | `string` | Group label value. | |
| key? | `string \| number` | Group ID (should be unique). | |
| show? | `boolean` | Whether to show the option. | 2.33.3 |
| type | `'group'` | The type of the DropdownGroupOption. | |
#### DropdownRenderOption Type
| Property | Type | Description | Version |
| --- | --- | --- | --- |
| key? | `string \| number` | Render option ID (should be unique). | |
| render? | `() => VNodeChild` | Render function of the option content. | |
| show? | `boolean` | Whether to show the option. | 2.33.3 |
| type | `'render'` | The type of the DropdownRenderOption. | |
---
# Ellipsis
Complexity has to live somewhere.
When you hear somebody talk about a subtle concept, keep alert.
## Demos
### Basic
Basic single line ellipsis with tooltip.
```vue
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium
doloremque laudantium, totam rem aperiam
```
### Line clamp
See [caniuse](https://caniuse.com/?search=line-clamp) for compatibility.
```vue
Lorem ipsum dolor sit amet,
consectetur adipiscing elit,
sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua.
Ut enim ad minim veniam,
quis nostrud exercitation ullamco
```
### Expand trigger
Use `expand-trigger="click"` with the `line-clamp` parameter to achieve the function of clicking the abbreviated text to expand the complete text.
```vue
Lorem ipsum dolor sit amet,
consectetur adipiscing elit,
sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua.
Ut enim ad minim veniam,
quis nostrud exercitation ullamco
```
### Customize tooltip content
Use the `tooltip` slot to customize the tooltip content.
```vue
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium
doloremque laudantium, totam rem aperiam
Lorem Ipsum
Sed ut perspiciatis unde omnis
iste natus error sit voluptatem accusantium doloremque laudantium,
totam rem aperiam
```
### Better render performance
In most case, normal ellipsis is fast enough. However, if you have a huge amount ellipsis to render, you may use `n-performant-ellipsis` in place of `n-ellipsis`. It has better render performance with some caveats: Inner component may be unmounted and remouted again. Use it carefully.
```vue
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium
doloremque laudantium, totam rem aperiam
```
## API
### Ellipsis, PerformantEllipsis Props
`n-performant-ellipsis` since 2.35.0.
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| expand-trigger | `'click'` | `undefined` | Abbreviated content trigger event to expand to the full text. | 2.1.0 |
| line-clamp | `number \| string` | `undefined` | Maximum lines. | 2.1.0 |
| tooltip | `boolean \| TooltipProps` | `true` | Tooltip properties. | 2.1.0 |
### Ellipsis Slots
| Name | Parameters | Description |
| ------- | ---------- | ------------------------------------- |
| default | `()` | The content of the ellipsis. |
| tooltip | `()` | The content of the ellipsis' tooltip. |
---
# Gradient Text
It doesn't seem very useful... In fact it isn't.
## Demos
### Type
A gradient text component can have different types.
```vue
Boom!
Emmm
Oops!
Haha!
```
### Size
`font-size` CSS also works, but can be overridden by setting the size (if just a number is used, it's taken as pixels).
```vue
Live Forever
Live Forever
Married with Children
Back in the USSR
```
### Customizing gradient
Design it yourself.
```vue
Custom Color
Custom Color
A Scribbled Color
```
## API
### GradientText Props
| Name | Type | Default | Description |
| --- | --- | --- | --- |
| gradient | `string \| { from: string, to: string, deg: number \| string }` | `undefined` | Text gradient color parameters. |
| size | `number \| string` | `undefined` | Text size (when the unit is not specified the default unit will be `px`). |
| type | `'primary' \| 'info' \| 'success' \| 'warning' \| 'error'` | `'primary'` | Gradient Text type. |
### GradientText Slots
| Name | Parameters | Description |
| ------- | ---------- | --------------------------------- |
| default | `()` | The content of the gradient text. |
---
# Icon
It is recommend to use [xicons](https://www.xicons.org) as your icon library.
## Demos
### Basic
```vue
```
### Customize icon
(Make sure SVG's viewBox attribute is set)
```vue
```
### Depth
To match different text color levels, icon provides a `depth` property.
```vue
```
### Icon with background
Sometimes it looks better with a background.
```vue
```
## API
### Icon Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| color | `string` | `undefined` | Icon color. | |
| depth | `1 \| 2 \| 3 \| 4 \| 5` | `undefined` | Icon depth. | |
| size | `number \| string` | `undefined` | Icon size (when the unit is not specified the default unit is `px`). | |
| component | `Component` | `undefined` | Icon component to display. | 2.24.6 |
### IconWrapper Props
| Name | Type | Default | Description | Version |
| ------------- | -------- | ----------- | -------------- | ------- |
| border-radius | `number` | `6` | Border radius. | 2.25.0 |
| color | `string` | `undefined` | Color. | 2.25.0 |
| icon-color | `string` | `undefined` | Icon color. | 2.25.0 |
| size | `number` | `24` | Size. | 2.25.0 |
### Icon Slots
| Name | Parameters | Description |
| ------- | ---------- | ------------------------ |
| default | `()` | The content of the icon. |
---
# PageHeader
I hope this component has all the slots you need!
## Demos
### Basic
```vue
Anyway.FM
PodcastBest CollectionUltimate Best CollectionAnyway.FMRefresh
···
As of April 3, 2021
```
## API
### PageHeader Props
| Name | Type | Default | Description |
| --- | --- | --- | --- |
| extra | `string` | `undefined` | Extra text information. Is overwritten by the `extra` slot so only use one. |
| subtitle | `string` | `undefined` | Subtitle. |
| title | `string` | `undefined` | Title. |
| on-back | `() => void` | `undefined` | Callback for when the back button is pressed. |
### PageHeader Slots
| Name | Parameters | Description | Version |
| -------- | ---------- | --------------------- | ------- |
| avatar | `()` | Image information. | |
| header | `()` | Header information. | |
| default | `()` | Content. | |
| extra | `()` | Extra information. | |
| footer | `()` | Footer information. | |
| subtitle | `()` | Subtitle information. | |
| title | `()` | Title information. | |
| back | `()` | Back icon. | 2.24.2 |
---
# Tag
Tags are great for showing attributes; and sometimes toggle options.
## Demos
### Type
It has some types.
```vue
Real Love
Yes It Is
I'm Down
Yesterday
I'm Looking Through You
```
### Borderless
```vue
Real Love
Yes It Is
I'm Down
Yesterday
I'm Looking Through You
```
### Closable
```vue
Real Love
Yes It Is
I'm Down
Yesterday
I'm Looking Through You
```
### Disabled
```vue
Real Love
Yes It Is
I'm Down
Yesterday
I'm Looking Through You
```
### Size
```vue
Real Love
Yes It Is
I'm Down
Yesterday
```
### Checkable
It can be checkable.
```vue
Real Love
Yes It Is
I'm Down
Yesterday
I'm Looking Through You
```
### Shape
Round tag looks like a capsule.
```vue
Real Love
Yes It Is
I'm Down
```
### Color
Use a color object to customize color.
```vue
Farewell to the night, waiting for dawn
```
### Avatar
Put avatar in tag.
```vue
Anyway.FM
Anyway.FM
```
### Icon
Use icon in tag.
```vue
Checked
Checked
```
## API
### Tag Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| bordered | `boolean` | `true` | Whether the tag has border. | |
| checkable | `boolean` | `false` | Whether the tag is checkable. Note: this nullifies the type property. | |
| checked | `boolean` | `false` | Whether the tag is checked. Note: used with `checkable`. | |
| closable | `boolean` | `false` | Whether the tag shows a close button. | |
| color | `{ color?: string, borderColor?: string, textColor?: string }` | `undefined` | Color of the tag. Note: this will override the type property's color. | |
| disabled | `boolean` | `false` | Whether the tag is disabled. | |
| round | `boolean` | `false` | Whether the tag has rounded corners. | |
| size | `'tiny' \| 'small' \| 'medium' \| 'large'` | `'medium'` | Size of the tag. | |
| strong | `boolean` | `false` | Whether to use strong text | 2.30.0 |
| trigger-click-on-close | `boolean` | `false` | Whether the tag triggers click on close. | 2.32.2 |
| type | `'default' \| 'primary' \| 'info' \| 'success' \| 'warning' \| 'error'` | `'default'` | Type of the tag. | |
| on-close | `(e: MouseEvent) => void` | `undefined` | Close clicked callback. | |
| on-update:checked | `(value: boolean) => void` | `undefined` | Checked status change callback. | |
### Tag Slots
| Name | Parameters | Description | Version |
| ------- | ---------- | -------------- | ------- |
| avatar | `()` | Tag'a avatar. | |
| default | `()` | Tag's content. | |
| icon | `()` | Tag'a icon. | 2.30.0 |
---
# Typography
Naive UI provides some HTML text styling.
Typography is an art.
## Demos
### Header
Make your headers pop with a little bar to the left. Much less boring.
```vue
sin(x)
sin(x)
sin(x)
sin(x)
sin(x)
sin(x)
sin(x)
cos(x)
cos(x)
cos(x)
-sin(x)
-sin(x)
-sin(x)
-cos(x)
-cos(x)
-cos(x)
sin(x)
sin(x)
sin(x)
What a loop!
What a loop!
What a loop!
```
### Tags
Other naive-ui built-in tags.
```vue
Hear the Wind Sing
h1 tag
Hear the Wind Sing (風の歌を聴け Kaze no uta o kike) is the first novel by
Japanese writer Haruki Murakami. It first appeared in the June 1979 issue of
Gunzo (one of the most influential literary magazines in Japan), and in book
form the next month. The novel was adapted by Japanese director Kazuki Ōmori
in a 1981 film distributed by Art Theatre Guild. An English translation by
Alfred Birnbaum appeared in 1987.
h2 tag
Hear the Wind Sing (風の歌を聴け Kaze no uta o kike) is the first novel by
Japanese writer Haruki Murakami. It first appeared in the June 1979 issue of
Gunzo (one of the most influential literary magazines in Japan), and in book
form the next month. The novel was adapted by Japanese director Kazuki Ōmori
in a 1981 film distributed by Art Theatre Guild. An English translation by
Alfred Birnbaum appeared in 1987.
h3 tag
Hear the Wind Sing (風の歌を聴け Kaze no uta o kike) is the first novel by
Japanese writer Haruki Murakami. It first appeared in the June 1979 issue of
Gunzo (one of the most influential literary magazines in Japan), and in book
form the next month. The novel was adapted by Japanese director Kazuki Ōmori
in a 1981 film distributed by Art Theatre Guild. An English translation by
Alfred Birnbaum appeared in 1987.
h4 tag
Hear the Wind Sing (風の歌を聴け Kaze no uta o kike) is the first novel by
Japanese writer Haruki Murakami. It first appeared in the June 1979 issue of
Gunzo (one of the most influential literary magazines in Japan), and in book
form the next month. The novel was adapted by Japanese director Kazuki Ōmori
in a 1981 film distributed by Art Theatre Guild. An English translation by
Alfred Birnbaum appeared in 1987.
h5 tag
Hear the Wind Sing (風の歌を聴け Kaze no uta o kike) is the first novel by
Japanese writer Haruki Murakami. It first appeared in the June 1979 issue of
Gunzo (one of the most influential literary magazines in Japan), and in book
form the next month. The novel was adapted by Japanese director Kazuki Ōmori
in a 1981 film distributed by Art Theatre Guild. An English translation by
Alfred Birnbaum appeared in 1987.
h6 tag
Hear the Wind Sing (風の歌を聴け Kaze no uta o kike) is the first novel by
Japanese writer Haruki Murakami. It first appeared in the June 1979 issue of
Gunzo (one of the most influential literary magazines in Japan), and in book
form the next month. The novel was adapted by Japanese director Kazuki Ōmori
in a 1981 film distributed by Art Theatre Guild. An English translation by
Alfred Birnbaum appeared in 1987.
li tagli tagli tagli tagli tagli tagli tagli tagli tagli tagli tagli tag
Hear the Wind Sing (風の歌を聴け Kaze no uta o kike) is the first novel by
Japanese writer Haruki Murakami. It first appeared in the June 1979 issue of
Gunzo (one of the most influential literary magazines in Japan), and in book
form the next month. The novel was adapted by Japanese director Kazuki Ōmori
in a 1981 film distributed by Art Theatre Guild. An English translation by
Alfred Birnbaum appeared in 1987.
Hear the Wind Sing (風の歌を聴け Kaze no uta o kike) is the first novel by
Japanese writer Haruki Murakami. It first appeared in the June 1979 issue of
Gunzo (one of the most influential literary magazines in Japan), and in book
form the next month. The novel was adapted by Japanese director Kazuki Ōmori
in a 1981 film distributed by Art Theatre Guild. An English translation by
Alfred Birnbaum appeared in 1987.
```
### Text
Use different `types` to add some variety to your styles.
```vue
Info
Success
Warning
Error
Strong
Italic
Underline
Delete
Code
Code
Primary Depth
Secondary Depth
Tertiary Depth
As Div
```
### Use n-a with router link
You can use `` for links and routes.
If you think the following method is a little verbose for routes, you can always make it a new component.
```vue
Back Home
```
## API
### Text Props
| Name | Type | Default | Description |
| --- | --- | --- | --- |
| type | `'default' \| 'success' \| 'info' \| 'warning' \| 'error'` | `'default'` | Typography type. |
| strong | `boolean` | `false` | Strong. |
| italic | `boolean` | `false` | Italic. |
| underline | `boolean` | `false` | Underline. |
| delete | `boolean` | `false` | Use the `del` tag and strikethrough style. |
| code | `boolean` | `false` | Use the `code` tag and style. |
| depth | `1 \| 2 \| 3 \| '1' \| '2' \| '3'` | `undefined` | Text depth (shade of text). |
| tag | `string` | `undefined` | Tag to use. `code` or `delete` properties will override this. |
### P Props
| Name | Type | Default | Description |
| --- | --- | --- | --- |
| depth | `1 \| 2 \| 3 \| '1' \| '2' \| '3'` | `undefined` | Text depth (shade of text). |
### H1, H2, H3, H4, H5, H6 Props
| Name | Type | Default | Description |
| --- | --- | --- | --- |
| align-text | `boolean` | `false` | Text alignment. |
| type | `'default' \| 'success' \| 'info' \| 'warning' \| 'error'` | `'default'` | Text color style. |
| prefix | `'bar'` | `undefined` | Show a bar in front of the heading. |
### Ul, Ol Props
| Name | Type | Default | Description |
| ---------- | --------- | ------- | --------------- |
| align-text | `boolean` | `false` | Text alignment. |
### Blockquote Props
| Name | Type | Default | Description |
| ---------- | --------- | ------- | --------------- |
| align-text | `boolean` | `false` | Text alignment. |
### All Typography Components Slots
| Name | Parameters | Description |
| ------- | ---------- | -------------------------- |
| default | `()` | The content of typography. |
---
# Watermark
Watermark.
## Demos
### Basic
```vue
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
```
### Fullscreen
You can make it displayed in fullscreen mode.
```vue
```
### Image
Put image here.
Please note about cross origin setting of the image URL. It will influence whether the image can be displayed.
```vue
```
### Multiline Text
Supports multiple lines text separated by `\n` since `2.38.2`.
Watermark supports displaying multiline text content.
```vue
Review
Empower
Collaborate
...
Connect
Align
Enable
Establish
...
Fulfill
...
...
...
...
...
```
### Custom Watermark
Preview watermark effects by configuring custom parameters.
```vue
The underlying logic is to break through information barriers and
create a new industry ecosystem. The top-level design focuses on user
perception tracks, reaching a tipping point through differentiation
and granularity. Delivering value is to achieve lasting benefits by
reusing major developments in vertical fields.
Review
Empower
Collaborate
...
Connect
Align
Breakthrough
Establish
...
Fulfill
...
...
...
...
...
```
## API
### Watermark Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| content | `string` | `undefined` | Content of watermark. | 2.25.3, supports multiple line text since 2.38.2 |
| cross | `boolean` | `false` | Whether to show watermark at cross position. | 2.25.3 |
| debug | `boolean` | `false` | Whether to show debug grid. | 2.25.3 |
| font-size | `number` | `14` | Font size. | 2.25.3 |
| font-family | `string` | `undefined` | Font family. | 2.25.3 |
| font-style | ``'normal' \| 'italic' \| `oblique ${number}deg` `` | `normal` | Font style. | 2.25.3 |
| font-variant | `string` | `''` | Font variant. | 2.25.3 |
| font-weight | `number` | `400` | Font weight. | 2.25.3 |
| font-color | `string` | `rgba(128, 128, 128, .3)` | Font color. | 2.25.3 |
| fullscreen | `boolean` | `false` | Whether to show fullscreen watermark. | 2.25.3 |
| global-rotate | `number` | `0` | Global rotate degree of the watermark. | 2.32.0 |
| line-height | `number` | `14` | Line height. | 2.25.3 |
| height | `number` | `32` | Height of watermark area. | 2.25.3 |
| image | `string` | `undefined` | The URI of watermark image. | 2.25.3 |
| image-height | `number` | `undefined` | Image height. | 2.25.3 |
| image-opacity | `number` | `1` | Image opacity. | 2.25.3 |
| image-width | `number` | `undefined` | Image width. | 2.25.3 |
| rotate | `number` | `0` | Rotate degree | 2.25.3 |
| selectable | `boolean` | `true` | Whether content covered by watermark is selectable. | 2.25.3 |
| text-align | `'left' \| 'center' \| 'right'` | `'left'` | Text align method when there's multiple lines of text. | 2.38.2 |
| width | `number` | `32` | Width of watermark area. | 2.25.3 |
| x-gap | `number` | `0` | Horizontal gap. | 2.25.3 |
| x-offset | `number` | `0` | Horizontal offset. | 2.25.3 |
| y-gap | `number` | `0` | Vertical gap. | 2.25.3 |
| y-offset | `number` | `0` | Vertical offset. | 2.25.3 |
| z-index | `number` | `10` | Z index of watermark. | 2.25.3 |
### Watermark Slots
| Name | Parameters | Description | Version |
| ------- | ---------- | ------------------------ | ------- |
| default | `()` | something with watermark | 2.25.3 |
---
# Float Button
Like `BackTop` but with more appearance level, more interaction.
Available since `2.38.0`.
## Demos
### Basic
```vue
```
### Badge
You can put a hover button with the number of badges on any element.
```vue
```
### Tooltip
```vue
Lpsum
```
### Description
Show description on float button.
```vue
Docs
Docs
Long Long Docs
```
### Float Button Group
Elements can be arbitrarily combined to achieve more functionality.
```vue
```
### Show menu
After `menu-trigger` is set, more `n-float-button` can be folded into one `n-float-button`.
```vue
```
## API
### FloatButton Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| bottom | `number \| string` | `40` | CSS `bottom` property of the button group. | 2.38.0 |
| height | `number \| string` | `40` | CSS `height` property of the button group. | 2.38.0 |
| left | `number \| string` | `undefined` | CSS `left` property of the button group. | 2.38.0 |
| menu-trigger | `'click' \| 'hover'` | `undefined` | Trigger action to show submenu. | 2.38.0 |
| position | `'relative' \| 'absolute' \| 'fixed'` | `'fixed'` | CSS `position` property of the button group. | 2.38.0 |
| right | `number \| string` | `undefined` | CSS `right` property of the button group. | 2.38.0 |
| shape | `'circle' \| 'square'` | `'circle'` | Shape of the button. | 2.38.0 |
| show-menu | `boolean` | `undefined` | Whether submenu of the button is shown. | 2.38.0 |
| top | `number \| string` | `undefined` | CSS `top` property of the button group. | 2.38.0 |
| type | `'default' \| 'primary'` | `'default'` | Type of the button. | 2.38.0 |
| width | `number \| string` | `undefined` | | 2.38.0 |
| on-update:show-menu | `(value: boolean) => void` | `undefined` | Callback when the menu is opened or closed. | 2.38.0 |
### FloatButtonGroup Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| bottom | `number \| string` | `undefined` | CSS `bottom` property of the button group. | 2.38.0 |
| left | `number \| string` | `undefined` | CSS `left` property of the button group. | 2.38.0 |
| position | `'relative' \| 'absolute' \| 'fixed'` | `'fixed'` | CSS `position` property of the button group. | 2.38.0 |
| right | `number \| string` | `undefined` | CSS `right` property of the button group. | 2.38.0 |
| shape | `'circle' \| 'square'` | `'circle'` | Shape of the button group. | 2.38.0 |
| top | `number \| string` | `undefined` | CSS `top` property of the button group. | 2.38.0 |
### FloatButton Slots
| Name | Parameters | Description | Version |
| ----------- | ---------- | ---------------------------- | ------- |
| description | `()` | Description for the button. | 2.38.0 |
| menu | `()` | Submenu of the float button. | 2.38.0 |
---
# AutoComplete
Offer a search hint or maybe guess some likely options?
## Demos
### Basic
Start typing to see how this works.
```vue
```
### Size
```vue
```
### Group
```vue
```
### Customize input element
You can also replace the input element of the auto-complete component (e.g. using a textarea).
```vue
```
### Actions after select
Choose whether the element blurs after a selection is made with `blur-after-select`.
```vue
```
### Whether to show menu
Your can determine is whether to show menu based on value when it is focused.
```vue
```
### Customized rendering
Use `render-label` to customize label rendering.
```vue
```
### Validation status
Validation status can be applied outside form.
```vue
```
### Append
Append the selected option to the input box instead of directly overwriting it, and use it in conjunction with get-show.
```vue
```
## API
### AutoComplete Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| append | `boolean` | `false` | Whether to append content to input. | 2.38.0 |
| blur-after-select | `boolean` | `false` | Whether to blur after selection. | |
| clear-after-select | `boolean` | `false` | Whether to clear after selection. | |
| clearable | `boolean` | `false` | Whether autocomplete is clearable. | |
| default-value | `string` | `null` | Default value of autocomplete. | |
| disabled | `boolean` | `false` | Whether the autocomplete is disabled. | |
| get-show | `(value: string) => boolean` | `undefined` | Use the input to determine whether to show options on focus. | |
| input-props | `InputHTMLAttributes` | `undefined` | The attributes of input element in autocomplete. | |
| loading | `boolean` | `false` | Whether to show a loading status. | |
| menu-props | `HTMLAttributes` | `undefined` | The menu's dom props. | 2.32.2 |
| options | `Array` | `[]` | Options to autocomplete from. | |
| placeholder | `string` | `'Please Input'` | Autocomplete's placeholder. | |
| placement | `'top-start' \| 'top' \| 'top-end' \| 'right-start' \| 'right' \| 'right-end' \| 'bottom-start' \| 'bottom' \| 'bottom-end' \| 'left-start' \| 'left' \| 'left-end'` | `'bottom-start'` | Autocomplete's placement. | 2.25.0 |
| render-label | `(option: SelectOption \| SelectGroupOption, selected: boolean) => VNodeChild` | `undefined` | Render function for each option label. | 2.24.0 |
| render-option | `(info: { node: VNode, option: SelectOption \| SelectGroupOption, selected: boolean }) => VNodeChild` | `undefined` | Render function for each option. | 2.24.0 |
| scrollbar-props | `ScrollbarProps` | `undefined` | See [Scrollbar props](https://www.naiveui.com/en-US/components/scrollbar.md#Scrollbar-Props) | 2.44.0 |
| show-empty | `boolean` | `false` | Whether to show menu if there's no option. | 2.37.1 |
| size | `'small' \| 'medium' \| 'large'` | `'medium'` | Autocomplete size. | |
| status | `'success' \| 'warning' \| 'error'` | `undefined` | Validation status. | 2.27.0 |
| to | `string \| HTMLElement \| false` | `body` | Container node of the menu. `false` will keep it not detached. | |
| value | `string` | `undefined` | Input of autocomplete. | |
| on-blur | `(event: FocusEvent) => void` | `undefined` | On blur callback function. | |
| on-focus | `(event: FocusEvent) => void` | `undefined` | On focus callback function. | |
| on-select | `(value: string) => void` | `undefined` | On select callback function. | |
| on-update:value | `(value: string \| null) => void` | `undefined` | On update callback function. | |
#### AutoCompleteOption Properties
| Name | Type | Description |
| -------- | --------- | ------------------------------- |
| disabled | `boolean` | Whether the option is disabled. |
| label | `string` | Option label value. |
| value | `string` | Option ID (should be unique). |
#### AutoCompleteGroupOption Properties
| Name | Type | Description |
| -------- | ------------------------------------- | ----------------------- |
| children | `Array` | Group children options. |
| label | `string` | Group label. |
| key | `string \| number` | Unique group key. |
| type | `'group'` | Required group type. |
### AutoComplete Slots
| Name | Parameters | Description | Version |
| --- | --- | --- | --- |
| default | `(options: { handleInput: (value: string) => void, handleFocus: function, handleBlur: function, value: string, theme: string \| null })` | Custom input elements, supplied by the user. | |
| empty | `()` | Menu's content to show when there's no option. | 2.37.1 |
| prefix | `()` | Input's prefix content. | |
| suffix | `()` | Input's suffix content. | |
### AutoComplete Methods
| Name | Type | Description | Version |
| ----- | ------------ | ------------------------ | ------- |
| blur | `() => void` | Blur the input element. | 2.26.2 |
| focus | `() => void` | Focus the input element. | 2.26.2 |
---
# Cascader
Cascader can be used to display and select tree structured data.
## Demos
### Single
```vue
Child Check Strategy
Show PathHover TriggerFilterable
```
### Multiple
```vue
Child Check Strategy
CascadeShow PathHover TriggerFilterableResponsive MaxTagCount
clearFilterAfterSelect
```
### Size
Cascader has `small`, `medium` and `large` sizes.
```vue
```
### Single (async)
```vue
Child Check Strategy
Show Path
```
### Multiple (async)
```vue
All
Parent
Child
CascadeShow PathAllow Checking Not
Loaded
```
### Slots
Is there anybody who needs slots on a cascader menu?
```vue
Standing on a bridge that can divide the world
```
### Large data
In this example there are 5000 \* 2 \* 2 = 20000 entries.
```vue
Child Check Strategy
CascadeShow PathHover TriggerFilterable
```
### Setting check strategy
Set the way to show checked options. `all` means showing all checked nodes. `parent` means showing all checked parent nodes when all child node are checked. `child` means showing all child nodes.
```vue
All
Parent
Child
```
### Customizing Fields
Various data would come from backend.
```vue
```
### Customized rendering
The `render-label` can be used to batch render cascader menu options.
```vue
```
### Focus & blur manually
```vue
Focus then blur in 1 second
```
### Validation status
Validation status can be applied outside form.
```vue
```
## API
### Cascader Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| allow-checking-not-loaded | `boolean` | `false` | Whether to allow cascade checking on not loaded nodes. If you want to use this, you should know the `value` may be incomplete. Also, you should aware about the consistency bewteen naive's checking logic and your backend's checking logic, especially when there are disabled nodes. | 2.28.1 |
| cascade | `boolean` | `true` | Whether to cascade the checkbox selection onto children. | |
| check-strategy | `string` | `'all'` | The way to show checked options. `all` means showing all checked node. `parent` means showing all checked parent node when all child node are checked (not working in single select mode). `child` means showing all child node. | |
| children-field | `string` | `'children'` | The children field in `CascaderOption`. | |
| clearable | `boolean` | `false` | Whether the cascader is clearable. | |
| clear-filter-after-select | `boolean` | `true` | When multiple and filter is true, whether to clear filter keyword after select an option. | 2.25.3 |
| default-value | `string \| number \| Array \| null` | `null` | Data selected by default if no value is set. | |
| disabled | `boolean` | `false` | Whether to disable the cascader. | |
| disabled-field | `string` | `'disabled'` | The disabled field in `CascaderOption`. | 2.32.2 |
| ellipsis-tag-popover-props | `PopoverProps` | `undefined` | `popover` props of the preview ellipsis tag. | 2.37.0 |
| expand-trigger | `'click' \| 'hover'` | `'click'` | If `remote` is set, `'hover'` won't work. | |
| filterable | `boolean` | `false` | Note: If `remote` is set, this won't have any effect. | |
| filter | `(pattern: string, option: CascaderOption, path: CascaderOption[]) => boolean` | A string based filter algorithm. | Filter function of the cascader. | |
| filter-menu-props | `HTMLAttributes` | `undefined` | The filter menu's dom props. | 2.27.0 |
| get-column-style | `(detail: { level: number }) => string \| object` | `undefined` | Function that resolves column style. `level` starts from `0`. | 2.38.2 |
| value-field | `string` | `'value'` | The value field in `CascaderOption`. | |
| label-field | `string` | `'label'` | The label field in `CascaderOption`. | |
| max-tag-count | `number \| 'responsive'` | `undefined` | Max tag count in multiple select mode. `responsive` will keep all the tags in single line. | |
| menu-props | `HTMLAttributes` | `undefined` | The menu's dom props. | 2.27.0 |
| multiple | `boolean` | `false` | Whether to allow multiple options being selected. | |
| options | `CascaderOption[]` | `[]` | Options of the cascader. | |
| placeholder | `string` | `'Please Select'` | Placeholder text. | |
| placement | `'top-start' \| 'top' \| 'top-end' \| 'right-start' \| 'right' \| 'right-end' \| 'bottom-start' \| 'bottom' \| 'bottom-end' \| 'left-start' \| 'left' \| 'left-end'` | `'bottom-start'` | Cascader placement. | 2.25.0 |
| remote | `boolean` | `false` | Whether to obtain data remotely. | |
| render-prefix | `(info: { option: CascaderOption, node: VNode \| null, checked: boolean }) => VNodeChild` | `undefined` | Render function of all the options' prefix. | 2.38.2 |
| render-label | `(option: CascaderOption, checked: boolean) => VNodeChild` | `undefined` | Render function for cascader menu option label. | 2.24.0 |
| render-suffix | `(info: { option: CascaderOption, node: VNode \| null, checked: boolean }) => VNodeChild` | `undefined` | Render function of all the options' suffix. | 2.38.2 |
| scrollbar-props | `ScrollbarProps` | `undefined` | See [Scrollbar props](https://www.naiveui.com/en-US/components/scrollbar.md#Scrollbar-Props) | 2.44.0 |
| separator | `string` | `' / '` | Selected option path value separator (used with `show-path`). | |
| show | `boolean` | `undefined` | Whether to show the menu. | |
| show-path | `boolean` | `true` | Whether to show the selected options as a path. | |
| size | `'small' \| 'medium' \| 'large'` | `'medium'` | Cascader size. | |
| spin-props | `{ strokeWidth?: number, stroke?: string, scale?: number, radius?: number }` | `undefined` | Loading icon properties. | 2.44.0 |
| status | `'success' \| 'warning' \| 'error'` | `undefined` | Validation status. | 2.27.0 |
| to | `string \| HTMLElement \| false` | `body` | Container node of the menu. `false` will keep it not detached. | |
| value | `string \| number \| Array \| null` | `undefined` | Value of the cascader (if being set manually). | |
| virtual-scroll | `boolean` | `true` | Whether to enable virtual scrolling. | |
| on-blur | `() => void` | `undefined` | Callback on blurred. | |
| on-focus | `() => void` | `undefined` | Callback on focused. | |
| on-load | `(option: CascaderOption) => Promise` | `undefined` | Callback when a node is loaded. Set `option.children` in the returned promise. Loading will stop after the promise is resolved or rejected. | |
| on-update:show | `(value: boolean) => void` | `undefined` | Callback executed when menu is opened & closed. | |
| on-update:value | `(value: string \| number \| Array \| null, option: CascaderOption \| Array \| null, pathValues: Array \| Array \| null) => void` | `undefined` | Callback executed when the value changes. | |
#### CascaderOption Properties
| Name | Type | Description | Version |
| --- | --- | --- | --- |
| label | `string` | Label of the option. | |
| value | `string \| number` | Value of the option. | |
| disabled? | `boolean` | Whether this option is disabled. | |
| children? | `CascaderOption` | The children options of this option. | |
### Cascader Slots
| Name | Parameters | Description | Version |
| --- | --- | --- | --- |
| action | `()` | Action content displayed in the cascading menu. | |
| arrow | `()` | Arrow content displayed in the cascading menu. | 2.32.2 |
| empty | `()` | Empty state slot for the options cascading menu. | 2.22.0 |
| not-found | `()` | Data not found slot when searching. | 2.34.0 |
### Cascader Methods
| Name | Type | Description | Version |
| --- | --- | --- | --- |
| blur | `() => void` | Blur. | 2.24.2 |
| focus | `() => void` | Focus. | 2.24.2 |
| getCheckedData | `() => { keys: Array, options: Array }` | Get checked data. | 2.34.0 |
| getIndeterminateData | `() => { keys: Array, options: Array }` | Get indeterminate data. | 2.34.0 |
---
# Color Picker
Unlike the real world, these color values are discrete.
## Demos
### Basic
A basic color picker. Note: when choosing a color in a particular mode, that's the mode that will be used.
```vue
```
### Alpha
Use `show-alpha` to control whether the alpha channel can be adjusted.
```vue
```
### Size
`small`, `medium`, `large`.
```vue
```
### Disabled
```vue
```
### Set mode
Use `modes` to set restrict the available modes.
```vue
```
### Clearable
If you want the color picker to be clearable, you can add `'clear'` in `'actions'` prop.
```vue
```
### Use with form
It seems this example is useless, but it's a data input component so I just left it here.
```vue
```
### Swatches
Set color swatches for users to choose.
```vue
```
### Custom Trigger
Use the `trigger` slot to customize the trigger.
```vue
{{ value }}
```
### Native
We provide a way to trigger the browser's native color selector by clicking on the color preview block, because browser manufacturers have implemented some great features on the native color selector, which you may need.
```vue
```
## API
### ColorPicker Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| default-show | `boolean` | `undefined` | Whether to show the color panel by default. | |
| default-value | `string` | Black color value of 1st mode's corresponding value. | Default value of the picker. | |
| modes | `Array<'rgb' \| 'hex' \| 'hsl' \| 'hsv'>` | `['rgb', 'hex', 'hsl']` | The value format of the picker. Notice that value will follow the mode once you select a new value from the picker. | |
| placement | `'top-start' \| 'top' \| 'top-end' \| 'right-start' \| 'right' \| 'right-end' \| 'bottom-start' \| 'bottom' \| 'bottom-end' \| 'left-start' \| 'left' \| 'left-end'` | `'bottom-start'` | Color panel placement. | 2.25.0 |
| render-label | `(color: string \| null) => VNodeChild` | `undefined` | Label render function of the color picker trigger. | 2.24.0 |
| show | `boolean` | `undefined` | Whether the color panel is shown. | |
| show-alpha | `boolean` | `true` | Whether the alpha channel can be adjusted. | |
| show-preview | `boolean` | `false` | Whether the color preview is shown. | |
| size | `'small' \| 'medium' \| 'large'` | `'medium'` | Size of the picker. | |
| disabled | `boolean` | `false` | Whether to disable the color picker. | 2.24.5 |
| swatches | `string[]` | `undefined` | Value of the swatches. | |
| to | `string \| HTMLElement \| false` | `'body'` | Where to attach the panel to. `false` will keep it not detached. | |
| value | `string \| null` | `undefined` | Value of the picker. | |
| on-complete | `(value: string) => void` | `undefined` | Callback once the value is changed completely (not called during mousemove). | |
| on-confirm | `(value: string) => void` | `undefined` | Callback once the confirm button is clicked. | 2.29.0 |
| on-clear | `() => void` | `undefined` | Callback once the clear button is clicked. | 2.39.0 |
| on-update:show | `(value: boolean) => void` | `undefined` | Callback once panel the show status is changed. | |
| on-update:value | `(value: string) => void` | `undefined` | Callback once the value is changed. | |
| actions | `Array<'confirm' \| 'clear'> \| null` | `null` | The types of buttons to be shown in the panel. | |
### ColorPicker Slots
| Name | Parameters | Description | Version |
| --- | --- | --- | --- |
| action | `()` | Custom action. | 2.24.0 |
| label | `(color: string \| null)` | Label of the color picker trigger. | 2.24.0 |
| trigger | `(props: { value: string \| null , onClick: (() => void) \| undefined, ref: (ref: Element \| ComponentPublicInstance \| null }) => void })` | Custom trigger element. Only one element is allowed & it can't be pure text. | 2.44.0 |
## Q & A
### How to get color value from name?
Naive doesn't provide it builtin. You can create a color map, like [https://github.com/bgrins/TinyColor/blob/master/tinycolor.js#L803](https://github.com/bgrins/TinyColor/blob/master/tinycolor.js#L803).
Or you can create a function like this.
```js
export function getRgb(colorName) {
const el = document.createElement('div')
el.style.color = colorName
document.body.appendChild(el)
const rgbColor = getComputedStyle(el).color
document.body.removeChild(el)
return rgbColor
}
```
---
# Checkbox
Yo, yo, check it out.
## Demos
### Basic
```vue
Checkbox
Checkbox
Disabled
```
### Size
```vue
```
### Checkbox group
```vue
```
### Using Options
Pass option data directly through the `options` prop. You can also customize field names with `label-field` and `value-field`.
```vue
```
### Grid
Use checkboxes with a grid.
```vue
```
### Indeterminate
```vue
Checkbox
checked
Unchecked
Indeterminate
Not indeterminate
```
### Controlled checkbox
```vue
Checkbox
```
### Event
```vue
```
### Customizing checked value
Use `checked-value` and `unchecked-value` to customize value.
```vue
FooBar
```
### Focus & blur manually
```vue
Focus then blur in 1 second
```
## API
### Checkbox Props
| Name | Type | Default | Description |
| --- | --- | --- | --- |
| checked | `boolean` | `false` | Whether the checkbox is being checked manually. |
| checked-value | `string \| boolean \| number` | `true` | Value of checked state. |
| default-checked | `boolean` | `false` | Whether the checkbox is checked by default. |
| disabled | `boolean` | `false` | Whether the checkbox is disabled. |
| focusable | `boolean` | `true` | Whether the checkbox gains focus after being checked. |
| indeterminate | `boolean` | `false` | Whether the checkbox can have a third indeterminate state. |
| label | `string` | `undefined` | Checkbox label. |
| size | `'small' \| 'medium' \| 'large'` | `'medium'` | The size of the checkbox. |
| unchecked-value | `string \| boolean \| number` | `false` | Value of unchecked state. |
| value | `string \| number` | `undefined` | The value of the checkbox to be used in a checkbox group. |
| on-update:checked | `(checked: boolean) => void` | `undefined` | Callback function triggered on a checked status change. |
### CheckboxGroup Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| disabled | `boolean` | `false` | Whether the checkbox group is disabled. | |
| default-value | `Array` | `null` | Checkbox group's default selected value. | |
| label-field | `string` | `'label'` | The field name of option labels in `options`. | 2.45.0 |
| max | `number` | `undefined` | The maximum number of checkboxes that can be checked. | |
| min | `number` | `undefined` | The minimum number of checkboxes that can be checked. | |
| options | `Array<{ label?: string, value: string \| number, disabled?: boolean }>` | `undefined` | Options for the checkbox group. When set, the default slot is ignored. | 2.45.0 |
| value | `Array \| null` | `undefined` | Manually set values of a checkbox group. | |
| value-field | `string` | `'value'` | The field name of option values in `options`. | 2.45.0 |
| on-update:value | `(value: (string \| number)[], meta: { actionType: 'check' \| 'uncheck', value: string \| number }) => void` | `undefined` | Callback when the checkbox group's value changes. | `meta` 2.32.0 |
### Checkbox Slots
| Name | Parameters | Description |
| ------- | ---------- | ------------------------ |
| default | `()` | Content of the checkbox. |
### CheckboxGroup Slots
| Name | Parameters | Description |
| ------- | ---------- | ------------------------------ |
| default | `()` | Content of the checkbox group. |
### Checkbox Methods
| Name | Type | Description | Version |
| ----- | ------------ | ----------- | ------- |
| focus | `() => void` | Focus. | 2.24.2 |
| blur | `() => void` | Blur. | 2.24.2 |
---
# Date Picker
People have too many ideas on how to set the time.
## Demos
### Date
```vue
{{ JSON.stringify(timestamp) }}
```
### Date time
```vue
{{ JSON.stringify(timestamp) }}
```
### Formatted value
Honestly I don't like the feature. Since at most of time it's not a best practice to passing time string around. However, real world is complex, I hope it can help you resolve some tricky problems.
```vue
{{ formattedValue }}
```
### Date range
```vue
{{ JSON.stringify(range) }}
```
### Date time range
```vue
{{ JSON.stringify(range) }}
```
### Month
Use `month-format` to format month item inside panel.
```vue
{{ JSON.stringify(timestamp) }}
```
### Month range
```vue
{{ JSON.stringify(timestamp) }}
```
### Year
```vue
{{ JSON.stringify(timestamp) }}
```
### Year range
```vue
{{ JSON.stringify(timestamp) }}
```
### Quarter
```vue
{{ JSON.stringify(timestamp) }}
```
### Quarter range
```vue
{{ JSON.stringify(timestamp) }}
```
### Week
```vue
{{ JSON.stringify(timestamp) }}
```
### Size
Date Picker can be `small`, `medium` or `large` sized.
```vue
```
### Default time
You can set the default time of picked date.
```vue
```
### Disabled
```vue
```
### Disabled specific time
```vue
Disable first half of the month
Disable first half of the month & AM at second half of the month
At least 7 days
At least 7 days
Only allow previous date
```
### Actions
```vue
```
### Shortcuts
You can customize some shorcut buttons.
```vue
```
### Events
```vue
```
### Format
```vue
```
### Extra footer
```vue
extra footer
extra footer
extra footer
extra footer
```
### Update value on close
```vue
```
### Focus & blur manually
```vue
Focus then blur in 1 second
```
### Validation status
Validation status can be applied outside form.
```vue
```
### Icon
```vue
```
### Use panel only
It may be useful sometimes.
```vue
```
### Close panel on select year or month
By using the `fast-year-select` and `fast-month-select` properties, you can implement the closing of the year and month panel after selecting the year or month.
```vue
{{ JSON.stringify(timestamp) }}
```
## API
### General Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| calendar-day-format | `string` | `undefined` | Weekday format inside popup panel. | 2.40.2 |
| calendar-header-year-format | `string` | `undefined` | Year format inside the header of popup panel's calendar. | 2.40.2 |
| calendar-header-month-format | `string` | `undefined` | Month format inside the header of popup panel's calendar. | 2.40.2 |
| calendar-header-month-before-year | `string` | `undefined` | Whether to show month before year inside the header of popup panel's calender. | 2.40.2 |
| calendar-header-month-year-separator | `string` | `' '` | Separator between month and year inside the header of popup panel's calendar. | 2.40.2 |
| clearable | `boolean` | `false` | Whether the date picker is clearable. | |
| date-format | `string` | `undefined` | Date input format inside popup panel. | 2.40.2 |
| default-value | `number \| [number, number] \| null` | `undefined` | Date picker's default value. | |
| default-formatted-value | `string \| [string, string] \| null` | `undefined` | Date picker's default formatted value. | 2.24.0 |
| disabled | `boolean` | `false` | Whether the date picker is disabled. | |
| first-day-of-week | `0 \| 1 \| 2 \| 3 \| 4 \| 5 \| 6` | `undefined` | The first day of a week on calendar, 0 means Monday. | |
| input-readonly | `boolean` | `false` | Set the `readonly` attribute of the input (avoids virtual keyboard on touch devices). | |
| month-format | `string` | `'M'` | Format of month item in the panel. See [format](https://date-fns.org/v2.23.0/docs/format). | 2.37.0 |
| panel | `boolean` | `false` | Whether to use date-picker as panel. | 2.29.1 |
| placement | `'top-start' \| 'top' \| 'top-end' \| 'right-start' \| 'right' \| 'right-end' \| 'bottom-start' \| 'bottom' \| 'bottom-end' \| 'left-start' \| 'left' \| 'left-end'` | `'bottom-start'` | Panel's placement. | 2.25.0 |
| quarter-format | `string` | `'Q'Q` | Format of quarter item in the panel. See [format](https://date-fns.org/v2.23.0/docs/format). | 2.37.0 |
| shortcuts | `Record number)> \| Record [number, number])>` | `undefined` | Shortcut button customizations. | |
| show | `boolean` | `undefined` | Whether to show panel. | 2.28.3 |
| size | `'small' \| 'medium' \| 'large'` | `'medium'` | Date picker size. | |
| status | `'success' \| 'warning' \| 'error'` | `undefined` | Validation status. | 2.27.0 |
| time-picker-format | `string \| undefined` | `undefined` | Format of the binding value in time picker inside date picker of type `'datetime'` and `'datetimerange'`. See [format](https://date-fns.org/v2.23.0/docs/format). | 2.38.2 |
| to | `string \| HTMLElement \| false` | `body` | Container node of the panel. `false` will keep it not detached. | |
| type | `'date' \| 'datetime' \| 'daterange' \| 'datetimerange' \| 'month' \| 'monthrange' \| 'year' \| 'yearrange' \| 'quarter' \| 'quarterrange' \| 'week'` | `'date'` | Date picker type. | `'quarter'` v2.22.0, `'monthrange'` 2.28.3 |
| value | `number \| [number, number] \| null` | `undefined` | Value of the date picker when being manually set. | |
| value-format | `string` | Follow `format` prop | Format of the binding value. See [format](https://date-fns.org/v2.23.0/docs/format). | 2.24.0 |
| year-format | `string` | `'y'` | Format of year item in the panel. See [format](https://date-fns.org/v2.23.0/docs/format). | 2.37.0 |
| year-range | `[number, number]` | `[1901, 2100]` | Year range in month picker in panel. | 2.40.0 |
| on-clear | `() => void` | `undefined` | On clear callback. | 2.28.3 |
| on-confirm | `(value: number \| [number, number] \| null, formattedValue: string \| [string, string] \| null) => void` | `undefined` | On confirm callback. | 2.28.3 |
| on-blur | `() => void` | `undefined` | On blur callback. | |
| on-focus | `() => void` | `undefined` | On focus callback. | |
| on-next-month | `() => void` | `undefined` | Callback when click next month button. | 2.37.0 |
| on-next-year | `() => void` | `undefined` | Callback when click next year button. | 2.37.0 |
| on-prev-month | `() => void` | `undefined` | Callback when click previous month button. | 2.37.0 |
| on-prev-year | `() => void` | `undefined` | Callback when click previous year button. | 2.37.0 |
| on-update:show | `(show: boolean) => void` | `undefined` | Callback when panel shows & hides. | 2.28.3 |
### Date Type Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| actions | `Array<'clear' \| 'now'> \| null` | `['clear', 'now']` | Operations supported for the `date` type date picker. | |
| default-calendar-start-time | `number` | `undefined` | Default panel calendar start month timestamp. | 2.38.1 |
| fast-year-select | `boolean` | `false` | Close year and month panel after selecting year. | 2.44.0 |
| fast-month-select | `boolean` | `false` | Close year and month panel after selecting month. | 2.44.0 |
| format | `string` | `'yyyy-MM-dd'` | Format of the input. For detail please see [format](https://date-fns.org/v2.23.0/docs/format). | |
| is-date-disabled | `(current: number, detail: { type: 'date', year: number, month: number, date: number } \| { type: 'month', year: number, month: number } \| { type: 'year', year: number } \| { type: 'quarter', year: number, quarter: number } \| { type: 'input' }) => boolean` | `() => false` | Validator of the date. | `detail` 2.37.1 |
| placeholder | `string` | `'Select Date'` | Placeholder. | |
| on-update:formatted-value | `(value: string \| null, timestampValue: number \| null) => void` | `undefined` | Date selected callback. | 2.24.0 |
| on-update:value | `(value: number \| null, formattedValue: string \| null) => void` | `undefined` | Date selected callback. | `formattedValue` 2.24.0 |
### DateTime Type Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| actions | `Array<'clear' \| 'now' \| 'confirm'> \| null` | `['clear', 'now', 'confirm']` | Operations supported for the `datetime` type date picker. | |
| default-calendar-start-time | `number` | `undefined` | Default panel calendar start month timestamp. | 2.38.1 |
| default-time | `string \| (timestamp: number) => string` | `undefined` | Default time of the selected date. Can accept a function with a timestamp argument that returns a formatted string. It's format is `HH:mm:ss`. | 2.22.0, functional since 2.43.2 |
| fast-year-select | `boolean` | `false` | Close year and month panel after selecting year. | 2.44.0 |
| fast-month-select | `boolean` | `false` | Close year and month panel after selecting month. | 2.44.0 |
| format | `string` | `'yyyy-MM-dd HH:mm:ss'` | Format of the input. For detail please see [format](https://date-fns.org/v2.23.0/docs/format). | |
| is-date-disabled | `(current: number, detail: { type: 'date', year: number, month: number, date: number } \| { type: 'month', year: number, month: number } \| { type: 'year', year: number } \| { type: 'quarter', year: number, quarter: number } \| { type: 'input' }) => boolean` | `() => false` | Validator of the date. | `detail` 2.37.1 |
| is-time-disabled | `(current: number) => { isHourDisabled?: () => boolean, isMinuteDisabled?: () => boolean, isSecondDisabled?: () => boolean }` | `undefined` | Validator of the time. | |
| placeholder | `string` | `'Select Date and Time'` | Placeholder. | |
| time-picker-props | `TimePickerProps` | `undefined` | Time picker props in the panel. | 2.27.0 |
| update-value-on-close | `boolean` | `false` | Whether to update value on close. | |
| on-update:formatted-value | `(value: string \| null, timestampValue: number \| null) => void` | `undefined` | Date selected callback. | MEXT_VERSION |
| on-update:value | `(value: number \| null, formattedValue: string \| null) => void` | `undefined` | Date selected callback. | `formattedValue` 2.24.0 |
### DateRange Type Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| actions | `Array<'clear' \| 'confirm'> \| null` | `['clear', 'confirm']` | Operations supported for the `daterange` type date picker. | |
| bind-calendar-months | `boolean` | `false` | Whether months in panel calendar are consecutive. | 2.28.3 |
| default-calendar-start-time | `number` | `undefined` | Default panel calendar start month timestamp. | 2.28.3 |
| default-calendar-end-time | `number` | `undefined` | Default panel calendar end month timestamp. | 2.28.3 |
| end-placeholder | `string` | `'End Date'` | Placeholder at end part of the input. | |
| fast-year-select | `boolean` | `false` | Close year and month panel after selecting year. | 2.44.0 |
| fast-month-select | `boolean` | `false` | Close year and month panel after selecting month. | 2.44.0 |
| format | `string` | `'yyyy-MM-dd'` | Format of the input. For detail please see [format](https://date-fns.org/v2.23.0/docs/format). | |
| is-date-disabled | `(current: number, phase: 'start' \| 'end', value: [number, number] \| null) => boolean` | `undefined` | Validator of the date. | `detail` 2.37.1 |
| is-time-disabled | `(current: number, phase: 'start' \| 'end', value: [number, number]) => { isHourDisabled?: (hour: number) => boolean, isMinuteDisabled?: (minute: number, hour: number \| null) => boolean, isSecondDisabled?: (second: number, minute: number \| null, hour: number \| null) => boolean }` | `undefined` | Validator of the time. `null` in validators means value of picker is empty. | |
| close-on-select | `boolean` | `false` | Whether to close the panel after the user has selected a time range. | |
| separator | `string` | internal icon | The separator between the start input and the end input. | |
| start-placeholder | `string` | `'Start Date'` | The prompt information at the beginning of the input. | |
| update-value-on-close | `boolean` | `false` | Whether to update the value on close. | |
| on-update:formatted-value | `(value: [string, string] \| null, timestampValue: [number, number] \| null) => void` | `undefined` | Formatted range changed callback. | 2.24.0 |
| on-update:value | `(value: [number, number] \| null, formattedValue: [string, string] \| null) => void` | `undefined` | Range changed callback. | `formattedValue` 2.24.0 |
### DateTimeRange Type Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| actions | `Array<'clear' \| 'confirm'> \| null` | `['clear', 'confirm']` | Operations supported for the `datetimerange` type. | |
| bind-calendar-months | `boolean` | `false` | Whether months in panel calendar are consecutive. | 2.28.3 |
| default-calendar-start-time | `number` | `undefined` | Default panel calendar start month timestamp. | 2.28.3 |
| default-calendar-end-time | `number` | `undefined` | Default panel calendar end month timestamp. | 2.28.3 |
| default-time | `string \| Array \| (timestamp: number, position: "start" \| "end", value: [number, number] \| null) => string` | `undefined` | Default time of the selected date. Can accept a function with timestamp, position and value arguments that returns a formatted string. It's format is `HH:mm:ss`. | 2.22.0, functional since 2.43.2 |
| end-placeholder | `string` | `'End Date and Time'` | Placeholder at end part of the input. | |
| fast-year-select | `boolean` | `false` | Close year and month panel after selecting year. | 2.44.0 |
| fast-month-select | `boolean` | `false` | Close year and month panel after selecting month. | 2.44.0 |
| format | `string` | `'yyyy-MM-dd HH:mm:ss'` | Format of the input. For detail please see [format](https://date-fns.org/v2.23.0/docs/format). | |
| is-date-disabled | `(current: number, phase: 'start' \| 'end', value: [number, number] \| null) => boolean` | `undefined` | Validator of the date. | |
| is-time-disabled | `(current: number, phase: 'start' \| 'end', value: [number, number]) => { isHourDisabled?: (hour: number) => boolean, isMinuteDisabled?: (minute: number, hour: number \| null) => boolean, isSecondDisabled?: (second: number, minute: number \| null, hour: number \| null) => boolean }` | `undefined` | Validator of the time. `null` in validators means value of picker is empty. | |
| separator | `string` | internal icon | The separator between the start input and the end input. | |
| start-placeholder | `string` | `'Start Date and Time'` | The prompt information at the beginning of the input. | |
| time-picker-props | `TimePickerProps \| [TimePickerProps, TimePickerProps]` | `undefined` | Time picker props in the panel. | 2.27.0 |
| update-value-on-close | `boolean` | `false` | Whether to update value on close. | |
| on-update:formatted-value | `(value: [string, string] \| null, timestampValue: [number, number] \| null) => void` | `undefined` | Formatted value changed callback. | 2.24.0 |
| on-update:value | `(value: [number, number] \| null, formattedValue: [string, string] \| null) => void` | `undefined` | Value changed callback. | `formattedValue` 2.24.0 |
### Month Type Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| actions | `Array<'clear' \| 'now' \| 'confirm'> \| null` | `['clear', 'now']` | Operations supported for the `month` type date picker. | |
| format | `string` | `'yyyy-MM'` | Format of the input. For detail please see [format](https://date-fns.org/v2.23.0/docs/format). | |
| is-date-disabled | `(current: number, detail: { type: 'date', year: number, month: number, date: number } \| { type: 'month', year: number, month: number } \| { type: 'year', year: number } \| { type: 'quarter', year: number, quarter: number } \| { type: 'input' }) => boolean` | `() => false` | Validator of the month. | `detail` 2.37.1 |
| placeholder | `string` | `'Select Month'` | Placeholder. | |
| on-update:formatted-value | `(value: string \| null, timestampValue: number \| null) => void` | `undefined` | Formatted value changed callback. | 2.24.0 |
| on-update:value | `(value: number \| null, formattedValue: string \| null) => void` | `undefined` | Value changed callback. | `formattedValue` 2.24.0 |
### MonthRange, QuarterRange, YearRange Type Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| actions | `Array<'clear' \| 'confirm'> \| null` | `['clear', 'confirm']` | Operations supported for the `monthrange` type date picker. | 2.28.3 |
| end-placeholder | `string` | `'End Month'` | Placeholder at end part of the input. | 2.28.3 |
| format | `string` | `'yyyy-MM-dd'` | Format of the input. For detail please see [format](https://date-fns.org/v2.23.0/docs/format). | 2.28.3 |
| close-on-select | `boolean` | `false` | Whether to close the panel after the user has selected a time range. | 2.28.3 |
| separator | `string` | internal icon | The separator between the start input and the end input. | 2.28.3 |
| start-placeholder | `string` | `'Start Month'` | The prompt information at the beginning of the input. | 2.28.3 |
| update-value-on-close | `boolean` | `false` | Whether to update the value on close. | 2.28.3 |
| on-update:formatted-value | `(value: [string, string] \| null, timestampValue: [number, number] \| null) => void` | `undefined` | Formatted range changed callback. | 2.28.3 |
| on-update:value | `(value: [number, number] \| null, formattedValue: [string, string] \| null) => void` | `undefined` | Range changed callback. | 2.28.3 |
### Year Type Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| actions | `Array<'clear' \| 'now'> \| null` | `['clear', 'now']` | Operations supported for the `year` type date picker. | |
| format | `string` | `'yyyy'` | Format of the input. For detail please see [format](https://date-fns.org/v2.23.0/docs/format). | |
| is-date-disabled | `(current: number, detail: { type: 'date', year: number, month: number, date: number } \| { type: 'month', year: number, month: number } \| { type: 'year', year: number } \| { type: 'quarter', year: number, quarter: number } \| { type: 'input' }) => boolean` | `() => false` | Validator of the year. | `detail` 2.37.1 |
| placeholder | `string` | `'Select Year'` | Placeholder. | |
| on-update:formatted-value | `(value: string \| null, timestampValue: number \| null) => void` | `undefined` | Formatted value changed callback. | 2.24.0 |
| on-update:value | `(value: number \| null, formattedValue: string \| null) => void` | `undefined` | Value changed callback. | `formattedValue` 2.24.0 |
### Week Type Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| actions | `Array<'clear' \| 'now'> \| null` | `['clear', 'now']` | Operations supported for the `week` type date picker. | 2.37.0 |
| default-calendar-start-time | `number` | `undefined` | Default panel calendar start month timestamp. | 2.38.1 |
| format | `string` | `'YYYY-w'` for en-US, Locale specific. | Format of the input. For detail please see [format](https://date-fns.org/v2.23.0/docs/format). | 2.37.0 |
| placeholder | `string` | `'Select Week'` for en-US, Locale specific. | Placeholder. | 2.37.0 |
| on-update:formatted-value | `(value: string \| null, timestampValue: number \| null) => void` | `undefined` | Formatted value changed callback. | 2.37.0 |
| on-update:value | `(value: number \| null, formattedValue: string \| null) => void` | `undefined` | Value changed callback. | 2.37.0 |
### DatePicker Slots
| Name | Parameters | Description | Version |
| ---------- | ---------- | --------------------------------- | ------- |
| date-icon | `()` | Date icon of the input box. | 2.29.0 |
| footer | `()` | Extra Footer. | |
| next-month | `()` | Next icon of the date panel. | 2.33.4 |
| next-year | `()` | Fast next icon of the date panel. | 2.33.4 |
| prev-month | `()` | Prev icon of the date panel. | 2.33.4 |
| prev-year | `()` | Fast prev icon of the date panel. | 2.33.4 |
| separator | `()` | Separator of range picker. | 2.29.0 |
### Date, Year, QuarterRange, Week Slots
| 名称 | 参数 | 说明 | 版本 |
| --- | --- | --- | --- |
| clear | `(props: { onClear: () => void, text: string })` | Clear button of the panel. | 2.40.0 |
| now | `(props: { onNow: () => void, text: string })` | Now button of the panel. | 2.40.0 |
### DateRange, DateTimeRange, MonthRange, YearRange Slots
| 名称 | 参数 | 说明 | 版本 |
| --- | --- | --- | --- |
| clear | `(props: { onClear: () => void, text: string })` | Clear button of the panel. | 2.40.0 |
| confirm | `(props: { onConfirm: () => void, disabled: boolean, text: string })` | Confirm button of the panel. | 2.40.0 |
### DateTime, Month, Quarter Slots
| 名称 | 参数 | 说明 | 版本 |
| --- | --- | --- | --- |
| clear | `(props: { onClear: () => void, text: string })` | Clear button of the panel. | 2.40.0 |
| confirm | `(props: { onConfirm: () => void, disabled: boolean, text: string })` | Confirm button of the panel. | 2.40.0 |
| now | `(props: { onNow: () => void, text: string })` | Now button of the panel. | 2.40.0 |
### DatePicker Methods
| Name | Type | Description | Version |
| ----- | ------------ | ----------- | ------- |
| focus | `() => void` | Focus. | 2.24.2 |
| blur | `() => void` | Blur. | 2.24.2 |
---
# Dynamic Input
This component's name has been changed so many times.
In the beginning, it was created for entering environment variables.
If you find the component doesn't look like what you want, I recommend you to write a new one. It's probably easier than using this one.
## Demos
### Use input preset
By default, the preset element of `n-dynamic-input` is `input`.
```vue
{{ JSON.stringify(value, null, 2) }}
```
### Using pair preset
```vue
{{ JSON.stringify(value, null, 2) }}
```
### Customizing input content
```vue
Add whatever you want
{{ JSON.stringify(customValue, null, 2) }}
```
### Using it in a form
`n-dynamic-input` itself cannot be verified. If you need to verify the input of `n-dynamic-input`, you can pass `n-form-item` in the custom content to complete the verification. Here is a complete example.
```vue
```
## API
### DynamicInput Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| create-button-props | `ButtonProps` | `undefined` | Props of create item button. | 2.25.0 |
| default-value | `unknown[]` | `[]` | Default value. | |
| disabled | `boolean` | `false` | Whether to disable the dynamic-input. It won't work for custom content. | 2.34.4 |
| item-class | `string` | `undefined` | The class of each item of the dynamic input. | 2.36.0 |
| item-style | `string \| Object` | `undefined` | The style of each item of the dynamic input. | |
| key-field | `string` | `undefined` | The key of each item that should be used in the rendering of the list. | |
| min | `number` | `0` | Minimum number of items. | |
| max | `number` | `undefined` | Maximum number of items. | |
| preset | `'input' \| 'pair'` | `'input'` | The preset of `n-dynamic-input`, it work when `$slots.default` is not set. | |
| show-sort-button | `boolean` | `false` | Whether to show sort button. | 2.25.0 |
| value | `unknown[]` | `undefined` | Value in controlled mode. | |
| on-create | `(index: number) => void` | `undefined` | Add button (+) click callback. If set, the return value will be used as the initial value of the new item. `index` is the the new item's corresponding index in the value array, which starts from 1 (the second item). | |
| on-remove | `(index: number) => void` | `undefined` | Remove button (-) callback. | |
| on-update:value | `(value: any) => void` | `undefined` | On value changed callback. | |
### DynamicInput Props (Input Preset)
| Name | Type | Default | Description |
| ----------- | --------------- | -------- | ------------------------------ |
| value | `Array` | required | Value when being set manually. |
| placeholder | `string` | `''` | Placeholder for each item. |
### DynamicInput Props (Pair Preset)
| Name | Type | Default | Description |
| --- | --- | --- | --- |
| value | `Array<{ key: string, value: string }>` | required | Value when being set manually. |
| key-placeholder | `string` | `''` | The placeholder of each item's key. |
| value-placeholder | `string` | `''` | The placeholder of each item's value. |
### DynamicInput Slots
| Name | Parameters | Description | Version |
| --- | --- | --- | --- |
| action | `(options: { value: any, index: number, create: (index: number) => void, remove: (index: number) => void, move: (type: 'up' \| 'down', index: number) => void })` | Customizing action; `value` and `index` are the value and index of the current item. | 2.34.4 |
| default | `(options: { value: any, index: number })` | The content of each item; `value` and `index` are the value and index of the current item. | |
| create-button-default | `()` | Content of create button. | 2.25.0 |
| create-button-icon | `()` | Icon of create button. | 2.25.0 |
---
# Dynamic Tags
Turn tags to inputs and back again.
## Demos
### Basic
```vue
```
### Max tag count
```vue
```
### Use in form
```vue
```
### Customizing input or trigger element
You can replace a dynamic-tags input or trigger element with another component.
```vue
New Tag
```
### Custom render for each tag
```vue
```
### Use object formatted value
You can use `@create` to produce `{ label, value }` formatted value. Don't mess it up with `string` typed value.
```vue
```
### Custom tag creation
Use `on-create` to custom tags.
```vue
```
## API
### DynamicTags Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| closable | `boolean` | `true` | Whether the tag is closable. | |
| color | `{ color?: string, borderColor?: string, textColor?: string }` | `undefined` | Color of the tag. Note: it will override the color set by `type`. | |
| default-value | `string[]` | `[]` | Default value. | |
| disabled | `boolean` | `false` | Whether the tag is disabled. | |
| input-props | `InputProps` | `undefined` | Props of internal `n-input`. | 2.25.0 |
| input-class | `string` | `undefined` | Customize the class of the input. | 2.36.0 |
| input-style | `string \| Object` | `undefined` | Customize the style of the input. | |
| max | `number` | `undefined` | Maximum number of tags. | |
| round | `boolean` | `false` | Whether the tag has rounded corners. | |
| render-tag | `((tag: string, index: number) => VNodeChild) \| ((tag: { label: string, value: string }, index: number) => VNodeChild)` | `undefined` | custom render tag. | 2.27.0 |
| size | `'small' \| 'medium' \| 'large'` | `'medium'` | Size of the tag. | |
| tag-class | `string` | `undefined` | Customize the class of the tag. | 2.36.0 |
| tag-style | `string \| Object` | `undefined` | Customize the style of the tag. | |
| type | `'default' \| 'primary' \| 'info' \| 'success' \| 'warning' \| 'error'` | `'default'` | Type of the tag. | |
| value | `string[]` | `undefined` | Value if manually set. | |
| on-create | `((label: string) => string) \| ((label: string) => ({ label: string, value: string }))` | `label => label` | Create derived value from input. | 2.30.4 |
| on-update:value | `((value: string[]) => void) \| ((value: DynamicTagsOption[]) => void)` | `undefined` | Callback when the component's value changes. | |
#### DynamicTagsOption Type
```ts
export interface DynamicTagsOption {
label: string
value: string
}
```
### DynamicTags Slots
| Name | Parameters | Description | Version |
| --- | --- | --- | --- |
| input | `(info: { submit: (value: any) => void, deactivate: () => void })` | Custom element(s) to replace the regular input. | `deactivate` 2.26.2 |
| trigger | `(info: { activate: () => void, disabled: boolean })` | The element or component that triggers the tag to switch to an input. | |
---
# Form
The element to collect and validate data.
> **Caveat**
>
> If you want to apply required rule for a form item with number typed value, you need to set ``type: 'number'`` in the rule object.
## Demos
### Inline form
An example of an inline form.
```vue
Small
Medium
Large
Validate
{{ JSON.stringify(formValue, null, 2) }}
```
### Customizing rules
Sometimes builtin triggers don't meet your needs. You can customize these validations by setting a custom trigger in the rules and manually triggering the validation.
```vue
Validate
{{ JSON.stringify(modelRef, null, 2) }}
```
### Abnormal warning
You may want to display warnings to the user for values that may be abnormal, but do not want the validate method to throw an exception. In this case, `FormItemRule`'s `level` attribute can help you (`level: 'warning'`).
```vue
Submit Answer
```
### Custom validation
If you need to customize the timing and effect of a validation, use `validation-status` and `feedback`. In this case, there's usually no need for providing a `path` for the form item.
```vue
{{ inputNumberFeedback }}
```
### I18n
Form's rule supports `renderMessage`. You can use it to render your message.
```vue
```
### Label placement top
Use `n-grid` and `n-form-item-gi` (grid item) to style the form more exactly.
```vue
Small
Medium
Large
Option 1
Option 2
Option 3
Radio 1
Radio 2
Radio 3
Radio 1
Radio 2
Radio 3
Validate
{{ JSON.stringify(model, null, 2) }}
```
### Label placement left
```vue
Small
Medium
Large
Option 1
Option 2
Option 3
Radio 1
Radio 2
Radio 3
Radio 1
Radio 2
Radio 3
Validate
{{ JSON.stringify(model, null, 2) }}
```
### Use form item alone
You can also use `n-form-item` outside of an `n-form` element.
```vue
```
### Async validation
Supports async when the provided validator returns a `Promise`.
```vue
Validate
{{ JSON.stringify(formValue, null, 2) }}
```
### Disabled form
```vue
Upload file
Checkbox
Option 1
Option 2
Option 3
Definitely Maybe
Radio 1
Radio 2
Radio 3
Radio 1
Radio 2
Radio 3
```
### Show / hide label
If `show-label` will default to `true` if not set and inherit `n-form`'s `show-label`.
```vue
Form:Form Item:
```
### Apply partial validation
During validation, use the second parameter of `form.validate` to select rules, field paths, or both. A path is matched exactly against the `path` of a form item.
```vue
Check first field by rule key
Check second field by path
Check all fields
Restore validation
```
### Custom messages
You can define custom messages that are used instead of the standard ones.
```vue
Validate
{{ JSON.stringify(formValue, null, 2) }}
```
### Dynamic form
Delete or add form items dynamically.
```vue
Remove
Validate
New hobby
```
### Custom feedback style
Using `feedback-style` and `feedback-class` to custom feedback.
```vue
```
## API
### Form Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| disabled | `boolean` | `false` | Whether to disable the form. | |
| inline | `boolean` | `false` | Whether to display as an inline form. | |
| label-width | `number \| string \| 'auto'` | `undefined` | The width of label. Particularly useful when `label-placement` is set to `'left'`,`'auto'` means label width will be auto adjusted. | |
| label-align | `'left' \| 'right'` | `-` | Label text alignment. | |
| label-placement | `'left' \| 'top'` | `'top'` | Label placement. | |
| model | `Object` | `{}` | The object to get/set form item values. | |
| rules | `type FormRules = { [itemValidatePath: string]: FormItemRule \| Array \| FormRules }` | `{}` | The rules to validate form items. | |
| show-feedback | `boolean` | `true` | Whether to show the feedback area. | |
| show-label | `boolean` | `true` | Whether to show the label. | |
| show-require-mark | `boolean` | `-` | Whether to show a required symbol when a form item is required. | |
| require-mark-placement | `'left' \| 'right' \| 'right-hanging'` | `'right'` | Require mark placement | `'right-hanging'` 2.24.0 |
| size | `'small' \| 'medium' \| 'large'` | `'medium'` | Size. | |
| validate-messages | `FormValidateMessages` | `undefined` | Validation messages of `async-validator`. | 2.27.0 |
#### FormItemRule Type
> **Caveat**
>
> The follow table doesn't demostrate all props of rules. If you want to know all the usages, please see [async-validator](https://github.com/yiminghe/async-validator).
| Property | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| asyncValidator | `(rule: FormItemRule, value: any, callback: (error?: Error) => void) => void` | `undefined` | Asynchronous validation in the form of a callback. | |
| key | `string` | `undefined` | Unique key of this rule, which can be used to apply partial rules. See [Apply partial rules](https://www.naiveui.com/en-US/components/form.md#partially-apply-rules.vue) example. | |
| level | `'error'` \| `'warning'` | `undefined` | Validation level. If there are already errors, `'warning'` level validation would be skipped. | |
| message | `string` | `undefined` | Text to show when validation fails. | |
| renderMessage | `() => VNodeChild` | `undefined` | Render function or message. | 2.29.1 |
| required | `boolean` | `undefined` | Is it required. | |
| trigger | `string \| Array` | `undefined` | Trigger type. | |
| validator | `(rule: FormItemRule, value: any) => boolean \| Error` | `undefined` | Validation rule. | |
#### FormValidateMessages Type
> **Caveat**
>
> Please see the default messages defined in [async-validator](https://github.com/yiminghe/async-validator/blob/master/src/messages.ts) in order to see which messages you can override.
### FormItem Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| content-class | `string` | `undefined` | The class name of the content. | 2.43.0 |
| content-style | `string \| object` | `undefined` | The style of the content. | 2.43.0 |
| feedback | `string` | `undefined` | The feedback message of the form item. If set, it will replace any result of rule-based validation. | |
| feedback-class | `string` | `undefined` | Feedback check vertical display positioning | 2.38.2 |
| feedback-style | `string \| object` | `undefined` | Feedback check horizontal display positioning | 2.38.2 |
| first | `boolean` | `false` | Whether to only show the first validation error message. | |
| ignore-path-change | `boolean` | `false` | Usually, changing `path` will cause a re-render and naive-ui will clear the validation result. Setting `ignore-path-change` to `true` will disable that behavior. | |
| label | `string` | `undefined` | Label. | |
| label-align | `'left' \| 'right'` | `undefined` | Text alignment inside the label. If not set, it will inherit the parent form's `label-align`. | |
| label-placement | `'left' \| 'top'` | `undefined` | If not set, it will inherit the parent form's `label-placement`. | |
| label-props | `LabelHTMLAttributes` | `undefined` | HTML attributes of the label element inside form item. | 2.24.0 |
| label-style | `CSSProperties \| string` | `undefined` | Label style. | |
| label-width | `number \| string \| 'auto'` | `undefined` | If not set, it will inherit the parent form's `label-width`,`'auto'` means label width will be auto adjusted. | |
| path | `string` | `undefined` | The path to use in the parent form's model object. | |
| required | `boolean` | `false` | Whether to show the "required" symbol. Note: a required rule has higher priority than this prop & this prop **won't** have any effect on validation. Validation still depends on rules. | |
| rule | `FormItemRule \| Array` | `undefined` | The rule to validate this form item. It will be merged with the rules acquired by `rule-path` from the parent form's rules. It's recommended to set all rules on the parent form. | |
| rule-path | `string` | `undefined` | The path to get rules from the parent form's rule object. If not set, it will use the path of the parent form item instead. | |
| show-feedback | `boolean` | `true` | Whether to show the feedback area. | |
| show-label | `boolean` | `true` | Whether to show a label. If not set, it will inherit `show-label` from the parent form. | |
| show-require-mark | `boolean` | `-` | Whether to show required symbol. If not set, it will use `show-require-mark` from the parent form. |
| require-mark-placement | `'left' \| 'right' \| 'right-hanging'` | `'right'` | Require mark placement. If not set, it will use `require-mark-placement` from the parent form. | `'right-hanging'` 2.24.0 |
| size | `'small' \| 'medium' \| 'large'` | `'medium'` | Size. | |
| validation-status | `'error' \| 'success' \| 'warning'` | `undefined` | The validation status of the form item. If set, it will replace the result of the rule-based validation. | |
### FormItemGi Props
Accept all props from FormItem & [GridItem](https://www.naiveui.com/en-US/components/grid.md#GridItem-Props)
### Form Methods
> **Caveat on Validate Method**
>
> By default, validation will use all rules regardless of the triggers of the rules.
| Name | Type | Description | Version |
| --- | --- | --- | --- |
| validate | `(validateCallback?: (errors: Array \| undefined, extra: { warnings: Array \| undefined }) => void, filter?: ((rule: FormItemRule) => boolean) \| Array \| { paths: Array, shouldRuleBeApplied: (rule: FormItemRule) => boolean }) => Promise<{ warnings: Array \| undefined }>` | Validate the form. Pass field paths to validate matching form items, or pass an object to filter both form items and rules. Paths match form item `path` values exactly. The rejection value type of returned promise is `Array`. | `warnings` `2.37.1`, path filter `2.45.0` |
| restoreValidation | `() => void` | Restore validate. | |
| invalidateLabelWidth | `() => void` | Recalculate label widths of all form items. Useful when using `label-width="auto"` and the label content changes dynamically. | NEXT_VESION |
### FormItem, FormItemGi Methods
| Name | Type | Description | Version |
| --- | --- | --- | --- |
| validate | `(options: { trigger?: string, callback?: (errors: FormValidationError \| undefined, extra: { warnings: FormValidationError \| undefined }) => void, shouldRuleBeApplied?: FormItemRule => boolean, options?: AsyncValidatorOptions }) => Promise<{ warnings: FormValidationError \| undefined }>` | Validate the form item. The rejection value type of returned promise is `FormValidationError`. If trigger is not set, all rules of the item will be applied. `shouldRuleBeApplied` can filter rules after they are filtered by the trigger. | `warnings` `2.37.1` |
| restoreValidation | `() => void` | Restore validate. | |
| invalidateLabelWidth | `() => void` | Recalculate the label width of this form item. Useful when using `label-width="auto"` and the label content changes dynamically. | NEXT_VESION |
To find out more about AsyncValidatorOptions, see [async-validator](https://github.com/yiminghe/async-validator).
### Form Slots
| Name | Parameters | Description |
| ------- | ---------- | ----------- |
| default | `()` | Content. |
### FormItem, FormItemGi Slots
| Name | Parameters | Description | Version |
| -------- | ---------- | -------------- | ------- |
| default | `()` | Content. |
| feedback | `()` | Feedback. | 2.24.0 |
| label | `()` | Label content. | |
---
# Input
Many years ago, inputs were just punched cards.
## Demos
### Basic
Basic use of `n-input`.
```vue
```
### Size
```vue
```
### Round corner
Inputs can have rounded corners.
```vue
```
### Prefix & suffix
Set a prefix and/or suffix for the input.
```vue
$
```
### Loading
`input` has a loading state.
Note: When using `clearable`, `suffix` and `loading` at the same time, and `loading` is `false`, there will be a space between the clear button and the suffix, if you want to remove the whitespace, `loading` should be set to `undefined` when stopping loading.
```vue
```
### Password
```vue
```
### Disabled
Inputs can also be disabled.
```vue
```
### Clearable
Make the input clearable after a value is set.
```vue
```
### Autosize
Autosize the input.
```vue
```
### Pairwise value
```vue
```
### Input group
```vue
https://www..com
Search
Search
```
### Passively activated
If you want to activate the input by pressing enter after it's focused, use `passively-activated`. Use Tab to focus on the next input(s).
```vue
```
### Word limit
Don't waste words.
```vue
{{ value.includes('Yes') ? '99+' : value.length }}
{{ value.includes('What?') ? '99+' : value.length }}
```
### Imperative handle
Clear. Focus. Blur. Selection. Scroll.
```vue
Clear
Focus
Blur
Select
ScrollToEnd
```
### Events
```vue
```
### Input props
Input element has some special attributes, such as `auto-complete` or `type`. You can use `input-props` to set it.
```vue
```
### Validation status
Validation status can be applied outside form.
```vue
```
### Limit input format
Use `allow-input` to limit input value to desired format. You can use it to achieve trim effect.
```vue
```
### Count graphemes
Browser's default `maxlength` and `minlength` and naive-ui's builtin character count method can't split all string correctly. You can use `count-graphemes` count to count graphemes correctly.
```vue
```
## API
### Input Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| allow-input | `(value: string) => boolean` | `undefined` | Check the incoming value, if it returns `false`, input will not be accepted. | 2.30.4 |
| autofocus | `boolean` | `false` | Whether to autofocus. | |
| autosize | `boolean \| { minRows?: number, maxRows?: number }` | `false` | Sizing property for when the input is of type `textarea`. e.g. `{ minRows: 1, maxRows: 3 }`. | |
| clearable | `boolean` | `false` | Whether the input is clearable. | |
| count-graphemes | `(value: string) => number` | `undefined` | Count graphemes of input value. If it's set, native `maxlength` and `minlength` won't be used. | 2.34.0 |
| default-value | `string \| [string, string] \| null` | `null` | Default value when not manually set. | |
| disabled | `boolean` | `false` | Whether to disable the input. | |
| input-props | `InputHTMLAttributes \| TextareaHTMLAttributes` | `undefined` | The dom props of the input element inside the component. This is disabled if the `pair` property is true. For avaiable attributes, [see here](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). Warning:It won't override internal props with the same name (except `type`). | |
| loading | `boolean` | `undefined` | Set loading state. If set (true/false), the element will always take up enough space for the loading indicator. | |
| maxlength | `number` | `undefined` | Maximum input length. | |
| minlength | `number` | `undefined` | Minimum input length. | |
| pair | `boolean` | `false` | Whether to use the pairwise type input. | |
| passively-activated | `boolean` | `false` | Whether to passively activate the input. | |
| placeholder | `string \| [string, string]` | `undefined` | Placeholder of input. When `pair` is `true`, this is an array. | |
| readonly | `boolean` | `false` | Set the readonly state. | |
| render-count | `(props: { value: string }) => void` | `undefined` | Render function of word count. | 2.32.2 |
| round | `boolean` | `false` | Use a rounded input style. | |
| rows | `number` | `3` | Rows property for when the input is of type `textarea`. | |
| separator | `string` | `undefined` | The separator between pairwise inputs. | |
| show-count | `boolean` | `false` | Whether to show the word count. | |
| show-password-on | `'click' \| 'mousedown'` | `undefined` | The event to show the password. | |
| size | `'tiny' \| 'small' \| 'medium' \| 'large'` | `'medium'` | Input size. | |
| status | `'success' \| 'warning' \| 'error'` | `undefined` | Validation status. | 2.25.0 |
| type | `'text' \| 'password' \| 'textarea'` | `'text'` | Input type. | |
| value | `string \| [string, string] \| null` | `undefined` | Manually set the input value. When `pair` is `true`, this is an array. | |
| on-blur | `() => void` | `undefined` | Callback triggered when the input is blurred. | |
| on-change | `(value: string \| [string, string]) => void` | `undefined` | Callback triggered when native change event is fired. | |
| on-clear | `() => void` | `undefined` | Callback triggered when the input is cleared. | |
| on-focus | `() => void` | `undefined` | Callback triggered when the input is focussed on. | |
| on-input | `(value: string \| [string, string]) => void` | `undefined` | Callback triggered when the input gets user input. | |
| on-update:value | `(value: string \| [string, string]) => void` | `undefined` | Callback triggered when the input value changes. | |
### Input Slots
| Name | Parameters | Description | Version |
| --- | --- | --- | --- |
| clear-icon | `()` | Custom clear icon. | 2.29.0 |
| count | `(props: { value: string })` | Word count. | |
| password-invisible-icon | `()` | Password toggle icon when password is invisible. | 2.27.0 |
| password-visible-icon | `()` | Password toggle icon when password is visible. | 2.27.0 |
| prefix | `()` | Prefix content slot. | |
| separator | `()` | The separator content of the input, only works when `pair` is true. This will take priority over the separator property. | |
| suffix | `()` | Suffix content slot. | |
### InputGroup Slots
| Name | Parameters | Description |
| ------- | ---------- | ------------------------------- |
| default | `()` | The content of the input group. |
### InputGroupLabel Slots
| Name | Parameters | Description |
| ------- | ---------- | ------------------------------------- |
| default | `()` | The content of the input group label. |
### Input Methods
| Name | Type | Description | Version |
| --- | --- | --- | --- |
| blur | `() => void` | Blur the input element. | |
| clear | `() => void` | Clear input value. | 2.37.0 |
| focus | `() => void` | Focus the input element. | |
| scrollTo | `(options: { left?: number, top?: number, behavior?: 'auto' \| 'smooth' }) => void` | Scroll To. | 2.32.0 |
| select | `() => void` | Select the input element. | |
---
# Input Number
If you just want a number, this is for you.
## Demos
### Basic
```vue
```
### Disabled
```vue
```
### Custom parsing
You can use `parse` and `format` to custom parsing & display. For example add thousand separator. Usually they should be set together, especially you have a custom `validator` set.
Use `parse` and `format` will disable `update-value-on-input`.
```vue
```
### Precision
Set the `precision` property to control the numerical precision.
Use `precision` will disable `update-value-on-input`.
```vue
```
### Event
Blur & change events are exposed.
```vue
```
### Prefix & suffix
Add prefix and suffix contents.
```vue
$
%
%
```
### Button placement
Button can be placed at both ends.
```vue
$
฿
```
### Loading
```vue
```
### Min and max
You can set minimum and maximum values too.
```vue
```
### Size
```vue
```
### Step
Set how much the buttons change the value.
```vue
```
### Validator
```vue
```
### Hide button
Use `show-button` prop to control whether to show control buttons.
```vue
```
### Disable keyboard arrow up & down
Set `:keyboard="{ ArrowUp: false, ArrowDown: false }"` to disabled keyboard arrow up & down.
```vue
```
### Timing to change
Set `update-value-on-input` to `false`, the value won't be changed on input.
```vue
{{ value }}
```
### Validation status
Validation status can be applied outside form.
```vue
```
### Custom Icon
```vue
```
## API
### InputNumber Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| autofocus | `boolean` | `false` | Whether to autofocus. | 2.26.1 |
| bordered | `boolean` | `true` | Whether to show a border. | |
| button-placement | `'both' \| 'right'` | `'right'` | Placement of add & minus button. | 2.29.1 |
| clearable | `boolean` | `false` | Whether the input is clearable. | |
| default-value | `number \| null` | `null` | Default value when not manually set. | |
| disabled | `boolean` | `false` | Whether to disable the input. | |
| format | `(value: number \| null) => string` | `undefined` | Method to format value. If it's set, `update-value-on-input` will be disabled. | 2.30.0 |
| input-props | `InputHTMLAttributes` | `undefined` | The dom props of the input element inside the component. For avaiable attributes, [see here](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). Warning:It won't override internal props with the same name (except `type`). | 2.37.0 |
| keyboard | `{ ArrowUp?: boolean, ArrowDown?: boolean }` | `{}` | Control the keyboard behavior. If you set corresponding to false, the keyboard behavior will be disabled. | |
| loading | `boolean` | `undefined` | Set loading state. If set (true/false), the element will always take up enough space for the loading indicator. | |
| max | `number` | `undefined` | The max value. | |
| min | `number` | `undefined` | The min value. | |
| parse | `(input: string) => number \| null` | `undefined` | Method to parse input string. If it's set, `update-value-on-input` will be disabled. | 2.30.0 |
| placeholder | `string` | `'Please Input'` | Placeholder. | |
| precision | `number` | `undefined` | Precision of input value. If it's set, `update-value-on-input` will be disabled. | 2.30.0 |
| round | `boolean` | `undefined` | Use a rounded input style. | 2.39.0 |
| readonly | `boolean` | `false` | Whether it's readonly. | |
| show-button | `boolean` | `true` | Whether to show increase/decrease buttons. | |
| size | `'tiny' \| 'small' \| 'medium' \| 'large'` | `'medium'` | The size of input box. | |
| status | `'success' \| 'warning' \| 'error'` | `undefined` | Validation status. | 2.27.0 |
| step | `number` | `1` | The number which the current value is increased or decreased on key or button press. It can be an integer or a decimal. | |
| update-value-on-input | `boolean` | `true` | Whether to change the value on input if the input value is valid. | |
| validator | `(value) => boolean` | `undefined` | Setup custom validation. | |
| value | `number \| null` | `undefined` | Manually set the input value. | |
| on-blur | `(event: FocusEvent) => void` | `undefined` | Callback triggered when the input is blurred. | |
| on-clear | `() => void` | `undefined` | Callback triggered when the input is cleared. | |
| on-focus | `(event: FocusEvent) => void` | `undefined` | Callback triggered when the input is focussed on. | |
| on-update:value | `(value: number \| null) => void` | `undefined` | Callback triggered when the input value changes. | |
### InputNumber Slots
| Name | Parameters | Description | Version |
| ---------- | ---------- | ------------------------- | ------- |
| add-icon | `()` | icon of the add button. | 2.28.1 |
| minus-icon | `()` | icon of the minus button. | 2.28.1 |
| prefix | `()` | Prefix content slot. | |
| suffix | `()` | Suffix content slot. | |
### InputNumber Methods
| Name | Type | Description |
| ----- | ------------ | ----------------------- |
| blur | `() => void` | Blur the input number. |
| focus | `() => void` | Focus the input number. |
---
# Input OTP
InputOTP is used to enter one time password.
Available since `2.41.1`.
## Demos
### Basic
The number of characters is defined by the `length` prop, which by default is `6`.
```vue
```
### Status
Readonly, disabled, warning, error status.
```vue
```
### Mask
Set `mask=true` to turn on input mask.
```vue
```
### Custom rendering
By using `default` slot, you can custom UI to replace default design.
```vue
--
```
### Block
`block` property will make the `n-input-otp` fit to its parent width.
```vue
```
### Size
```vue
```
### Use with form
An example for using together with `n-form`.
```vue
Validate
```
### Limit input format
Use `allow-input` to limit input value to desired format.
```vue
Only allow number input
Only allow character input
```
## API
### InputOTP Props
| Name | Type | Type Alais | Default | Description | Version |
| --- | --- | --- | --- | --- | --- |
| allow-input | `(char: string, index: number, currentValue: string[]) => boolean` | `InputOtpAllowInput` | `undefined` | Check the incoming value, if it returns `false`, input will not be accepted. | 2.41.1 |
| block | `boolean` | | `false` | Whether to fit its width to its parent's width. | 2.42.0 |
| default-value | `string[]` | | `[]` | Default value. | 2.41.1 |
| disabled | `boolean` | | `false` | Whether the component is disabled. | 2.41.1 |
| gap | `string \| number` | | `undefined` | Gap between different input. If not specified, the default styling would be applied. | 2.41.1 |
| length | `number` | | `6` | Number of characters to initiate. | 2.41.1 |
| mask | `boolean` | | `false` | Whether to enable password mode. | 2.41.1 |
| placeholder | `string` | | `''` | Input placeholder. | 2.41.1 |
| readonly | `boolean` | | `false` | Whether the component is readonly. | 2.41.1 |
| size | `'small' \| 'medium' \| 'large'` | `InputOtpSize` | `'medium'` | Size of the component. | 2.41.1 |
| status | `'success' \| 'warning' \| 'error'` | `FormValidationStatus` | `undefined` | The validation status of the component. | 2.41.1 |
| value | `string \| null` | | `undefined` | Value of the component (in controlled mode). | 2.41.1 |
| on-blur | `(event: FocusEvent, index: number) => void` | `InputOtpOnBlur` | `undefined` | Callback fired when the focus is out of the component. | 2.41.1 |
| on-finish | `(value: string[]) => void` | `InputOtpOnFinish` | `undefined` | Callback fired when all child inputs are settled. | 2.41.1 |
| on-focus | `(event: FocusEvent, index: number) => void` | `InputOtpOnFocus` | `undefined` | Callback fired when the focus is moved from outside to the component. | 2.41.1 |
| on-update:value | `(value: string[], meta: { diff: string, index: number, source: 'input' \| 'delete' \| 'paste' }) => void` | `InputOtpOnUpdateValue`, `InputOtpOnUpdateValueMeta`, `InputOtpOnUpdateValueMetaSource` | `undefined` | Callback fired when user inputs value. `meta.index` is the start index of the value change.`meta.diff` is the content that changes. `meta.source` is the reason of the value change. If reason is `'delete'`, `meta.diff` is `''`. If reason is `'paste'`, `meta.diff` is the final accepted part of the paste content. | 2.41.1 |
### InputOTP Slots
| Name | Parameters | Type Alias | Description | Version |
| --- | --- | --- | --- | --- |
| default | `(props: InputProps & { index: number, ref: (inst: InputInst) => void })` | `InputOtpDefaultSlot` | Input area. | 2.41.1 |
### InputOTP Methods
| 名称 | 类型 | 说明 | 版本 |
| --- | --- | --- | --- |
| focusOnChar | `(charIndex: number) => void` | Focus on a certain input box. | 2.43.0 |
---
# Mention
A year ago, my product manager asked me if I could implement this feature. Back then, I recommended just using multiple selects as a workaround.
## Demos
### Basic usage
If `label` is a render function, the `value` property will be used for matching.
```vue
```
### Textarea
The input `type` can be set to `'textarea'`.
```vue
```
### Load remote options
Load options asynchronously.
```vue
```
### Autosize
```vue
```
### Work with form
```vue
Validate
```
### Render label
If the `option.label` property is not a string, the `option.value` property will be used for matching by default.
```vue
```
### Custom trigger prefix
Use `prefix` to set the trigger character(s).
```vue
```
### Manually trigger focus and blur
You may want to trigger `focus` and `blur` manually?
```vue
Click to focus, and will blur after one second
```
### Validation status
Validation status can be applied outside form.
```vue
```
## API
### Mention Props
Mention requires `v2.2.0` and above.
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| autosize | `boolean \| { maxRows?: number, minRows?: number }` | `false` | Autosize. | |
| options | `MentionOption[]` | `[]` | Mention options list. | |
| type | `'text' \| 'textarea'` | `'text'` | Input type. | |
| separator | `string` | `' '` | Character to split mentions. The string length must be exactly 1. | |
| bordered | `boolean` | `true` | Whether to display the border of the input element. | |
| disabled | `boolean` | `false` | Whether to disable the input element. | |
| default-value | `string` | `''` | Default value when the value is not manually set. | |
| filter | `(pattern: string, option: MentionOption) => boolean` | Default filter method | Method to filter options corresponding to `pattern`. | 2.38.2 |
| loading | `boolean` | `false` | Whether the selection panel of mentions is in a loading state. | |
| prefix | `string \| string[]` | `'@'` | Prefix character(s) to trigger mentions. The string length(s) must be exactly 1. | |
| placeholder | `string` | `''` | Placeholder. | |
| placement | `'top-start' \| 'top' \| 'top-end' \| 'right-start' \| 'right' \| 'right-end' \| 'bottom-start' \| 'bottom' \| 'bottom-end' \| 'left-start' \| 'left' \| 'left-end'` | `'bottom-start'` | Selection panel's placement . | 2.25.0 |
| render-label | `(option: MentionOption) => VNodeChild` | `undefined` | Options' labels render function. | |
| scrollbar-props | `ScrollbarProps` | `undefined` | See [Scrollbar props](https://www.naiveui.com/en-US/components/scrollbar.md#Scrollbar-Props) | 2.44.0 |
| size | `'small' \| 'medium' \| 'large'` | `'medium'` | Input size. | |
| status | `'success' \| 'warning' \| 'error'` | `undefined` | Validation status. | 2.27.0 |
| to | `string \| HTMLElement \| false` | `body` | Container node of the menu. `false` will keep it not detached. | |
| value | `string \| null` | `undefined` | Manually set input value. | |
| on-update:show | `(show: boolean) => void` | `undefined` | Callback when the selection panel of mentions is shown or hidden. | 2.34.0 |
| on-update:value | `(value: string) => void` | `undefined` | Triggered when the input box value is updated. | |
| on-select | `(option: MentionOption, prefix: string) => void` | `undefined` | Triggered when the input box is selected. | |
| on-focus | `(e: FocusEvent) => void` | `undefined` | Triggered when the input box is focussed on. | |
| on-search | `(pattern: string, prefix: string) => void` | `undefined` | Triggered when searching in the input box. | |
| on-blur | `(e: FocusEvent) => void` | `undefined` | Triggered when the input box loses focus. | |
### MentionOption Properties
| Name | Type | Description |
| --- | --- | --- |
| class | `string` | Option class property. |
| disabled | `boolean` | Option disabled state. |
| label | `string \| (option: MentionOption) => VNodeChild` | Option label. |
| render | `(option: MentionOption) => VNodeChild` | Support custom options via `render` rendering function. |
| style | `string` | Option style property. |
| value | `string` | Option value. Must be unique. |
### Mention Methods
| Name | Type | Description |
| ----- | ------------ | -------------------------------- |
| focus | `() => void` | Manually focus on the component. |
| blur | `() => void` | Manually blur the component. |
### Mention Slots
| Name | Parameters | Description |
| ----- | ---------- | --------------------------- |
| empty | `()` | Slot when menu has no data. |
---
# Radio
When I was young, I loved listening to the radio, such as FM 106.8 or FM 92.1.
## Demos
### Basic
```vue
Definitely Maybe
Be Here Now
```
### Group
A radio group looks elegant.
```vue
```
### Using Options
Pass option data directly through the `options` prop. You can also customize field names with `label-field` and `value-field`.
```vue
```
### Button group
Sometimes a radio button group can look more elegant.
```vue
Disable Shakemaker
Disable Live Forever
```
### Size
Choose the size you want.
```vue
{{ song.label }}
{{ song.label }}
Disable Shakemaker
Disable Live Forever
```
## API
### Radio Props, RadioButton Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| checked | `boolean` | `undefined` | Checked state. | |
| default-checked | `boolean` | `false` | Default checked state. | |
| disabled | `boolean` | `false` | Disabled state. | |
| label | `string` | `undefined` | Radio label. If not set, render default slot content, if both, use default slot content first. | 2.28.0 |
| name | `string` | `undefined` | The name attribute of the radio element. If not set, name of `radio-group` will be used. |
| size | `'small' \| 'medium' \| 'large'` | `'medium'` | Size. | |
| value | `string \| number \| boolean` | `'on'` | Checked value. | `boolean` 2.33.0 |
| on-update:checked | `(check: boolean) => void` | `undefined` | Callback method triggered when a selection change occurs. | |
### RadioGroup Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| disabled | `boolean` | `false` | Disabled state. | |
| default-value | `string \| number \| boolean \| null` | `null` | Default checked value. | |
| label-field | `string` | `'label'` | The field name of option labels in `options`. | 2.45.0 |
| name | `string` | `undefined` | The name attribute of the radio elements inside the group. | |
| options | `Array<{ label?: string, value: string \| number \| boolean, disabled?: boolean }>` | `undefined` | Options for the radio group. When set, the default slot is ignored. | 2.45.0 |
| size | `'small' \| 'medium' \| 'large'` | `'medium'` | Size. | |
| value | `string \| number \| boolean \| null` | `null` | Checked value. | |
| value-field | `string` | `'value'` | The field name of option values in `options`. | 2.45.0 |
| on-update:value | `(value: string \| number \| boolean) => void` | `undefined` | Callback method triggered when a selection change occurs. | |
---
# Rate
Hint: If you are not very confident, think twice before changing the star's color. That can lead to a disaster.
## Demos
### Basic
```vue
```
### Size
Rate has `small`, `medium` and `large` size. Also you can use number to specify the size.
```vue
```
### Color
This can end in disaster.
```vue
```
### Icon
The content of the default slot will be used as the icon.
```vue
```
### Allow Selecting Half Star
```vue
```
### Readonly
```vue
```
### Clearable
After `clearable` is set, you can click at current value's corresponding value to reset value to `null`.
```vue
```
### Hover Value
Listen to hover value changes via `on-update:hover-value`.
```vue
```
## API
### Rate Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| allow-half | `boolean` | `false` | Allow activating half of the icon. | |
| clearable | `boolean` | `false` | Whether the rate is clearable. Value will be set to `null` if you click on current value's corresponding icon. | 2.33.0 |
| color | `string` | `undefined` | Activated icon color. This supports the formats: `#FFF`, `#FFFFFF`, `yellow`, `rgb(0, 0, 0)`. | |
| count | `number` | `5` | Number of icons (max rating). | |
| default-value | `number \| null` | `null` | Default value of activated icons. Before 2.33.0 default value is `null`. | 2.33.0 `null` |
| readonly | `boolean` | `false` | Readonly state. | |
| size | `'small' \| 'medium' \| 'large' \| number` | `'medium'` | Icon size. | |
| value | `number \| null` | `undefined` | Value of activated icons. | |
| on-clear | `() => void` | `undefined` | Callback on value is cleared. | 2.33.0 |
| on-update:hover-value | `(value: number \| null) => void` | `undefined` | Callback when the hover value changes. | 2.45.0 |
| on-update:value | `(value: number) => void` | `undefined` | Callback on the value (rating) is changed. | |
### Rate Slots
| Name | Parameters | Description |
| ------- | --------------------------- | ----------------------- |
| default | `(info: { index: number })` | The icon of the rating. |
---
# Select
Select something!
## Demo
### Basic
Basic usage of `n-select`.
```vue
```
### Size
```vue
```
### Multiple select
Allow the selection of multiple values.
```vue
```
### UpdateValue event
Why make the `update:value` event an example? Because there's so little to write.
```vue
```
### Filterable
Go go go, Filter.
```vue
```
### Create option dynamically
Use `tag` & `filterable` properties to create options dynamically.
```vue
```
### Menu width
The options menu width can be made to fit its content. Using this disables virtual scrolling.
```vue
```
### Remote (single)
Asynchronous example for a single select case.
```vue
```
### Remote (multiple)
Asynchronous options example for a multiple select case.
```vue
```
### Clearable
Make the select clearable. Remember you can only clear a select that has a value.
```vue
```
### Scroll event
A colleague of mine wanted to use a scroll event for loading options asynchronously. Here's that example.
```vue
```
### Group
Options can also be grouped together.
```vue
```
### Lots of options
1000 times the answer to everything.
```vue
```
### Customize option rendering
After much deliberation, I decided to drop the slot API for rendering options; however, using `render-label`, `style`, and/or `class` properties you can do almost anything.
```vue
```
### Customize arrow
Make arrow a bit different.
```vue
```
### Action slot
Is there anybody who needs an action slot on a select menu?
```vue
Don't know what to put
If you click this demo, you may need it.
```
### Fallback option
If you don't need fallback options, setting `fallback-option` to `false` ensures that only an option with a matching value will be displayed. If no option has that value, the selected value will be cleared.
```vue
```
### Max tag count
Maximum selected options to display. This can be a fixed number or the string `responsive` to set a responsive max count.
```vue
```
### Add tooltip to option
Use the `render-option` property to control rendering of the entire option.
```vue
```
### Customize tag rendering
Give the tag a little color.
```vue
```
### Focus & blur manually
```vue
Focus then blur in 1 second
```
### Select person
I've found that people often want to make a people picker. Here is an example that shows you how that can be done with a select.
```vue
```
### Use as tag input box
Use `tag` and `:show="false"` to use select as a tag input box.
```vue
```
### Customizing field
Various data would come from backend.
```vue
```
## API
### Select Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| consistent-menu-width | `boolean` | `true` | Whether the menu keeps its width the same as the select trigger element. Setting it to `false` will also disable `virtual-scroll`. | |
| children-field | `string` | `'children'` | Field name of group option children. | 2.29.1 |
| clearable | `boolean` | `false` | Whether the value is clearable. | |
| clear-created-options-on-clear | `boolean` | `true` | When `tag` and `clearable` are enabled, whether to clear created options when clearing. | 2.44.0 |
| clear-filter-after-select | `boolean` | `true` | When multiple and filter is true, whether to clear filter keyword after select an option. | 2.25.2 |
| default-value | `Array \| string \| number \| null` | `null` | Default value. | |
| disabled | `boolean` | `false` | Whether to disable the select. | |
| ellipsis-tag-popover-props | `PopoverProps` | `undefined` | `popover` props of the preview ellipsis tag. | 2.37.0 |
| fallback-option | `false \| (value: string \| number) => SelectOption` | `value => ({ label: '' + value, value })` | The option to be created using the value which has no corresponding option value. If set to `false`, the fallback option won't be created and displayed. | |
| filterable | `boolean` | `false` | Whether options can be filtered. | |
| filter | `(pattern: string, option: Object) => boolean` | String search method. | Filter function. | |
| ignore-composition | `boolean` | `true` | Ingore IME's composition status. By default `filter` won't be triggered by input event under compositions. | 2.33.4 |
| input-props | `InputHTMLAttributes` | `undefined` | The attributes of input element in the trigger. It only works when the select is filterable. | |
| keyboard | `boolean` | `true` | Whether to allow keyboard control. | 2.34.4 |
| label-field | `string` | `'label'` | Field name of option label. | 2.29.1 |
| loading | `boolean` | `false` | Whether to show a loading state. | |
| max-tag-count | `number \| 'responsive'` | `undefined` | Maximum selected values to display while in `multiple` mode. `responsive` will keep all the tags in single line. | |
| menu-props | `HTMLAttributes` | `undefined` | The menu's dom props. | |
| menu-size | `'tiny' \| 'small' \| 'medium' \| 'large'` | `'medium'` | Size of select menu. | 2.40.0 |
| multiple | `boolean` | `false` | Whether to allow selecting multiple values. | |
| node-props | `(option: SelectOption \| SelectGroupOption) => object` | `undefined` | Option's DOM attrs generator. | 2.32.2 |
| options | `Array` | `[]` | Options that can be selected. For more details see SelectOption Properties (below). | |
| placeholder | `string` | `'Please Select' (i18n)` | Placeholder. | |
| placement | `'top-start' \| 'top' \| 'top-end' \| 'right-start' \| 'right' \| 'right-end' \| 'bottom-start' \| 'bottom' \| 'bottom-end' \| 'left-start' \| 'left' \| 'left-end'` | `'bottom-start'` | Option menu's placement. | 2.25.0 |
| remote | `boolean` | `false` | Allows options to be fetched asynchronously. Note that if `remote` is set, `filter` & `tag` won't work on `options`. | |
| render-label | `(option: SelectOption \| SelectGroupOption, selected: boolean) => VNodeChild` | `undefined` | Render function for each option label. | |
| render-option | `(info: { node: VNode, option: SelectOption \| SelectGroupOption, selected: boolean }) => VNodeChild` | `undefined` | Render function for each option. | |
| render-tag | `(props: { option: SelectBaseOption, handleClose: () => void }) => VNodeChild` | `undefined` | Render function for each option tag. | |
| reset-menu-on-options-change | `boolean` | `true` | Whether to reset menu status on options change, for example, scroll status. | 2.24.2 |
| scrollbar-props | `ScrollbarProps` | `undefined` | See [Scrollbar props](https://www.naiveui.com/en-US/components/scrollbar.md#Scrollbar-Props) | 2.44.0 |
| show | `boolean` | `undefined` | Whether to show/open the option menu. | |
| show-arrow | `boolean` | `true` | Whether to show the dropdown arrow. | |
| show-checkmark | `boolean` | `true` | Whether to show checkmark. | 2.33.4 |
| show-on-focus | `boolean` | `false` | Whether to show menu on focus. | 2.34.3 |
| size | `'tiny' \| 'small' \| 'medium' \| 'large'` | `'medium'` | Size of the select input. | |
| status | `'success' \| 'warning' \| 'error'` | `undefined` | Validation status. | 2.27.0 |
| tag | `boolean` | `false` | Whether users can create new options. This should be used with `filterable`. | |
| to | `string \| HTMLElement \| false` | `body` | Container node of the menu. `false` will keep it not detached. | |
| value | `Array \| string \| number \| null` | `undefined` | Value when being manually set. | |
| value-field | `string` | `'value'` | Field name of option value. | 2.29.1 |
| virtual-scroll | `boolean` | `true` | Whether to enable virtual scrolling. | |
| on-blur | `() => void` | `undefined` | Callback triggered when the selection element is blurred. | |
| on-clear | `() => void` | `undefined` | Callback triggered when the selection element is cleared. | |
| on-create | `(label: string) => SelectOption` | `label => ({ label, value: label })` | How to create an option when you type in a custom option. Note that `filter` will be applied to the created option too. And you'd better make sure that the value of the created option is not the same as any other option. Should be used with `tag` prop. | |
| on-focus | `() => void` | `undefined` | Callback triggered when the selection element is focussed on. | |
| on-scroll | `(e: ScrollEvent) => void` | `undefined` | Callback triggered when the options menu is scrolled. | |
| on-search | `(value: string) => void` | `undefined` | Callback triggered when a search is conducted. | |
| on-update:show | `(show: boolean) => void` | `undefined` | Callback on menu open status change. | 2.24.2 |
| on-update:value | `(value: Array \| string \| number \| null, option: SelectBaseOption \| null \| SelectBaseOption[]) => void` | `undefined` | Callback triggered when the selected value is updated. | |
#### SelectOption Properties
| Name | Type | Description |
| --- | --- | --- |
| class | `string` | Customize the option's class. |
| disabled | `boolean` | Whether to disable the option. |
| label | `string \| ((option: SelectOption, selected: boolean) => VNodeChild)` | Label of the option. Note that if you are using the `render` function, the default filter will filter the option. |
| render | `(info: { node: VNode, option: SelectOption, selected: boolean }) => VNodeChild` | Render the entire option. |
| style | `string \| CSSProperties` | Customize the option's style. |
| value | `string \| number` | Should be unique for each option. |
#### SelectGroupOption Properties
| Name | Type | Description |
| --- | --- | --- |
| children | `Array` | Child select options. |
| label | `string \| ((option: SelectGroupOption) => VNodeChild)` | Label of the group. |
| key | `string \| number` | Should be unique for each option. |
| render | `(info: { node: VNode, option: SelectOption, selected: boolean }) => VNodeChild` | Render the entire option. |
| type | `'group'` | Type of the group option. |
### Select Slots
| Name | Parameters | Description | Version |
| ------ | ---------- | -------------------------------------- | ------- |
| header | `()` | Header menu slot. | 2.37.0 |
| action | `()` | Options menu slot. | |
| empty | `()` | Empty state slot for the options menu. | |
| arrow | `()` | Arrow icon slot. | 2.24.2 |
### Select Methods
| Name | Type | Description | Version |
| ---------- | ------------ | ------------ | ------- |
| focus | `() => void` | Focus. | 2.24.2 |
| focusInput | `() => void` | Input focus. | 2.35.0 |
| blur | `() => void` | Blur. | 2.24.2 |
| blurInput | `() => void` | Input blur. | 2.35.0 |
---
# Slider
As far as I know, it is always used as a volume control.
## Demos
### Basic
```vue
```
### Range
```vue
```
### Mark
```vue
```
### Restrict selectable values
Set `step="mark"` to restrict the selectable values to those provided by the mark prop.
```vue
```
### Disabled
```vue
```
### Disable tooltip
Set `:tooltip="false"` to disabled the tooltip.
```vue
```
### Format tooltip
```vue
```
### Reverse
Set `reverse` to invert the track.
```vue
```
### Vertical
Set `vertical` to enable the vertical mode. Its height depends on the height of the container by default, and you can also customize the height.
```vue
```
### Always show tooltip
Set `show-tooltip` to always show tooltip.
```vue
```
### Customize handle
You can use `handle` slot to customize handle button.
```vue
```
### Custom Mark
You can use `marks` prop to customize handle button.
```vue
```
## API
### Slider Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| default-value | `number \| [number, number] \| null` | `null` | Default value. | |
| disabled | `boolean` | `false` | Whether the slider is disabled. | |
| format-tooltip | `(value: number) => string \| number` | `undefined` | Format tooltip. | |
| keyboard | `boolean` | `true` | Whether the slider can be controlled keyboard. | 2.33.0 |
| marks | `{ [markValue: number]: string \| (() => VNodeChild) }` | `undefined` | Marks of the slider | Render function since 2.40.0 |
| max | `number` | `100` | Max value of the slider. | |
| min | `number` | `0` | Min value of the slider. | |
| placement | `'top-start' \| 'top' \| 'top-end' \| 'right-start' \| 'right' \| 'right-end' \| 'bottom-start' \| 'bottom' \| 'bottom-end' \| 'left-start' \| 'left' \| 'left-end'` | `undefined` | Tooltip's placement | 2.25.0 |
| range | `boolean` | `false` | Whether the slider uses range value. | |
| reverse | `boolean` | `false` | Whether to reverse the track. | |
| show-tooltip | `boolean` | `false` | Whether to always show tooltip. Only work with non-range slider. | 2.24.2 |
| step | `number \| 'mark'` | `1` | Step of the slider. | |
| tooltip | `boolean` | `true` | Whether to show tooltip. | |
| vertical | `boolean` | `false` | Whether to enable vertical mode. | |
| value | `number \| [number, number] \| null` | `undefined` | Value of the slider. | |
| on-update:value | `(value: number \| [number, number]) => void` | `undefined` | Callback on value update. | |
| on-dragstart | `() => void` | `undefined` | Callback function of dragging start. | 2.36.0 |
| on-dragend | `() => void` | `undefined` | Callback function of dragging end. | 2.36.0 |
### Slider Slots
| Name | Parameters | Description | Version |
| ----- | ---------- | -------------------- | ------- |
| thumb | `()` | Thumb of the slider. | 2.30.4 |
---
# Switch
I have a Nintendo Switch, but don't have time to play it. This reminds me of my childhood when I played NDS... a happier time.
## Demos
### Basic
```vue
```
### Size
```vue
```
### Content
Add switch content.
```vue
Big wheels keep on turnin'
Carry me home to see my kin
```
### Loading
```vue
```
### Event
```vue
```
### Customize checked value
Use `checked-value` and `unchecked-value` to customize respective values.
```vue
```
### Shape
Switch can have square shape.
```vue
```
### Customizing colors
```vue
Checked
Unchecked
```
### Customizing Icon
```vue
🤔
```
## API
### Switch Props
| Name | Type | Default | Description | Version |
| --- | --- | --- | --- | --- |
| checked-value | `string \| boolean \| number` | `true` | Value of checked state. | |
| default-value | `boolean` | `false` | Default value. | |
| disabled | `boolean` | `false` | Whether to disable the switch. | |
| loading | `boolean` | `false` | Whether to show loading state. | |
| rail-style | `(info: { focused: boolean, checked: boolean }) => (CSSProperties \| string)` | `undefined` | Rail style generator. | |
| round | `boolean` | `true` | Whether the switch has rounded corners. | |
| rubber-band | `boolean` | `true` | Whether the switch button has rubber band effect. | 2.28.3 |
| size | `'small' \| 'medium' \| 'large'` | `'medium'` | The size of the switch. | |
| spin-props | `{ strokeWidth?: number, stroke?: string, scale?: number, radius?: number }` | `undefined` | Loading icon properties. | 2.44.0 |
| unchecked-value | `string \| boolean \| number` | `false` | Value of unchecked state. | |
| value | `string \| number \| boolean \| undefined` | `undefined` | Value when being set manually. | |
| on-update:value | `(value: boolean) => void` | `undefined` | Callback when the component's value changes. | |
### Switch Slots
| Name | Parameters | Description | Version |
| --- | --- | --- | --- |
| checked | `()` | Content when the switch is checked. | |
| checked-icon | `()` | Icon of switch button when checked. | 2.25.3 |
| icon | `()` | Icon of switch button. | 2.25.3 |
| unchecked | `()` | Content when the switch is unchecked. | |
| unchecked-icon | `()` | Icon of switch button when unchecked. | 2.25.3 |
---
# Time Picker
Like a digital clock.
## Demos
### Basic
```vue
```
### Confirm
```vue
```
### Size
The Time Picker can be a `small`, `medium` or `large` size.
```vue
```
### Disable time
If you can't stop time, at least disable it.
```vue
```
### Step time
Pass a number as an incremental step, or use an array to specify the values you want to show. If inputs do not adhere to these parameters, an invalid status will be shown (strikethrough text).
```vue
```
### Format
```vue
```
### Actions
```vue
```
### 12 hours
```vue
```
### Use formatted value
Use `formatted-value` to control formatted value.
```vue