Show · Card

Card

Card container can consist of titles, paragraphs, pictures, lists, and other content.

Demos

How to import

import { Card, CardGroup } from '@fibrous/semi-ui-solid';

Basic card

The basic card contains the title, content and other parts.

Semi Design
Semi Design 是由抖音前端团队与 UED 团队共同设计开发并维护的设计系统。设计系统包含设计语言以及一整套可复用的前端组件,帮助设计师与开发者更容易地打造高质量的、用户体验一致的、符合设计规范的 Web 应用。
Code
import { Card, Typography } from '@fibrous/semi-ui-solid';

export default function CardDemo() {
    return (
        <Card title="Semi Design" style={{ 'max-width': '360px' }} headerExtraContent={<Typography.Text link>更多</Typography.Text>}>
            Semi Design 是由抖音前端团队与 UED 团队共同设计开发并维护的设计系统。设计系统包含设计语言以及一整套可复用的前端组件,帮助设计师与开发者更容易地打造高质量的、用户体验一致的、符合设计规范的 Web 应用。
        </Card>
    );
}

Simple card

The card can only set the content area.

Semi Design 是由抖音前端团队与 UED 团队共同设计开发并维护的设计系统。

Card meta img
Semi Doc
Code
import { IconInfoCircle } from '@fibrous/semi-icons-solid';
import { Avatar, Card, Popover } from '@fibrous/semi-ui-solid';

const avatarSrc = '/assets/placeholder/logo.svg';
const bodyStyle = { display: 'flex', 'align-items': 'center', 'justify-content': 'space-between' };

export default function CardDemo() {
    return (
        <>
            <Card style={{ 'max-width': '360px' }}>Semi Design 是由抖音前端团队与 UED 团队共同设计开发并维护的设计系统。</Card>
            <br />
            <Card style={{ 'max-width': '360px' }} bodyStyle={bodyStyle}>
                <Card.Meta title="Semi Doc" avatar={<Avatar alt="Card meta img" size="default" src={avatarSrc} />} />
                <Popover position="top" showArrow content={<article style={{ padding: '6px' }}>这是一个 Card</article>}>
                    <IconInfoCircle aria-label="信息" style={{ color: 'var(--semi-color-primary)' }} />
                </Popover>
            </Card>
        </>
    );
}

Cover

You can use the cover property to set the cover.

example
卡片封面
Code
import { Card } from '@fibrous/semi-ui-solid';

const coverSrc = '/assets/root-web-sites/card-cover-docs-demo2.jpeg';

export default function CardDemo() {
    return (
        <Card style={{ 'max-width': '300px' }} cover={<img alt="example" src={coverSrc} />}>
            <Card.Meta title="卡片封面" />
        </Card>
    );
}

Border and line

You can use bordered to set whether the card has an outer border, the default is true. At the same time, you can also use headerLine to set whether the content area and title area have borders, and footerLine to set whether the content area and footer area have borders.

Semi Design
Semi Design 是由抖音前端团队与 UED 团队共同设计开发并维护的设计系统。设计系统包含设计语言以及一整套可复用的前端组件,帮助设计师与开发者更容易地打造高质量的、用户体验一致的、符合设计规范的 Web 应用。
Code
import { Card } from '@fibrous/semi-ui-solid';

export default function CardDemo() {
    return (
        <div style={{ display: 'inline-block', padding: '20px', 'background-color': 'var(--semi-color-fill-0)' }}>
            <Card style={{ 'max-width': '360px' }} bordered={false} headerLine title="Semi Design">
                Semi Design 是由抖音前端团队与 UED 团队共同设计开发并维护的设计系统。设计系统包含设计语言以及一整套可复用的前端组件,帮助设计师与开发者更容易地打造高质量的、用户体验一致的、符合设计规范的 Web 应用。
            </Card>
        </div>
    );
}

Shadows

You can use shadows to set the timing of the shadow display. Optional: hover (show shadow when hover), always (show shadow always), if this property is not set, there will be no shadow.

