Hero
Basic Usage
The simplest Hero area display, containing title, description, and call-to-action button
Alignment
The Hero component supports left-aligned, centered, and right-aligned content
Usage with Images
Make the Hero area more vibrant by adding images. Images can be positioned in different locations.
---
import { Hero } from '@coffic/cosy-ui';
import { getExampleImage } from '@coffic/cosy-ui';
const image = {
src: getExampleImage({ width: 400, height: 300, provider: 'picsum' }),
alt: '示例图片',
};
---
<Hero
title="带图片的Hero"
description="这是一个带有图片的Hero组件示例。"
image={image}
links={[{ text: '查看详情', href: '#' }]}
/>
Background Styles
The Hero component supports different background styles, including solid colors and gradients.
Background Images
Adding background images can make the Hero area more attractive. Different overlay effects can also be added.
---
import { Hero } from '@coffic/cosy-ui';
import { getLandscapeImage } from '@coffic/cosy-ui';
---
<Hero
title="背景图片"
description="使用背景图片增强视觉效果。"
backgroundImage={getLandscapeImage({
width: 800,
height: 400,
provider: 'picsum',
})}
backgroundOverlay="dark"
links={[{ text: '了解更多', href: '/about' }]}
/>
Usage with Custom Content
Add custom content through slots to achieve richer display effects
带自定义按钮的Hero
这是一个带有自定义按钮的Hero组件示例。
---
import { Hero } from '@coffic/cosy-ui';
import { Button } from '@coffic/cosy-ui';
---
<Hero
title="带自定义按钮的Hero"
description="这是一个带有自定义按钮的Hero组件示例。"
links={[]}>
<div slot="app" class="cosy:flex cosy:gap-4">
<Button variant="primary">主要操作</Button>
<Button variant="secondary">次要操作</Button>
</div>
</Hero>