🔥 了解我们的新项目 t0ggles - 您终极的项目管理工具! 🔥

列表项 React 组件

列表项组件

包含以下组件

  • ListItem - 主列表项元素

ListItem 属性

名称类型默认值描述
afterReactNode

列表项 "after" 区域的内容

chevronbooleanundefined

如果列表项是链接,则启用引导图标。覆盖 chevronIoschevronMaterial

chevronIconReactNode

允许使用自定义图标替换默认引导图标

chevronIosbooleantrue

如果列表项是 iOS 主题中的链接,则启用引导图标

chevronMaterialbooleantrue

如果列表项是 Material 主题中的链接,则启用引导图标

colorsobject

包含 Tailwind CSS 颜色类对象的

colors.activeBgIosstring'active:bg-black active:bg-opacity-10 dark:active:bg-white dark:active:bg-opacity-10'
colors.activeBgMaterialstring''
colors.groupTitleBgIosstring'bg-ios-light-surface-variant dark:bg-ios-dark-surface-variant'
colors.groupTitleBgMaterialstring'bg-md-light-surface-2 dark:bg-md-dark-surface-2'
colors.groupTitleContactsBgIosstring'dark:bg-[#323234]'
colors.groupTitleContactsBgMaterialstring'bg-transparent dark:bg-transparent'
colors.groupTitleContactsTextMaterialstring'text-md-light-primary dark:text-md-dark-primary'
colors.groupTitleСontactsTextIosstring'text-opacity-90 dark:text-opacity-90'
colors.menuListItemActiveBgIosstring'bg-primary bg-opacity-15 dark:bg-primary'
colors.menuListItemActiveBgMaterialstring'bg-md-light-secondary-container dark:bg-md-dark-secondary-container'
colors.menuListItemActiveTextIosstring'text-primary dark:text-white'
colors.menuListItemActiveTextMaterialstring'text-md-light-on-secondary-container dark:text-md-dark-on-secondary-container'
colors.menuListItemBgIosstring'active:bg-black active:bg-opacity-10 dark:active:bg-white dark:active:bg-opacity-10'
colors.menuListItemBgMaterialstring'bg-md-light-surface-1 dark:bg-md-dark-surface-1'
colors.menuListItemTextIosstring'text-black dark:text-white'
colors.menuListItemTextMaterialstring'text-md-light-on-surface-variant dark:text-md-dark-on-surface-variant'
colors.primaryTextIosstring'text-black dark:text-white'
colors.primaryTextMaterialstring'text-md-light-on-surface dark:text-md-dark-on-surface'
colors.secondaryTextIosstring'text-black text-opacity-55 dark:text-white dark:text-opacity-55'
colors.secondaryTextMaterialstring'text-md-light-on-surface-variant dark:text-md-dark-on-surface-variant'
colors.touchRipplestring'touch-ripple-black dark:touch-ripple-white'
componentstring'li'

组件的 HTML 元素

contactsbooleanundefined

通过添加必要的额外样式类来启用联系人列表

contentChildrenReactNode

item-content 的内容

contentClassNamestring

要添加到项目 "content" 元素上的额外类

dividersbooleanundefined

在列表项之间呈现分隔线(边框)。如果未指定,则继承父列表组件的 dividers 属性值

footerReactNode

列表项 "footer" 区域的内容

groupTitlebooleanfalse

将其呈现为列表组标题

headerReactNode

列表项 "header" 区域的内容

hrefstring | boolean

列表项链接的 href 属性

innerChildrenReactNode

item-inner 的内容

innerClassNamestring

要添加到项目 "inner" 元素上的额外类

labelbooleanfalse

将项目内容呈现为 <label> 元素。用于创建单选/复选框列表项

linkbooleanfalse

将列表项呈现为链接 (<a>)

linkComponentstring'a'

列表项链接 HTML 元素

linkPropsany

包含要传递给链接/按钮的额外属性(属性)的对象

mediaReactNode

列表项 "media" 区域的内容

mediaClassNamestring

要添加到项目 "media" 元素上的额外类

menuListItemboolean

将列表项呈现为菜单列表项(与 <MenuListItem> 相同)

menuListItemActivebooleanfalse

使菜单列表项突出显示(活动)(与 <MenuListItem active> 相同)

strongTitleboolean | 'auto'

使项目标题变为粗体。当 'auto' 时,如果也指定了 subtitletext,它将使其变为粗体

subtitleReactNode

列表项 "subtitle" 区域的内容

targetstring

列表项链接的 target 属性

textReactNode

列表项 "text" 区域的内容

titleReactNode

列表项 "title" 区域的内容

titleFontSizeIosstring'text-[17px]'

iOS 主题中项目标题字体的 Tailwind CSS 类

titleFontSizeMaterialstring'text-[16px]'

Material 主题中项目标题字体的 Tailwind CSS 类

titleWrapClassNamestring

要添加到项目 "titleWrap" 元素上的额外类

touchRipplebooleantrue

在 Material 主题中启用触摸波纹效果

示例