Card meta img
Semi Doc

Card meta img
Semi Doc
Code
import { IconInfoCircle } from '@fibrous/semi-icons-solid';
import { Avatar, Card, Popover } from '@fibrous/semi-ui-solid';

const avatarSrc = '/assets/placeholder/logo.svg';
const bodyStyle = { display: 'flex', 'align-items': 'center', 'justify-content': 'space-between' };

export default function CardDemo() {
    return (
        <div>
            <Card shadows="hover" style={{ 'max-width': '360px' }} bodyStyle={bodyStyle}>
                <Card.Meta title="Semi Doc" avatar={<Avatar alt="Card meta img" size="default" src={avatarSrc} />} />
                <Popover position="top" showArrow content={<article style={{ padding: '6px' }}>这是一个 Card</article>}>
                    <IconInfoCircle aria-label="信息" style={{ color: 'var(--semi-color-primary)' }} />
                </Popover>
            </Card>
            <br />
            <Card shadows="always" style={{ 'max-width': '360px' }} bodyStyle={bodyStyle}>
                <Card.Meta title="Semi Doc" avatar={<Avatar alt="Card meta img" size="default" src={avatarSrc} />} />
                <Popover position="top" showArrow content={<article style={{ padding: '6px' }}>这是一个 Card</article>}>
                    <IconInfoCircle aria-label="信息" style={{ color: 'var(--semi-color-primary)' }} />
                </Popover>
            </Card>
        </div>
    );
}

Customized content

You can use Card.Meta to support more flexible content, allowing you to set title, avatar, and description.

Card meta img
Semi Doc
全面、易用、优质
example
Semi Design 是由抖音前端团队与 UED 团队共同设计开发并维护的设计系统。
Code
import { Avatar, Button, Card, Space, Typography } from '@fibrous/semi-ui-solid';

const avatarSrc = '/assets/placeholder/logo.svg';
const coverSrc = '/assets/root-web-sites/card-cover-docs-demo.jpeg';

export default function CardDemo() {
    return (
        <Card
            style={{ 'max-width': '340px' }}
            title={<Card.Meta title="Semi Doc" description="全面、易用、优质" avatar={<Avatar alt="Card meta img" size="default" src={avatarSrc} />} />}
            headerExtraContent={<Typography.Text link>More</Typography.Text>}
            cover={<img alt="example" src={coverSrc} />}
            footerLine
            footerStyle={{ display: 'flex', 'justify-content': 'flex-end' }}
            footer={
                <Space>
                    <Button theme="borderless" type="primary">
                        精选案例
                    </Button>
                    <Button theme="solid" type="primary">
                        开始使用
                    </Button>
                </Space>
            }
        >
            Semi Design 是由抖音前端团队与 UED 团队共同设计开发并维护的设计系统。
        </Card>
    );
}

Inner card

Other cards can be nested inside the card.

Card title
Inner Card title
Inner Card content
Inner Card title
Inner Card content
Code
import { Card, Typography } from '@fibrous/semi-ui-solid';

export default function CardDemo() {
    return (
        <Card title="Card title">
            <Card title="Inner Card title" style={{ 'margin-bottom': '20px' }} headerExtraContent={<Typography.Text link>More</Typography.Text>}>
                Inner Card content
            </Card>
            <Card title="Inner Card title" headerExtraContent={<Typography.Text link>More</Typography.Text>}>
                Inner Card content
            </Card>
        </Card>
    );
}

Card in column

The system overview page is often combined with the grid.

Card Title
Card Content
Card Title
Card Content
Card Title
Card Content
Card Title
Card Content
Card Title
Card Content
Code
import { Card, Col, Row } from '@fibrous/semi-ui-solid';

