🔥 看看我們的新專案 t0ggles - 您終極的專案管理工具! 🔥

徽章 React 組件

徽章 React 組件表示可在列表、連結、導覽列等中使用的徽章元素。

徽章組件

包含以下組件

  • 徽章

徽章屬性

名稱類型預設值描述
colors物件

具有 Tailwind CSS 顏色類別的物件

colors.bg字串'bg-primary'

徽章背景顏色

colors.text字串'text-white'

徽章文字顏色

component字串'span'

組件的 HTML 元素

small布林值

製作小型徽章

範例

Badge.jsx
import React from 'react';
import {
Page,
Navbar,
NavbarBackLink,
Badge,
Icon,
Link,
List,
ListItem,
Tabbar,
TabbarLink,
} from 'konsta/react';
import {
PersonCircleFill,
EnvelopeFill,
Calendar,
CloudUploadFill,
} from 'framework7-icons/react';
import { MdPerson, MdEmail, MdToday, MdFileUpload } from 'react-icons/md';
import DemoIcon from '../components/DemoIcon';
export default function BadgePage() {
return (
<Page>
<Navbar
title="Badge"
right={
<Link navbar iconOnly>
<Icon
ios={<PersonCircleFill className="w-7 h-7" />}
material={<MdPerson className="w-6 h-6" />}
badge="5"
badgeColors={{ bg: 'bg-red-500' }}
/>
</Link>
}
/>
<Tabbar labels icons className="left-0 bottom-0 fixed">
<TabbarLink
active
icon={
<Icon
ios={<EnvelopeFill className="w-7 h-7" />}
material={<MdEmail className="w-6 h-6" />}
badge="5"
badgeColors={{ bg: 'bg-green-500' }}
/>
}
label="Inbox"
/>
<TabbarLink
icon={
<Icon
ios={<Calendar className="w-7 h-7" />}
material={<MdToday className="w-6 h-6" />}
badge="7"
badgeColors={{ bg: 'bg-red-500' }}
/>
}
label="Calendar"
/>
<TabbarLink
icon={
<Icon
ios={<CloudUploadFill className="w-7 h-7" />}
material={<MdFileUpload className="w-6 h-6" />}
badge="1"
badgeColors={{ bg: 'bg-red-500' }}
/>
}
label="Upload"
/>
</Tabbar>
<List strong inset>
<ListItem
media={<DemoIcon />}
title="Foo Bar"
after={<Badge colors={{ bg: 'bg-gray-500' }}>0</Badge>}
/>
<ListItem
media={<DemoIcon />}
title="Ivan Petrov"
after={<Badge>CEO</Badge>}
/>
<ListItem
media={<DemoIcon />}
title="John Doe"
after={<Badge colors={{ bg: 'bg-green-500' }}>5</Badge>}
/>
<ListItem
media={<DemoIcon />}
title="Jane Doe"
after={<Badge colors={{ bg: 'bg-yellow-500' }}>NEW</Badge>}
/>
</List>
</Page>
);
}
程式碼授權採用 MIT.
2022 © Konsta UI 由 nolimits4web.