--- title: DataList description: "`DataList`は、データ項目のリストを表示するために使用されます。" links: - style: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/data-list/data-list.style.ts - source: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/data-list - storybook: https://yamada-ui.github.io/yamada-ui?path=/story/components-datalist--basic --- ```tsx 白石うらら 入れ替わりの魔女 小田切寧々 虜の魔女 大塚芽子 思念(テレパシー)の魔女 猿島マリア 未来視の魔女 滝川ノア 過去視の魔女 飛鳥美琴 透明の魔女 西園寺リカ 記憶操作の魔女 ``` ## 使い方 ```tsx import { DataList } from "@yamada-ui/react" ``` ```tsx import { DataList } from "@/components/ui" ``` ```tsx import { DataList } from "@workspaces/ui" ``` ```tsx ``` ### itemsを使う ```tsx const items = useMemo( () => [ { description: "入れ替わりの魔女", term: "白石うらら" }, { description: "虜の魔女", term: "小田切寧々" }, { description: "思念(テレパシー)の魔女", term: "大塚芽子" }, { description: "未来視の魔女", term: "猿島マリア" }, { description: "過去視の魔女", term: "滝川ノア" }, { description: "透明の魔女", term: "飛鳥美琴" }, { description: "記憶操作の魔女", term: "西園寺リカ" }, ], [], ) return ``` ### バリアントを変更する ```tsx const items = useMemo( () => [ { description: "入れ替わりの魔女", term: "白石うらら" }, { description: "虜の魔女", term: "小田切寧々" }, { description: "思念(テレパシー)の魔女", term: "大塚芽子" }, { description: "未来視の魔女", term: "猿島マリア" }, { description: "過去視の魔女", term: "滝川ノア" }, { description: "透明の魔女", term: "飛鳥美琴" }, { description: "記憶操作の魔女", term: "西園寺リカ" }, ], [], ) return ( }> ) ``` ### サイズを変更する ```tsx const items = useMemo( () => [ { description: "入れ替わりの魔女", term: "白石うらら" }, { description: "虜の魔女", term: "小田切寧々" }, { description: "思念(テレパシー)の魔女", term: "大塚芽子" }, { description: "未来視の魔女", term: "猿島マリア" }, { description: "過去視の魔女", term: "滝川ノア" }, { description: "透明の魔女", term: "飛鳥美琴" }, { description: "記憶操作の魔女", term: "西園寺リカ" }, ], [], ) return ( }> ) ``` ### 方向を変更する 方向を変更する場合は、`orientation`に`"horizontal"`または`"vertical"`を設定します。デフォルトでは、`"horizontal"`が設定されています。 ```tsx const items = useMemo( () => [ { description: "入れ替わりの魔女", term: "白石うらら" }, { description: "虜の魔女", term: "小田切寧々" }, { description: "思念(テレパシー)の魔女", term: "大塚芽子" }, { description: "未来視の魔女", term: "猿島マリア" }, { description: "過去視の魔女", term: "滝川ノア" }, { description: "透明の魔女", term: "飛鳥美琴" }, { description: "記憶操作の魔女", term: "西園寺リカ" }, ], [], ) return ( }> ) ``` ### 複数の用語を表示する 複数の用語を表示する場合は、`term`に配列を設定します。 ```tsx const items = useMemo( () => [ { description: "入れ替わりの魔女", term: ["白石うらら", "清集院桃子"] }, { description: "虜の魔女", term: ["小田切寧々", "紺野つばさ"] }, { description: "思念(テレパシー)の魔女", term: ["大塚芽子", "萌黄ことり"], }, { description: "未来視の魔女", term: ["猿島マリア", "筑紫愛子"] }, { description: "過去視の魔女", term: ["滝川ノア", "姫川そら"] }, { description: "透明の魔女", term: ["飛鳥美琴", "菊池アカネ"] }, { description: "記憶操作の魔女", term: ["西園寺リカ", "虹野晴子"] }, ], [], ) return ``` ```tsx 白石うらら 清集院桃子 入れ替わりの魔女 小田切寧々 紺野つばさ 虜の魔女 大塚芽子 萌黄ことり 思念(テレパシー)の魔女 猿島マリア 筑紫愛子 未来視の魔女 滝川ノア 姫川そら 過去視の魔女 飛鳥美琴 菊池アカネ 透明の魔女 西園寺リカ 虹野晴子 記憶操作の魔女 ``` ### 複数の説明を表示する 複数の説明を表示する場合は、`description`に配列を設定します。 ```tsx const items = useMemo( () => [ { description: ["入れ替わりの魔女", "絶望的味覚音痴"], term: "白石うらら", }, { description: ["虜の魔女", "得意教科は自称全教科"], term: "小田切寧々" }, { description: ["思念(テレパシー)の魔女", "若干腐女子の気がある"], term: "大塚芽子", }, { description: ["未来視の魔女", "服のセンスが独特な弟がいる"], term: "猿島マリア", }, { description: ["過去視の魔女", "数々の問題を起こしている"], term: "滝川ノア", }, { description: ["透明の魔女", "サディストの気がある"], term: "飛鳥美琴" }, { description: ["記憶操作の魔女", "学校でもノーパンで過ごしている"], term: "西園寺リカ", }, ], [], ) return ``` ```tsx 白石うらら 入れ替わりの魔女 絶望的味覚音痴 小田切寧々 虜の魔女 得意教科は自称全教科 大塚芽子 思念(テレパシー)の魔女 若干腐女子の気がある 猿島マリア 未来視の魔女 服のセンスが独特な弟がいる 滝川ノア 過去視の魔女 数々の問題を起こしている 飛鳥美琴 透明の魔女 サディストの気がある 西園寺リカ 記憶操作の魔女 学校でもノーパンで過ごしている ``` ### 用語をカスタマイズする ```tsx const items = useMemo( () => [ { description: "入れ替わりの魔女", term: "白石うらら", termProps: { color: "blue" }, }, { description: "虜の魔女", term: "小田切寧々" }, { description: "思念(テレパシー)の魔女", term: "大塚芽子" }, { description: "未来視の魔女", term: "猿島マリア" }, { description: "過去視の魔女", term: "滝川ノア" }, { description: "透明の魔女", term: "飛鳥美琴" }, { description: "記憶操作の魔女", term: "西園寺リカ" }, ], [], ) return ( ) ``` ```tsx 白石うらら 入れ替わりの魔女 小田切寧々 虜の魔女 大塚芽子 思念(テレパシー)の魔女 猿島マリア 未来視の魔女 滝川ノア 過去視の魔女 飛鳥美琴 透明の魔女 西園寺リカ 記憶操作の魔女 ``` ### 説明をカスタマイズする ```tsx const items = useMemo( () => [ { description: "入れ替わりの魔女", term: "白石うらら", descriptionProps: { color: "blue" }, }, { description: "虜の魔女", term: "小田切寧々" }, { description: "思念(テレパシー)の魔女", term: "大塚芽子" }, { description: "未来視の魔女", term: "猿島マリア" }, { description: "過去視の魔女", term: "滝川ノア" }, { description: "透明の魔女", term: "飛鳥美琴" }, { description: "記憶操作の魔女", term: "西園寺リカ" }, ], [], ) return ( ) ``` ```tsx 白石うらら 入れ替わりの魔女 小田切寧々 虜の魔女 大塚芽子 思念(テレパシー)の魔女 猿島マリア 未来視の魔女 滝川ノア 過去視の魔女 飛鳥美琴 透明の魔女 西園寺リカ 記憶操作の魔女 ``` ## Props ### DataList.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"` | The size of the component. | | `variant` | `"subtle"` | `"bold" \| "grid" \| "subtle"` | The variant of the component. | | `descriptionProps` | - | `DataListDescriptionProps` | The props for the data list description component. | | `items` | - | `DataListItemProps[]` | If provided, generate elements based on items. | | `orientation` | `"horizontal"` | `"horizontal" \| "vertical"` | The orientation of the data list. | | `termProps` | - | `DataListTermProps` | The props for the data list term component. | ### DataList.Description | 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. | ### DataList.Item | 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. | | `description` | - | `ReactNode \| ReactNode[]` | The data list description to use. | | `descriptionProps` | - | `DataListDescriptionProps` | The props for the data list description component. | | `term` | - | `ReactNode \| ReactNode[]` | The data list term to use. | | `termProps` | - | `DataListTermProps` | The props for the data list term component. | ### DataList.Term | 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. |