List.jsx
import React from 'react';
import {
Page,
Navbar,
NavbarBackLink,
Badge,
Block,
BlockTitle,
List,
ListGroup,
ListItem,
} from 'konsta/react';
import DemoIcon from '../components/DemoIcon';
export default function ListPage() {
return (
<Page>
<Navbar
title="List"
/>
<BlockTitle>Simple List</BlockTitle>
<List>
<ListItem title="Item 1" />
<ListItem title="Item 2" />
<ListItem title="Item 3" />
</List>
<BlockTitle>Strong List</BlockTitle>
<List strong>
<ListItem title="Item 1" />
<ListItem title="Item 2" />
<ListItem title="Item 3" />
</List>
<BlockTitle>Strong Outline List</BlockTitle>
<List strong outline>
<ListItem title="Item 1" />
<ListItem title="Item 2" />
<ListItem title="Item 3" />
</List>
<BlockTitle>Strong Inset List</BlockTitle>
<List strong inset>
<ListItem title="Item 1" />
<ListItem title="Item 2" />
<ListItem title="Item 3" />
</List>
<BlockTitle>Strong Outline Inset List</BlockTitle>
<List strong outline inset>
<ListItem title="Item 1" />
<ListItem title="Item 2" />
<ListItem title="Item 3" />
</List>
<BlockTitle>Simple Links List</BlockTitle>
<List strongIos outlineIos>
<ListItem title="Link 1" link />
<ListItem title="Link 2" link />
<ListItem title="Link 3" link />
</List>
<BlockTitle>Data list, with icons</BlockTitle>
<List strongIos outlineIos>
<ListItem media={<DemoIcon />} title="Ivan Petrov" after="CEO" />
<ListItem
title="John Doe"
media={<DemoIcon />}
after={<Badge>5</Badge>}
/>
<ListItem media={<DemoIcon />} title="Jenna Smith" />
</List>
<BlockTitle>Links</BlockTitle>
<List strongIos outlineIos>
<ListItem media={<DemoIcon />} link title="Ivan Petrov" after="CEO" />
<ListItem media={<DemoIcon />} link title="John Doe" after="Cleaner" />
<ListItem media={<DemoIcon />} link title="Jenna Smith" />
</List>
<BlockTitle>Links, Header, Footer</BlockTitle>
<List strongIos outlineIos>
<ListItem
media={<DemoIcon />}
link
header="Name"
title="John Doe"
after="Edit"
/>
<ListItem
media={<DemoIcon />}
link
header="Phone"
title="+7 90 111-22-3344"
after="Edit"
/>
<ListItem
link
header="Email"
title="john@doe"
footer="Home"
after="Edit"
media={<DemoIcon />}
/>
<ListItem
link
header="Email"
title="john@konsta"
footer="Work"
after="Edit"
media={<DemoIcon />}
/>
</List>
<BlockTitle>Links, no icons</BlockTitle>
<List strongIos outlineIos>
<ListItem link title="Ivan Petrov" />
<ListItem link title="John Doe" />
<ListItem groupTitle title="Group title here" />
<ListItem link title="Ivan Petrov" />
<ListItem link title="Jenna Smith" />
</List>
<BlockTitle>Grouped with sticky titles</BlockTitle>
<List strongIos outlineIos>
<ListGroup>
<ListItem
title="A"
groupTitle
className="ios:top-11-safe material:top-16-safe sticky"
/>
<ListItem title="Aaron " />
<ListItem title="Abbie" />
<ListItem title="Adam" />
</ListGroup>
<ListGroup>
<ListItem
title="B"
groupTitle
className="ios:top-11-safe material:top-16-safe sticky"
/>
<ListItem title="Bailey" />
<ListItem title="Barclay" />
<ListItem title="Bartolo" />
</ListGroup>
<ListGroup>
<ListItem
title="C"
groupTitle
className="ios:top-11-safe material:top-16-safe sticky"
/>
<ListItem title="Caiden" />
<ListItem title="Calvin" />
<ListItem title="Candy" />
</ListGroup>
</List>
<BlockTitle className="text-2xl">Media Lists</BlockTitle>
<Block>
<p>
Media Lists are almost the same as Data Lists, but with a more
flexible layout for visualization of more complex data, like products,
services, user, etc.
</p>
</Block>
<BlockTitle>Songs</BlockTitle>
<List strongIos outlineIos>
<ListItem
link
chevronMaterial={false}
title="Yellow Submarine"
after="$15"
subtitle="Beatles"
text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
media={
<img
className="ios:rounded-lg material:rounded-full ios:w-20 material:w-10"
src="https://cdn.framework7.io/placeholder/people-160x160-1.jpg"
width="80"
alt="demo"
/>
}
/>
<ListItem
link
chevronMaterial={false}
title="Don't Stop Me Now"
after="$22"
subtitle="Queen"
text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
media={
<img
className="ios:rounded-lg material:rounded-full ios:w-20 material:w-10"
src="https://cdn.framework7.io/placeholder/people-160x160-2.jpg"
width="80"
alt="demo"
/>
}
/>
<ListItem
link
chevronMaterial={false}
title="Billie Jean"
after="$16"
subtitle="Michael Jackson"
text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
media={
<img
className="ios:rounded-lg material:rounded-full ios:w-20 material:w-10"
src="https://cdn.framework7.io/placeholder/people-160x160-3.jpg"
width="80"
alt="demo"
/>
}
/>
</List>
<BlockTitle>Mail App</BlockTitle>
<List strongIos outlineIos>
<ListItem
link
chevronMaterial={false}
title="Facebook"
after="17:14"
subtitle="New messages from John Doe"
text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
/>
<ListItem
link
chevronMaterial={false}
title="John Doe (via Twitter)"
after="17:11"
subtitle="John Doe (@_johndoe) mentioned you on Twitter!"
text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
/>
<ListItem
link
chevronMaterial={false}
title="Facebook"
after="16:48"
subtitle="New messages from John Doe"
text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
/>
<ListItem
link
chevronMaterial={false}
title="John Doe (via Twitter)"
after="15:32"
subtitle="John Doe (@_johndoe) mentioned you on Twitter!"
text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
/>
</List>
</Page>
);
}
代码许可证 MIT.
2022 © Konsta UI 由 nolimits4web.