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
---
import { Hero } from '@coffic/cosy-ui';
---
<Hero
title="居中对齐标题"
description="这是一个居中对齐的Hero组件示例。"
align="center"
links={[
{ text: '主要操作', href: '#', variant: 'primary' },
{ text: '次要操作', href: '#', variant: 'secondary' },
]}
/>
---
import { Hero } from '@coffic/cosy-ui';
---
<Hero
title="左对齐标题"
description="这是一个左对齐的Hero组件示例。"
align="left"
links={[
{ text: '主要操作', href: '#', variant: 'primary' },
{ text: '次要操作', href: '#', variant: 'secondary' },
]}
/>
---
import { Hero } from '@coffic/cosy-ui';
---
<Hero
title="右对齐标题"
description="这是一个右对齐的Hero组件示例。"
align="right"
links={[
{ text: '主要操作', href: '#', variant: 'primary' },
{ text: '次要操作', href: '#', variant: 'secondary' },
]}
/>
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: '#', variant: 'primary' }]}
/>
Background Styles
The Hero component supports a variety of background styles, including solid colors and rich gradients.
---
import { Hero } from '@coffic/cosy-ui';
---
<Hero
title="纯色背景"
description="这个例子使用了纯色背景样式。"
background="plain"
links={[{ text: '了解更多', href: '/about', variant: 'primary' }]}
/>
---
import { Hero } from '@coffic/cosy-ui';
---
<Hero
title="渐变色背景"
description="这个例子使用了渐变色背景样式。"
background="gradient"
links={[{ text: '了解更多', href: '/about', variant: 'primary' }]}
/>
---
import { Hero } from '@coffic/cosy-ui';
---
<Hero
title="天空渐变"
description="gradient-sky: 天空蓝紫渐变背景"
background="gradient-sky"
links={[{ text: '了解更多', href: '#', variant: 'primary' }]}
/>
---
import { Hero } from '@coffic/cosy-ui';
---
<Hero
title="日落渐变"
description="gradient-sunset: 日落橙红渐变背景"
background="gradient-sunset"
links={[{ text: '了解更多', href: '#', variant: 'primary' }]}
/>
---
import { Hero } from '@coffic/cosy-ui';
---
<Hero
title="森林渐变"
description="gradient-forest: 森林绿渐变背景"
background="gradient-forest"
links={[{ text: '了解更多', href: '#', variant: 'primary' }]}
/>
---
import { Hero } from '@coffic/cosy-ui';
---
<Hero
title="海洋渐变"
description="gradient-ocean: 海洋蓝绿渐变背景"
background="gradient-ocean"
links={[{ text: '了解更多', href: '#', variant: 'primary' }]}
/>
---
import { Hero } from '@coffic/cosy-ui';
---
<Hero
title="山脉渐变"
description="gradient-mountain: 山脉灰蓝渐变背景"
background="gradient-mountain"
links={[{ text: '了解更多', href: '#', variant: 'primary' }]}
/>
---
import { Hero } from '@coffic/cosy-ui';
---
<Hero
title="花瓣渐变"
description="gradient-flower: 花瓣粉紫渐变背景"
background="gradient-flower"
links={[{ text: '了解更多', href: '#', variant: 'primary' }]}
/>
---
import { Hero } from '@coffic/cosy-ui';
---
<Hero
title="西瓜渐变"
description="gradient-watermelon: 西瓜绿粉红渐变背景"
background="gradient-watermelon"
links={[{ text: '了解更多', href: '#', variant: 'primary' }]}
/>
---
import { Hero } from '@coffic/cosy-ui';
---
<Hero
title="柠檬渐变"
description="gradient-lemon: 柠檬黄渐变背景"
background="gradient-lemon"
links={[{ text: '了解更多', href: '#', variant: 'primary' }]}
/>
---
import { Hero } from '@coffic/cosy-ui';
---
<Hero
title="葡萄渐变"
description="gradient-grape: 葡萄紫渐变背景"
background="gradient-grape"
links={[{ text: '了解更多', href: '#', variant: 'primary' }]}
/>
---
import { Hero } from '@coffic/cosy-ui';
---
<Hero
title="蓝莓渐变"
description="gradient-blueberry: 蓝莓蓝渐变背景"
background="gradient-blueberry"
links={[{ text: '了解更多', href: '#', variant: 'primary' }]}
/>
---
import { Hero } from '@coffic/cosy-ui';
---
<Hero
title="芒果渐变"
description="gradient-mango: 芒果黄橙渐变背景"
background="gradient-mango"
links={[{ text: '了解更多', href: '#', variant: 'primary' }]}
/>
---
import { Hero } from '@coffic/cosy-ui';
---
<Hero
title="奇异果渐变"
description="gradient-kiwi: 奇异果绿渐变背景"
background="gradient-kiwi"
links={[{ text: '了解更多', href: '#', variant: 'primary' }]}
/>
---
import { Hero } from '@coffic/cosy-ui';
---
<Hero
title="火龙果渐变"
description="gradient-pitaya: 火龙果粉绿渐变背景"
background="gradient-pitaya"
links={[{ text: '了解更多', href: '#', variant: 'primary' }]}
/>
---
import { Hero } from '@coffic/cosy-ui';
---
<Hero
title="香蕉渐变"
description="gradient-banana: 香蕉黄渐变背景"
background="gradient-banana"
links={[{ text: '了解更多', href: '#', variant: 'primary' }]}
/>
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', variant: 'primary' }]}
/>
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>