Select 选择器
===
[](https://jaywcjlove.github.io/#/sponsor)
[](https://t.me/s/AwesomeMacApps)
[](https://x.com/jaywcjlove)
[](https://uiwjs.github.io/npm-unpkg/#/pkg/@uiw/react-select/file/README.md)
[](https://www.npmjs.com/package/@uiw/react-select)
[](https://npmjs.com/@uiw/react-select)
当选项过多时,使用下拉菜单展示并选择内容。
```jsx
import { Select } from 'uiw';
// or
import Select from '@uiw/react-select';
```
### 基础用法
适用广泛的基础单选 `value` 的值为当前被选中的 `Option` 的 `value` 属性值。自定义 `Select` 请查看 [``](#/components/dropdown) 组件实例。
```jsx mdx:preview&bg=#fff
import React from 'react';
import { Row, Col, Select } from 'uiw';
export default function Demo() {
return (
);
}
```
### 禁用选择器
```jsx mdx:preview&bg=#fff
import React from 'react';
import { Row, Col, Select } from 'uiw';
export default function Demo() {
return (
);
}
```
### 尺寸
通过 `size` 属性设置选择器的尺寸,提供三个尺寸参数设置。
```jsx mdx:preview&bg=#fff
import React from 'react';
import { Row, Col, Select, Button } from 'uiw';
const rowSty = { marginBottom: 10 };
export default function Demo() {
return (
);
}
```
### 选项组
```jsx mdx:preview&bg=#fff
import React from 'react';
import { Row, Col, Select } from 'uiw';
const Option = Select.Option;
const Group = Select.Group;
export default function Demo() {
return (
);
}
```
### 在表单中使用
在 [``](#/components/form) 表单中应用 [``](#/components/select) 组件
```jsx mdx:preview&bg=#fff
import React from 'react';
import { Form, Row, Col, Select, Button, Notify } from 'uiw';
export default function Demo() {
return (
)
}
```
### HTML select
这个组件是最简单的基础样式组件,可以直接引用样式,使用 `w-select` 纯样式即可达到效果,下拉框右边箭头效果通过样式更改,通过 [`b64`](http://b64.io/) 工具,转换成 `base64` 格式。
```jsx
import 'uiw/lib/esm/select/style/index.less';
```
```jsx mdx:preview&bg=#fff
import React from 'react';
import { Row, Col, Select } from 'uiw';
export default function Demo() {
return (
);
}
```
## Select
| 参数 | 说明 | 类型 | 默认值 |
|--------- |-------- |--------- |-------- |
| value | 控制时 `select` 的值必须与 `onChange` 函数一起使用才能更新 `select` 的值 | Any | - |
| disabled | 禁用选择器 | Boolean | `false` |
| defaultValue | 根据 `value` 进行比较,判断是否选中 | Any | - |
| size | 选择框尺寸 | Enum {`large`, `default`, `small` } | `default` |