export default function CardDemo() {
    return (
        <div style={{ 'background-color': 'var(--semi-color-fill-0)', padding: '20px' }}>
            <Row gutter={[16, 16]}>
                <Col span={8}>
                    <Card title="Card Title" bordered={false}>
                        Card Content
                    </Card>
                </Col>
                <Col span={8}>
                    <Card title="Card Title" bordered={false}>
                        Card Content
                    </Card>
                </Col>
                <Col span={8}>
                    <Card title="Card Title" bordered={false}>
                        Card Content
                    </Card>
                </Col>
            </Row>
            <Row gutter={[16, 16]}>
                <Col span={16}>
                    <Card title="Card Title" bordered={false}>
                        Card Content
                    </Card>
                </Col>
                <Col span={8}>
                    <Card title="Card Title" bordered={false}>
                        Card Content
                    </Card>
                </Col>
            </Row>
        </div>
    );
}

loading

You can use the loading property of Card to set whether to display placeholder elements in the card content area. When it is true, the placeholder elements will be displayed, and vice versa.




Code
import { createSignal } from 'solid-js';
import { Card, Switch } from '@fibrous/semi-ui-solid';

export default function CardDemo() {
    const [loading, setLoading] = createSignal(true);

    return (
        <>
            <Switch aria-label="显示内容" onChange={(checked) => setLoading(!checked)} />
            <br />
            <br />
            <Card style={{ 'max-width': '360px' }} loading={loading()}>
                <Card.Meta title="Semi Doc" description="全面、易用、优质" />
            </Card>
        </>
    );
}

With Skeleton

The loading property of Card can only set the preloading effect of the content area. If you want to set the preloading of other parts, or customize a richer preloading effect, you can combine it with the Skeleton component.



Code
import { createSignal } from 'solid-js';
import { Avatar, Card, Skeleton, Switch, Typography } from '@fibrous/semi-ui-solid';

const avatarSrc = '/assets/placeholder/logo.svg';
const coverSrc = '/assets/root-web-sites/card-cover-docs-demo.jpeg';

export default function CardDemo() {
    const [loading, setLoading] = createSignal(true);

    return (
        <>
            <Switch aria-label="显示内容" onChange={(checked) => setLoading(!checked)} />
            <br />
            <br />
            <Card
                style={{ 'max-width': '300px' }}
                title={
                    <Card.Meta
                        title={
                            <Skeleton style={{ width: '80px' }} placeholder={<Skeleton.Title />} loading={loading()}>
                                <Typography.Title heading={5}>Semi Doc</Typography.Title>
                            </Skeleton>
                        }
                        description={
                            <Skeleton style={{ width: '150px', 'margin-top': '12px' }} placeholder={<Skeleton.Paragraph rows={1} />} loading={loading()}>
                                <Typography.Text>全面、易用、优质</Typography.Text>
                            </Skeleton>
                        }
                        avatar={
                            <Skeleton placeholder={<Skeleton.Avatar />} loading={loading()}>
                                <Avatar alt="Card meta img" size="default" src={avatarSrc} />
                            </Skeleton>
                        }
                    />
                }
                headerExtraContent={
                    <Skeleton style={{ width: '50px' }} placeholder={<Skeleton.Paragraph rows={1} />} loading={loading()}>
                        <Typography.Text link>More</Typography.Text>
                    </Skeleton>
                }
                cover={
                    <Skeleton style={{ 'max-width': '100%', height: '220px' }} placeholder={<Skeleton.Image />} loading={loading()}>
                        <img alt="example" src={coverSrc} />
                    </Skeleton>
                }
            />
        </>
    );
}

With tabs

You can use the Tabs component in the card component.

Card title

content1

content1

content1

Code
import { Card, TabPane, Tabs } from '@fibrous/semi-ui-solid';

export default function CardDemo() {
    return (
        <Card title="Card title">
            <Tabs type="line" style={{ 'margin-top': '-20px', 'margin-bottom': '-20px' }}>
                <TabPane tab="Tab 1" itemKey="1">
                    <p>content1</p>
                    <p>content1</p>
                    <p>content1</p>
                </TabPane>
                <TabPane tab="Tab 2" itemKey="2">
                    <p>content2</p>
                    <p>content2</p>
                    <p>content2</p>
                </TabPane>
            </Tabs>
        </Card>
    );
}

