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

卡片 React 组件

卡片,以及 列表视图,是包含和整理您的信息的一种绝佳方式。卡片包含独特的相关数据,例如,关于单个主题的照片、文本和链接。卡片通常是通往更复杂和详细信息的入口点。

卡片组件

以下组件已包含:

  • 卡片

卡片属性

名称类型默认值描述
colorsobject

包含 Tailwind CSS 颜色类的对象

colors.bgIosstring'bg-ios-light-surface-1 dark:bg-ios-dark-surface-1'
colors.bgMaterialstring'bg-md-light-surface-1 dark:bg-md-dark-surface-1'
colors.footerTextIosstring'text-black text-opacity-55 dark:text-white dark:text-opacity-55'
colors.footerTextMaterialstring'text-md-light-on-surface-variant dark:text-md-dark-on-surface-variant'
colors.outlineIosstring'border-black border-opacity-20 dark:border-white dark:border-opacity-20'
colors.outlineMaterialstring'border-md-light-outline dark:border-md-dark-outline'
colors.textIosstring''
colors.textMaterialstring'text-md-light-on-surface dark:text-md-dark-on-surface'
componentstring'div'

组件的 HTML 元素

contentWrapbooleantrue

使用带有填充的额外元素包裹卡片内容

contentWrapPaddingstring'p-4'

内容包装填充(如果启用了 contentWrap

footerReactNode

卡片页脚的内容

footerDividerbooleanfalse

启用页脚和内容之间的分隔线

headerReactNode

卡片标题的内容

headerDividerbooleanfalse

启用标题和内容之间的分隔线

marginstring'm-4'

Tailwind CSS 边距类

outlinebooleanundefined

使卡片轮廓。覆盖 outlineIosoutlineMaterial

outlineIosbooleanfalse

在 iOS 主题中使卡片轮廓

outlineMaterialbooleanfalse

在 Material 主题中使卡片轮廓

raisedbooleanundefined

使卡片凸起。覆盖 raisedIosraisedMaterial

raisedIosbooleanfalse

在 iOS 主题中使卡片凸起

raisedMaterialbooleanfalse

在 Material 主题中使卡片凸起

示例

Cards.jsx
import React from 'react';
import {
Page,
Navbar,
NavbarBackLink,
Card,
BlockTitle,
List,
ListItem,
Link,
Button,
} from 'konsta/react';
export default function CardsPage() {
return (
<Page>
<Navbar
title="Cards"
/>
<BlockTitle withBlock={false}>Simple Cards</BlockTitle>
<Card>
This is a simple card with plain text, but cards can also contain their
own header, footer, list view, image, or any other element.
</Card>
<Card header="Card header" footer="Card footer">
Card with header and footer. Card headers are used to display card
titles and footers for additional information or just for custom
actions.
</Card>
<Card>
Another card. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Suspendisse feugiat sem est, non tincidunt ligula volutpat sit amet.
Mauris aliquet magna justo.
</Card>
<BlockTitle withBlock={false}>Outline Cards</BlockTitle>
<Card outline>
This is a simple card with plain text, but cards can also contain their
own header, footer, list view, image, or any other element.
</Card>
<Card outline header="Card header" footer="Card footer">
Card with header and footer. Card headers are used to display card
titles and footers for additional information or just for custom
actions.
</Card>
<Card outline>
Another card. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Suspendisse feugiat sem est, non tincidunt ligula volutpat sit amet.
Mauris aliquet magna justo.{' '}
</Card>
<BlockTitle withBlock={false}>Outline With Dividers</BlockTitle>
<Card
outline
header="Card header"
footer="Card footer"
headerDivider
footerDivider
>
Card with header and footer. Card headers are used to display card
titles and footers for additional information or just for custom
actions.
</Card>
<BlockTitle withBlock={false}>Raised Cards</BlockTitle>
<Card raised>
This is a simple card with plain text, but cards can also contain their
own header, footer, list view, image, or any other element.
</Card>
<Card raised header="Card header" footer="Card footer">
Card with header and footer. Card headers are used to display card
titles and footers for additional information or just for custom
actions.
</Card>
<Card raised>
Another card. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Suspendisse feugiat sem est, non tincidunt ligula volutpat sit amet.
Mauris aliquet magna justo.{' '}
</Card>
<BlockTitle withBlock={false}>Card With List View</BlockTitle>
<Card>
<List nested className="-m-4">
<ListItem href title="Link 1" />
<ListItem href title="Link 2" />
<ListItem href title="Link 3" />
<ListItem href title="Link 4" />
<ListItem href title="Link 5" />
</List>
</Card>
<BlockTitle withBlock={false}>Styled Cards</BlockTitle>
<div className="lg:grid lg:grid-cols-2">
<Card
outline
footer={
<>
<div className="flex justify-between material:hidden">
<Link>Like</Link>
<Link>Read more</Link>
</div>
<div className="flex justify-start ios:hidden space-x-2 rtl:space-x-reverse">
<Button rounded inline>
Like
</Button>
<Button rounded inline outline>
Read more
</Button>
</div>
</>
}
>
<div
className="ios:-mx-4 ios:-mt-4 h-48 p-4 flex items-end text-white ios:font-bold bg-cover bg-center material:rounded-xl mb-4 material:text-[22px]"
style={{
backgroundImage:
'url(https://cdn.framework7.io/placeholder/nature-1000x600-3.jpg)',
}}
>
Journey To Mountains
</div>
<div className="text-gray-500 mb-3">Posted on January 21, 2021</div>
<p>
Quisque eget vestibulum nulla. Quisque quis dui quis ex ultricies
efficitur vitae non felis. Phasellus quis nibh hendrerit...
</p>
</Card>
<Card
footer={
<>
<div className="flex justify-between material:hidden">
<Link>Like</Link>
<Link>Read more</Link>
</div>
<div className="flex justify-start ios:hidden space-x-2 rtl:space-x-reverse">
<Button rounded inline>
Like
</Button>
<Button rounded inline outline>
Read more
</Button>
</div>
</>
}
>
<div
className="ios:-mx-4 ios:-mt-4 h-48 p-4 flex items-end text-white ios:font-bold bg-cover bg-center material:rounded-xl mb-4 material:text-[22px]"
style={{
backgroundImage:
'url(https://cdn.framework7.io/placeholder/people-1000x600-3.jpg)',
}}
>
Journey To Mountains
</div>
<div className="text-gray-500 mb-3">Posted on January 21, 2021</div>
<p>
Quisque eget vestibulum nulla. Quisque quis dui quis ex ultricies
efficitur vitae non felis. Phasellus quis nibh hendrerit...
</p>
</Card>
</div>
</Page>
);
}
代码许可证 MIT.
2022 © Konsta UI 由 nolimits4web.