卡片與列表視圖一樣,是包含和組織資訊的另一種好方法。卡片包含獨特的相關資料,例如,關於單一主題的照片、文字和連結。卡片通常是通往更複雜和詳細資訊的入口點。
包含以下元件
卡片
名稱 | 類型 | 預設值 | 描述 |
---|---|---|---|
colors | 物件 | 包含 Tailwind CSS 色彩類別的物件 | |
colors.bgIos | 字串 | 'bg-ios-light-surface-1 dark:bg-ios-dark-surface-1' | |
colors.bgMaterial | 字串 | 'bg-md-light-surface-1 dark:bg-md-dark-surface-1' | |
colors.footerTextIos | 字串 | 'text-black text-opacity-55 dark:text-white dark:text-opacity-55' | |
colors.footerTextMaterial | 字串 | 'text-md-light-on-surface-variant dark:text-md-dark-on-surface-variant' | |
colors.outlineIos | 字串 | 'border-black border-opacity-20 dark:border-white dark:border-opacity-20' | |
colors.outlineMaterial | 字串 | 'border-md-light-outline dark:border-md-dark-outline' | |
colors.textIos | 字串 | '' | |
colors.textMaterial | 字串 | 'text-md-light-on-surface dark:text-md-dark-on-surface' | |
component | 字串 | 'div' | 元件的 HTML 元素 |
contentWrap | 布林值 | true | 使用額外的帶有邊距的元素來包裝卡片內容 |
contentWrapPadding | 字串 | 'p-4' | 內容包裝邊距 (如果啟用 |
footer | ReactNode | 卡片頁尾的內容 | |
footerDivider | 布林值 | false | 啟用頁尾和內容之間的分隔線 |
header | ReactNode | 卡片標題的內容 | |
headerDivider | 布林值 | false | 啟用標題和內容之間的分隔線 |
margin | 字串 | 'm-4' | Tailwind CSS 邊距類別 |
outline | 布林值 | undefined | 使卡片具有外框。覆寫 |
outlineIos | 布林值 | false | 使卡片在 iOS 主題中具有外框 |
outlineMaterial | 布林值 | false | 使卡片在 Material 主題中具有外框 |
raised | 布林值 | undefined | 使卡片浮起。覆寫 |
raisedIos | 布林值 | false | 使卡片在 iOS 主題中浮起 |
raisedMaterial | 布林值 | false | 使卡片在 Material 主題中浮起 |
import React from 'react';import {Page,Navbar,NavbarBackLink,Card,BlockTitle,List,ListItem,Link,Button,} from 'konsta/react';export default function CardsPage() {return (<Page><Navbartitle="Cards"/><BlockTitle withBlock={false}>Simple Cards</BlockTitle><Card>This is a simple card with plain text, but cards can also contain theirown 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 cardtitles and footers for additional information or just for customactions.</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 theirown 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 cardtitles and footers for additional information or just for customactions.</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><Cardoutlineheader="Card header"footer="Card footer"headerDividerfooterDivider>Card with header and footer. Card headers are used to display cardtitles and footers for additional information or just for customactions.</Card><BlockTitle withBlock={false}>Raised Cards</BlockTitle><Card raised>This is a simple card with plain text, but cards can also contain theirown 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 cardtitles and footers for additional information or just for customactions.</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"><Cardoutlinefooter={<><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></>}><divclassName="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 ultriciesefficitur vitae non felis. Phasellus quis nibh hendrerit...</p></Card><Cardfooter={<><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></>}><divclassName="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 ultriciesefficitur vitae non felis. Phasellus quis nibh hendrerit...</p></Card></div></Page>);}