Actions

actions receives an array of JSX elements, and the elements will be displayed at the bottom of the content area with a horizontal spacing of 12px.

example
Semi Doc
全面、易用、优质
Code
import { Card, Rating } from '@fibrous/semi-ui-solid';

const coverSrc = '/assets/root-web-sites/card-cover-docs-demo.jpeg';

export default function CardDemo() {
    return (
        <Card style={{ 'max-width': '300px' }} actions={[<Rating size="small" defaultValue={4} />]} headerLine={false} cover={<img alt="example" src={coverSrc} />}>
            <Card.Meta title="Semi Doc" description="全面、易用、优质" />
        </Card>
    );
}

Card group

Use CardGroup to present the cards in an evenly spaced arrangement.

滑动调节 Card 间距
1040

Card title
Card content
Card title
Card content
Card title
Card content
Card title
Card content
Card title
Card content
Card title
Card content
Card title
Card content
Card title
Card content
Code
import { For, createSignal } from 'solid-js';
import { Card, CardGroup, Slider, Typography } from '@fibrous/semi-ui-solid';

const cardIndexes = Array.from({ length: 8 }, (_, index) => index);

export default function CardDemo() {
    const [spacing, setSpacing] = createSignal(12);

    return (
        <>
            <Typography.Text id="card-group-spacing">滑动调节 Card 间距</Typography.Text>
            <Slider
                aria-labelledby="card-group-spacing"
                defaultValue={12}
                max={40}
                min={10}
                style={{ width: '360px' }}
                onChange={(value) => {
                    if (typeof value === 'number') setSpacing(value);
                }}
            />
            <br />
            <CardGroup spacing={spacing()}>
                <For each={cardIndexes}>
                    {() => (
                        <Card shadows="hover" title="Card title" headerLine={false} style={{ width: '260px' }} headerExtraContent={<Typography.Text link>More</Typography.Text>}>
                            <Typography.Text>Card content</Typography.Text>
                        </Card>
                    )}
                </For>
            </CardGroup>
        </>
    );
}

Grid card

You can use the type property of CardGroup to set the card group to a grid type.

Card title
Card content
Card title
Card content
Card title
Card content
Card title
Card content
Card title
Card content
Card title
Card content
Card title
Card content
Code
import { For } from 'solid-js';
import { Card, CardGroup, Typography } from '@fibrous/semi-ui-solid';

const cardIndexes = Array.from({ length: 7 }, (_, index) => index);

export default function CardDemo() {
    return (
        <CardGroup type="grid">
            <For each={cardIndexes}>
                {() => (
                    <Card shadows="hover" title="Card title" headerLine={false} style={{ width: '260px' }} headerExtraContent={<Typography.Text link>More</Typography.Text>}>
                        <Typography.Text>Card content</Typography.Text>
                    </Card>
                )}
            </For>
        </CardGroup>
    );
}

API reference

Card

Props

PropertyDescriptionTypeDefault
actionsActions at the bottom of the content area; each element is one action, spaced 12px apart horizontally.JSX.Element[]-
bodyStyleInline style of the content area, with CSS property names in kebab-case.JSX.CSSProperties | string-
borderedWhether the card has an outer border.booleantrue
coverCard cover, below the header.JSX.Element-
footerCustom footer at the bottom of the card.JSX.Element-
footerLineWhether there is a border between the footer and the content area.booleanfalse
footerStyleInline style of the footer area, with CSS property names in kebab-case.JSX.CSSProperties | string-
headerCustom header that replaces title and headerExtraContent.JSX.Element-
headerExtraContentExtra content to the right of the title.JSX.Element-
headerLineWhether there is a border between the header and the content area.booleantrue
headerStyleInline style of the header area, with CSS property names in kebab-case.JSX.CSSProperties | string-
loadingWhether the content area shows a loading placeholder; the root element's aria-busy is true while on.booleanfalse
shadowsWhen to show the shadow: hover or always. No shadow when unset.Shadows-
titleTitle. A string renders as a div styled like a level-6 heading and truncated with a tooltip when too long; a JSX element renders as is.JSX.Element-

