From ab1c307e93e4952990b05e931bd80bf3a53f35ee Mon Sep 17 00:00:00 2001 From: Sarah Date: Tue, 5 Sep 2023 14:48:27 -0700 Subject: [PATCH] [joy-ui][docs] Revise the Lists page (#36324) Signed-off-by: Siriwat K Signed-off-by: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Co-authored-by: siriwatknp Co-authored-by: Sam Sycamore <71297412+samuelsycamore@users.noreply.github.com> Co-authored-by: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> --- .../components/autocomplete/autocomplete.md | 2 +- docs/data/joy/components/list/list.md | 228 +++++++++++------- docs/data/joy/components/menu/menu-pt.md | 2 +- docs/data/joy/components/menu/menu-zh.md | 2 +- docs/data/joy/components/menu/menu.md | 2 +- 5 files changed, 142 insertions(+), 94 deletions(-) diff --git a/docs/data/joy/components/autocomplete/autocomplete.md b/docs/data/joy/components/autocomplete/autocomplete.md index 76752ae8c694ce..5368acaf2b8b82 100644 --- a/docs/data/joy/components/autocomplete/autocomplete.md +++ b/docs/data/joy/components/autocomplete/autocomplete.md @@ -173,7 +173,7 @@ You could also display a dialog when the user wants to add a new value. {{"demo": "FreeSoloCreateOptionDialog.js"}} :::info -The `AutocompleteOption` uses the same styles and variables as [`ListItemButton`](/joy-ui/react-list/#actionable), so that you get the same customization experience. +The `AutocompleteOption` uses the same styles and variables as [`ListItemButton`](/joy-ui/react-list/#interactive-list-items), so that you get the same customization experience. ::: ### Validation diff --git a/docs/data/joy/components/list/list.md b/docs/data/joy/components/list/list.md index 5ebd9217aa5757..3d641b86a6a0d2 100644 --- a/docs/data/joy/components/list/list.md +++ b/docs/data/joy/components/list/list.md @@ -7,108 +7,151 @@ githubLabel: 'component: list' # Lists -

Lists are continuous, vertical indexes of text or images.

+

Lists are organizational tools that enhance the readability and organization of content.

## Introduction -Joy UI provides four list-related components: +Lists present information in a concise, easy-to-follow format through a continuous, vertical index of text or images. -- [`List`](#basic-usage): A wrapper for list items (defaulting as `ul`). -- [`ListItem`](#basic-usage): A common list item (default as `li`). -- [`ListItemButton`](#actionable): An action element to be used inside a list item. -- [`ListItemDecorator`](#decorator): A decorator of a list item, usually used to display an icon. -- [`ListItemContent`](#ellipsis-content): A container inside a list item, used to display text content. -- [`ListDivider`](#divider): A separator between list items. -- [`ListSubheader`](#nested-list): A label for a nested list. +Joy UI Lists are implemented using a collection of related components: -{{"demo": "ListUsage.js", "hideToolbar": true, "bg": "gradient"}} +- [List](#basics) - a wrapper for list items. Renders as a `
    ` by default. +- [List Item](#basics) - a common list item. Renders as an `
  • ` by default. +- [List Item Button](#interactive-list-items) - an action element to be used inside a list item. +- [List Item Decorator](#decorators) - a decorator of a list item, usually used to display an icon. +- [List Item Content](#ellipsis-content) - a container inside a list item, used to display text content. +- [List Divider](#divider) - a separator between list items. +- [List Subheader](#nested-list) - a label for a nested list. -## Component +{{"demo": "ListUsage.js", "hideToolbar": true, "bg": "gradient"}} -After [installation](/joy-ui/getting-started/installation/), you can start building with this component using the following basic elements: +## Basics ```jsx import List from '@mui/joy/List'; import ListItem from '@mui/joy/ListItem'; - -export default function MyApp() { - return ( - - Hello, world! - Bye bye, world! - - ); -} ``` -### Basic usage +## Customization -Use the `List` and `ListItem` components to create a basic, non-interactive, list. -Make sure to use a meaningful name that describe the content of the list in the `aria-labelledby` prop. +### Variants -{{"demo": "BasicList.js"}} +The List component supports Joy UI's four [global variants](/joy-ui/main-features/global-variants/): `solid`, `soft`, `outlined`, and `plain`. ### Sizes -Use the `size` prop to control font-size and general list density. +The List component comes in three sizes: `sm`, `md`, and `lg`. +The size of the List determines its font size and density. {{"demo": "SizesList.js"}} :::info -To learn how to add more sizes to the component, check out [Themed components—Extend sizes](/joy-ui/customization/themed-components/#extend-sizes). +To learn how to add custom sizes to the component, check out [Themed components—Extend sizes](/joy-ui/customization/themed-components/#extend-sizes). ::: -### Decorator +### Colors -Use the `ListItemDecorator` component to add supporting icons or elements to the list item. +Every palette included in the theme is available via the `color` prop. -It comes with a minimum set width that you can adjust via the `--ListItemDecorator-size` CSS variable within the `List` component. +### Decorators + +```jsx +import ListItemDecorator from '@mui/joy/ListItemDecorator'; +``` + +Use the List Item Decorator component to add supporting icons or elements to the list item. {{"demo": "DecoratedList.js"}} +:::info +The List Item Decorator comes with a minimum set width that can be adjusted using the `--list-decorator-size` CSS variable within the List component. +::: + +### Horizontal list + +Use the `orientation="horizontal"` prop on the List component to display the List horizontally. + +{{"demo": "HorizontalList.js"}} + +:::warning +While nested lists will not work in a horizontal direction, you can create a custom pop-up component to achieve a similar effect (see the [Navigation menu](#navigation-menu) example). +::: + +### Semantic elements + +Use the `component` prop to control which HTML tag is rendered. + +```js + +``` + +The example below renders the List component as an HTML `