woocommerce/plugins/woocommerce-admin/packages/components/src/list
Sam Seay 5354e4e856 Remove googlefonts/material icons. Migrate to @wordpress/icons and gridicons (https://github.com/woocommerce/woocommerce-admin/pull/6343) 2021-02-18 11:54:02 +13:00
..
stories Update @wordpress/base-styles and replace deprecated variables (https://github.com/woocommerce/woocommerce-admin/pull/4759) 2020-07-17 12:11:42 +12:00
test Add support for List item tags and link types (https://github.com/woocommerce/woocommerce-admin/pull/4287) 2020-05-07 11:52:49 -04:00
README.md Add option to create product by template (https://github.com/woocommerce/woocommerce-admin/pull/5892) 2021-01-25 12:52:42 -04:00
index.js Add option to create product by template (https://github.com/woocommerce/woocommerce-admin/pull/5892) 2021-01-25 12:52:42 -04:00
list-item.js Add option to create product by template (https://github.com/woocommerce/woocommerce-admin/pull/5892) 2021-01-25 12:52:42 -04:00
style.scss Remove googlefonts/material icons. Migrate to @wordpress/icons and gridicons (https://github.com/woocommerce/woocommerce-admin/pull/6343) 2021-02-18 11:54:02 +13:00

README.md

List

List component to display a list of items.

Usage

const listItems = [
	{
		title: 'List item title',
		description: 'List item description text',
	},
	{
		before: <Gridicon icon="star" />,
		title: 'List item with before icon',
		description: 'List item description text',
	},
	{
		before: <Gridicon icon="star" />,
		after: <Gridicon icon="chevron-right" />,
		title: 'List item with before and after icons',
		description: 'List item description text',
	},
	{
		title: 'Clickable list item',
		description: 'List item description text',
		onClick: () => alert( 'List item clicked' ),
	},
];

<List items={ listItems } />;

If you wanted a different format for the individual list item you can pass in a functional child:

<List items={ listItems } >
{
	(item, index) => <div className="woocommerce-list__item-inner">{item.title}</div>
}
</List>

Props

Name Type Default Description
className String null Additional class name to style the component
items Array null (required) An array of list items

items structure:

  • after: ReactNode - Content displayed after the list item text.
  • before: ReactNode - Content displayed before the list item text.
  • className: String - Additional class name to style the list item.
  • description: String - Description displayed beneath the list item title.
  • href: String - Href attribute used in a Link wrapped around the item.
  • onClick: Function - Called when the list item is clicked.
  • target: String - Target attribute used for Link wrapper.
  • title: String - Title displayed for the list item.