Skip to main content

List list component

Effect demonstration

1. Only one input box

<List
header="Basic use"
items={[
{
title: "Basic title",
extra: <Input placeholder="Please enter" style={{ height: px(32) }} />,
},
{
title: `Main title Main title Main title Main title Main title Main title'< a i=3>`,
brief: "Subtitle below the main titleSubtitle below the main title",
arrow: "horizontal",
onPress: () => console.log("onPress"),
},
]}
/>
input-ios1.png

2. Set background color

<List
header="Set background color"
itemBackgroundColor="warningColor"
items={[
{
title: "Main title main label",
extra: <Input placeholder="Please enter" style={{ height: px(32) }} />,
},
{
title:
"Main title main title main title main title main title main title",
brief: "Subtitle below the main title Subtitle below the main title",
arrow: "horizontal",
onPress: () => console.log("onPress"),
},
]}
/>
input-ios1.png

3. Override the background color

<List
header="Override background color"
itemBackgroundColor="primary200"
items={[
{
title: "Main title main label",
extra: <Input placeholder="Please enter" style={{ height: px(32) }} />,
},
{
title:
"Main title main title main title main title main title main title",
brief: "Subtitle below the main title Subtitle below the main title",
backgroundColor: "primary100",
arrow: "horizontal",
onPress: () => console.log("onPress"),
},
{
title:
"Main title main title main title main title main title main title",
brief: "Subtitle below the main title Subtitle below the main title",
backgroundColor: "warningColor",
arrow: "horizontal",
onPress: () => console.log("onPress"),
},
]}
/>
input-ios1.png

4. Custom header

const CustomHeader = () => {
return (
<Box paddingHorizontal={"x2"}>
<Text variant="h3">Hello there!</Text>
</Box>
);
};
<List
header={<CustomHeader />}
items={[
{
title: "Main title main label",
extra: <Input placeholder="Please enter" style={{ height: px(32) }} />,
},
{
title:
"Main title main title main title main title main title main title",
brief: "Subtitle below the main title Subtitle below the main title",
arrow: "horizontal",
onPress: () => console.log("onPress"),
},
]}
/>;
input-ios1.png

5. Use alone ListHeader

<ListHeader text="Only title" />

6. Customize the right side of the title

<List
header="only header"
extra={<SvgIcon name="left" />}
items={[
{
title: "Main title main label",
extra: <Input placeholder="Please enter" style={{ height: px(32) }} />,
},
]}
/>

List API

PropertiesRequiredDescriptionTypeDefault Value
headerfalseheaderReactNode
extrafalseContent to the right of the titleReactNode
itemstruelist itemsListItemProps[]
itemHeightfalseList item heightnumber32Ï
itemBackgroundColorfalseSet the background color of list items uniformlyTheme Color

ListHeader API

PropertiesRequiredDescriptionTypeDefault Value
texttruetitle textstring
extrafalseContent to the right of the titleReactNode
textStylefalseTitle text styleStyleProp<TextStyle>
headerStylefalseThe style of the header containerStyleProp<ViewStyle>