---
title: NativeSelect
description: "`NativeSelect`は、ユーザーがオプションのリストから1つの値を選択するために使用されるコンポーネントです。ブラウザ(ユーザーエージェント)によって提供されるネイティブなドロップダウンリストを表示します。"
links:
- style: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/native-select/native-select.style.ts
- source: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/native-select
- storybook: https://yamada-ui.github.io/yamada-ui?path=/story/components-nativeselect--basic
---
```tsx
日比野カフカ
市川レノ
亜白ミナ
四ノ宮キコル
```
## 使い方
:::note
`NativeSelect`は、ブラウザ(ユーザーエージェント)によって提供されるネイティブなUIコンポーネントです。これは、ブラウザがデフォルトで持っている機能を利用して、ドロップダウンリストを表示します。機能を拡張し、よりスタイリングされたコンポーネントを使いたい場合は、[Select](https://yamada-ui.com/components/forms/select.md)をご覧ください。
:::
```tsx
import { NativeSelect } from "@yamada-ui/react"
```
```tsx
import { NativeSelect } from "@/components/ui"
```
```tsx
import { NativeSelect } from "@workspaces/ui"
```
```tsx
```
### itemsを使う
```tsx
const items = useMemo(
() => [
{ label: "日比野カフカ", value: "日比野カフカ" },
{ label: "市川レノ", value: "市川レノ" },
{ label: "亜白ミナ", value: "亜白ミナ" },
{ label: "四ノ宮キコル", value: "四ノ宮キコル" },
],
[],
)
return
```
### バリアントを変更する
```tsx
const items = useMemo(
() => [
{ label: "日比野カフカ", value: "日比野カフカ" },
{ label: "市川レノ", value: "市川レノ" },
{ label: "亜白ミナ", value: "亜白ミナ" },
{ label: "四ノ宮キコル", value: "四ノ宮キコル" },
],
[],
)
return (
{(variant) => (
)}
)
```
### サイズを変更する
```tsx preview functional
const items = useMemo(
() => [
{ label: "日比野カフカ", value: "日比野カフカ" },
{ label: "市川レノ", value: "市川レノ" },
{ label: "亜白ミナ", value: "亜白ミナ" },
{ label: "四ノ宮キコル", value: "四ノ宮キコル" },
],
[],
)
return (
{(size) => (
)}
)
```
### デフォルトの値を設定する
デフォルトの値を設定する場合は、`defaultValue`に値を設定します。
```tsx
const items = useMemo(
() => [
{ label: "日比野カフカ", value: "日比野カフカ" },
{ label: "市川レノ", value: "市川レノ" },
{ label: "亜白ミナ", value: "亜白ミナ" },
{ label: "四ノ宮キコル", value: "四ノ宮キコル" },
],
[],
)
return (
)
```
### グループ化する
オプションをグループ化する場合は、`NativeSelectGroup`を使用します。
```tsx
鳴海弦
長谷川エイジ
日比野カフカ
市川レノ
亜白ミナ
四ノ宮キコル
```
```tsx
const items = useMemo(
() => [
{ label: "怪獣8号", value: "怪獣8号" },
{
label: "第1部隊",
items: [
{ label: "鳴海弦", value: "鳴海弦" },
{ label: "長谷川エイジ", value: "長谷川エイジ" },
],
},
{
label: "第3部隊",
items: [
{ label: "日比野カフカ", value: "日比野カフカ" },
{ label: "市川レノ", value: "市川レノ" },
{ label: "亜白ミナ", value: "亜白ミナ" },
{ label: "四ノ宮キコル", value: "四ノ宮キコル" },
],
},
],
[],
)
return
```
### プレースホルダーをオプションに含めない
デフォルトでは、オプションにプレースホルダーが含まれています。プレースホルダーをオプションに含めない場合は、`includePlaceholder`を`false`に設定します。
```tsx
const items = useMemo(
() => [
{ label: "日比野カフカ", value: "日比野カフカ" },
{ label: "市川レノ", value: "市川レノ" },
{ label: "亜白ミナ", value: "亜白ミナ" },
{ label: "四ノ宮キコル", value: "四ノ宮キコル" },
],
[],
)
return (
)
```
### オプションを無効にする
オプションを無効にする場合は、`NativeSelect.Option`の`disabled`を`true`に設定します。
```tsx
日比野カフカ
市川レノ
亜白ミナ
四ノ宮キコル
```
```tsx
const items = useMemo(
() => [
{ label: "日比野カフカ", value: "日比野カフカ" },
{ disabled: true, label: "市川レノ", value: "市川レノ" },
{ label: "亜白ミナ", value: "亜白ミナ" },
{ label: "四ノ宮キコル", value: "四ノ宮キコル" },
],
[],
)
return
```
### 無効にする
無効にする場合は、`disabled`を`true`に設定します。
```tsx
const items = useMemo(
() => [
{ label: "日比野カフカ", value: "日比野カフカ" },
{ label: "市川レノ", value: "市川レノ" },
{ label: "亜白ミナ", value: "亜白ミナ" },
{ label: "四ノ宮キコル", value: "四ノ宮キコル" },
],
[],
)
return (
{(variant) => (
)}
)
```
### 読み取り専用にする
読み取り専用にする場合は、`readOnly`を`true`に設定します。
```tsx
const items = useMemo(
() => [
{ label: "日比野カフカ", value: "日比野カフカ" },
{ label: "市川レノ", value: "市川レノ" },
{ label: "亜白ミナ", value: "亜白ミナ" },
{ label: "四ノ宮キコル", value: "四ノ宮キコル" },
],
[],
)
return (
{(variant) => (
)}
)
```
### 無効な入力にする
無効な入力にする場合は、`invalid`を`true`に設定します。
```tsx
const items = useMemo(
() => [
{ label: "日比野カフカ", value: "日比野カフカ" },
{ label: "市川レノ", value: "市川レノ" },
{ label: "亜白ミナ", value: "亜白ミナ" },
{ label: "四ノ宮キコル", value: "四ノ宮キコル" },
],
[],
)
return (
{(variant) => (
)}
)
```
### ボーダーの色を変更する
ボーダーの色を変更する場合は、`focusBorderColor`または`errorBorderColor`に値を設定します。
```tsx
const items = useMemo(
() => [
{ label: "日比野カフカ", value: "日比野カフカ" },
{ label: "市川レノ", value: "市川レノ" },
{ label: "亜白ミナ", value: "亜白ミナ" },
{ label: "四ノ宮キコル", value: "四ノ宮キコル" },
],
[],
)
return (
)
```
### アイコンをカスタマイズする
```tsx
const items = useMemo(
() => [
{ label: "日比野カフカ", value: "日比野カフカ" },
{ label: "市川レノ", value: "市川レノ" },
{ label: "亜白ミナ", value: "亜白ミナ" },
{ label: "四ノ宮キコル", value: "四ノ宮キコル" },
],
[],
)
return (
}
/>
)
```
### 制御する
```tsx
const [value, setValue] = useState("日比野カフカ")
const items = useMemo(
() => [
{ label: "日比野カフカ", value: "日比野カフカ" },
{ label: "市川レノ", value: "市川レノ" },
{ label: "亜白ミナ", value: "亜白ミナ" },
{ label: "四ノ宮キコル", value: "四ノ宮キコル" },
],
[],
)
return (
setValue(e.target.value)}
/>
)
```
## Props
### NativeSelect.Root
| Prop | Default | Type | Description |
| -------------------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------- |
| `as` | - | `As` | The HTML element to render. |
| `asChild` | - | `boolean` | Merges its props onto its immediate child. |
| `css` | - | `CSSObject \| CSSObject[]` | The CSS object. |
| `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. |
| `size` | `"md"` | `"lg" \| "md" \| "sm" \| "xl" \| "xs"` | The size of the component. |
| `variant` | `"outline"` | `"filled" \| "flushed" \| "outline" \| "plain"` | The variant of the component. |
| `elementProps` | - | `InputGroup.ElementProps` | The props for the end element. |
| `errorBorderColor` | - | `"-moz-initial" \| "ActiveBorder" \| "ActiveCaption" \| "aliceblue" \| "amber.100" \| "amber.200" \| "amber.300" \| "amber.400" \| "amber.50" \| "amber.500" ...` | The border color when the input is invalid. |
| `focusBorderColor` | - | `"-moz-initial" \| "ActiveBorder" \| "ActiveCaption" \| "aliceblue" \| "amber.100" \| "amber.200" \| "amber.300" \| "amber.400" \| "amber.50" \| "amber.500" ...` | The border color when the input is focused. |
| `icon` | - | `ReactNode` | The icon to be used in the select. |
| `iconProps` | - | `NativeSelectIconProps` | Props for icon element. |
| `includePlaceholder` | `true` | `boolean` | If `true`, include placeholder in options. |
| `invalid` | `false` | `boolean` | If `true`, the field will be invalid. |
| `items` | `[]` | `NativeSelectItem[]` | If provided, generate options based on items. |
| `placeholder` | - | `string` | The placeholder for select. |
| `readOnly` | `false` | `boolean` | If `true`, the field will be readonly. |
| `rootProps` | - | `InputGroup.RootProps` | Props for root element. |
## アクセシビリティ
現在、v2の移行に伴い、このセクションは更新中です。