woocommerce/packages/js/components/src/list
Chi-Hsuan Huang 7068c78101
Fix JS lint errors (#33484)
* Fix @woocommerce/data lint errors

* Fix internal-e2e-builds lint error

* Fix lint errors
2022-06-21 16:37:34 +08:00
..
stories Moved WCA Packages 2022-03-18 14:25:26 -07:00
test Moved WCA Packages 2022-03-18 14:25:26 -07:00
README.md Moved WCA Packages 2022-03-18 14:25:26 -07:00
index.js Fix JS lint errors (#33484) 2022-06-21 16:37:34 +08:00
list-item.js Moved WCA Packages 2022-03-18 14:25:26 -07:00
style.scss Moved WCA Packages 2022-03-18 14:25:26 -07: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.