class, style, ref and native attributes and events (such as id, aria-*, onClick) land on the root element (div).

CardGroup

Props

PropertyDescriptionTypeDefault
alignCross-axis alignment of the children, passed to Space: start, center, end or baseline. Defaults to center.Align-
spacingSpacing between cards, a number or [horizontal, vertical]; ignored when type is grid.number | [number, number]16
typeSet to grid for a grid layout, which overrides spacing.CardGroupType-
verticalWhether to lay out vertically, passed to Space.boolean-
wrapWhether to wrap, passed to Space; ignored when vertical.booleantrue

class, style, ref and native attributes and events land on the root element of the inner Space.

Card.Meta

Props

PropertyDescriptionTypeDefault
avatarAvatar, to the left of the title and description.JSX.Element-
descriptionDescription, below the title.JSX.Element-
titleTitle content.JSX.Element-

class, style, ref and native attributes and events land on the root element (div).

Accessibility

  • Card supports the input of aria-label or aria-labelledby to indicate the function of the Card; the root element then gets role="group" (an explicit role wins)
  • When Card loading, aria-busy will be turned on
  • A string title is styled as an h6 but rendered as a div without heading semantics, so it does not disturb the page's heading levels; pass your own heading element as title when you need one (in Vue, put it in the #title slot)
  • Card is a container-type component, and any elements inside the card need to follow their respective accessibility guidelines

Content Guidelines

  • Card title
    • Card titles should be informative and focus on the most important information
    • try to limit the title to 1 phrase or segment
    • Card titles should be written in sentence case
    • do not end with punctuation marks (except question marks)
  • Text
    • Actionable: Use imperative sentences instead of "you can" to describe the body, which better tells the user what can be done
✅ Recommended usage❌ Deprecated usage
Get order progress for detailsYou can get order progress for details
  • Always say the most important information first
  • Use "Need to" instead of "must"

Design Tokens

These are the component's internal Sass variables and cannot be overridden. To customize styles, override the --semi-* CSS variables (see the Design Token page) or write unlayered CSS rules.
Sass variableValueUsage
$color-card-bg-defaultvar(--semi-color-bg-0)卡片背景颜色
$color-card-bordervar(--semi-color-border)卡片描边颜色
$color-card_title-textvar(--semi-color-text-0)卡片标题文字颜色
$color-card_description-textvar(--semi-color-text-2)卡片描述文字颜色
$color-card_extra-textvar(--semi-color-text-0)卡片附加文字颜色
$color-card_body-textvar(--semi-color-text-1)卡片正文文字颜色
$font-card_default-fontWeight$font-weight-regular卡片文字字重 - 默认
$font-card_extra-fontWeight700卡片文字字重 - 附加文字
$font-card_title-fontWeight700卡片文字字重 - 标题
$font-card_default-lineHeight20px卡片文字行高 - 默认
$font-card_title-lineHeight22px卡片文字行高 - 标题
$font-card_default-fontSize$font-size-regular卡片文字大小 - 默认
$font-card_extra-fontSize$font-size-header-6卡片文字大小 - 附加文字
$font-card_title-fontSize$font-size-header-6卡片文字大小 - 标题
$radius-cardvar(--semi-border-radius-medium)卡片圆角
$motion-card-transition_duration300ms卡片悬浮动画时长
$width-card-border$border-thickness-control卡片描边宽度
$shadow-cardvar(--semi-shadow-elevated)卡片阴影
$spacing-card-padding$spacing-base-loose卡片内边距
$spacing-card-margin$spacing-base-loose卡片外边距
$spacing-card_avatar-marginRight$spacing-base-tight卡片头像右侧外边距
$spacing-cardGroup_card-margin-1px卡片组外边距
$z-card_hover1悬浮后卡片 zindex