Product card
ui-productive-card และ ui-expressive-card คือ ProductiveCard และ ExpressiveCard ของ Carbon for IBM Products เป็น card ที่ตั้งค่าด้วย attribute ไม่ได้ประกอบจาก part เป็น card รุ่นเก่า (legacy) ของ IBM Products ที่เก็บไว้สำหรับหน้าจอที่ต้องเหมือน UI ของผลิตภัณฑ์ IBM งานใหม่ให้ใช้ Card ซึ่งเป็น card แบบประกอบจาก part ของ Carbon และเป็นทิศทางที่ทั้ง Carbon และ IBM Products กำลังไป
สัญญารอตรวจ 14 ฉบับ เกินกำหนด 2 ฉบับ
HTMLReactReact + Tailwind<ui-productive-card label="แผนก" heading="ฝ่ายกฎหมาย" description="6 คน" primary-button-text="ดูทีม" style="max-width: 360px">
<ui-icon-button slot="actions" label="แก้ไข"><svg viewBox="0 0 16 16"><path d="M1 13h14v1H1zM12.7 4.5 10.5 2.3a1 1 0 0 0-1.4 0L3 8.4V11h2.6l6.1-6.1a1 1 0 0 0 0-1.4zM5.2 10H4V8.8l4-4 1.2 1.2zm4.7-4.7L8.7 4.1l1.1-1.1L11 4.2z" /></svg></ui-icon-button>
สัญญารอตรวจ 14 ฉบับ เกินกำหนด 2 ฉบับ
</ui-productive-card>
<UiProductiveCard label="แผนก" heading="ฝ่ายกฎหมาย" description="6 คน" primaryButtonText="ดูทีม" style={{ maxWidth: 360 }}>
<UiIconButton slot="actions" label="แก้ไข">{editIcon}</UiIconButton>
สัญญารอตรวจ 14 ฉบับ เกินกำหนด 2 ฉบับ
</UiProductiveCard>
<ProductiveCard
label="แผนก"
title="ฝ่ายกฎหมาย"
description="6 คน"
primaryButtonText="ดูทีม"
actionIcons={[{ id: 'edit', icon: editIcon, iconDescription: 'แก้ไข' }]}
className="max-w-[360px]"
>
สัญญารอตรวจ 14 ฉบับ เกินกำหนด 2 ฉบับ
</ProductiveCard>
ติดตั้ง
npmshadcn · Web componentshadcn · React + Tailwindคัดลอกเองnpm install @purpurabog/ui
npx shadcn@4 add @kanok-ui/product-card
npx shadcn@4 add @kanok-ui/tw-product-card
# Web component
# 1. ติดตั้ง dependency
npm install lit@^3.3.0
# 2. คัดลอก "content" ของแต่ละไฟล์จาก
# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/product-card.json
# ไปไว้ที่ target ของมัน:
# components/ui/primitives/product-card/expressive-card.ts
# components/ui/primitives/product-card/product-card-shared.ts
# components/ui/primitives/product-card/product-card.ts
# components/ui/primitives/product-card/productive-card.ts
# 3. ทำแบบเดียวกันกับ item ที่มันใช้ (registry/<name>.json):
# button, core-product-card, icon-button, layer, menu, overflow-menu, shared-element, shared-localize, shared-slots, tokens
# React + Tailwind
# 1. ติดตั้ง dependency
npm install @purpurabog/ui@^2.3.0
# 2. คัดลอก "content" ของแต่ละไฟล์จาก
# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/tw-product-card.json
# ไปไว้ที่ target ของมัน:
# components/ui/react-tw/product-card.tsx
# 3. ทำแบบเดียวกันกับ item ที่มันใช้ (registry/<name>.json):
# core-product-card, tw-button, tw-i18n, tw-icon-button, tw-layer, tw-menu, tw-theme, tw-utils
npm ให้ทุก component จากแพ็กเกจ ส่วน shadcn คัดลอกซอร์สเข้าแอปของคุณแทน เป็นสำเนาที่ล็อกเวอร์ชันนี้และแก้เองได้ คำสั่ง shadcn ต้องตั้ง registry @kanok-ui ใน components.json ครั้งเดียวก่อน ดู ติดตั้ง
วิธีใช้
card ทั้งสองแบบโหลดจาก module เดียว
HTMLReactReact + Tailwind<script type="module">import '@purpurabog/ui/product-card';</script>
<ui-productive-card heading="ฝ่ายกฎหมาย" description="6 คน">สัญญารอตรวจ 14 ฉบับ</ui-productive-card>
import { UiProductiveCard, UiExpressiveCard } from '@purpurabog/ui/react';
<UiProductiveCard heading="ฝ่ายกฎหมาย" description="6 คน">สัญญารอตรวจ 14 ฉบับ</UiProductiveCard>
import { ProductiveCard, ExpressiveCard } from '@/components/ui/react-tw/product-card';
<ProductiveCard title="ฝ่ายกฎหมาย" description="6 คน">สัญญารอตรวจ 14 ฉบับ</ProductiveCard>
บน element หัวข้อชื่อ heading (เพราะ title คือ tooltip ของทุก element อยู่แล้ว) ส่วน React + Tailwind ใช้ title เหมือน Carbon
Productive, Expressive หรือ Card?
| Component |
ใช้เมื่อ |
ui-productive-card |
หน้าจอผลิตภัณฑ์ที่แน่นและต้องเหมือน IBM Products: หัวข้อกะทัดรัด ปุ่มไอคอนเล็กหรือ overflow menu ปุ่มแบบ ghost |
ui-expressive-card |
card เนื้อหาที่ต้องเหมือน IBM Products: รูป pictogram หัวข้อใหญ่กว่า ปุ่ม primary และ secondary |
| Card |
งานใหม่ทั้งหมด ประกอบจาก part และเป็นทิศทางของ Carbon |
ปุ่มไอคอน
ปุ่มไอคอนใส่ใน slot actions (React + Tailwind ใช้ actionIcons) ใส่ label ให้ทุกปุ่ม card จะทำให้เป็นปุ่ม ghost และตั้งขนาดให้ ด้านบนเป็นขนาดเล็ก ด้านล่างเป็นขนาดกลาง แต่ละปุ่มเป็นจุดหยุดของ Tab แยกกัน
สาขาสีลม ชั้นสอง ผู้รับเหมาเริ่มงาน 1 พฤศจิกายน
กดแล้ว:
HTMLReactReact + Tailwind<ui-productive-card id="product-card-icons" heading="ปรับปรุงสาขา" description="ครบกำหนดใน 3 วัน" style="max-width: 360px">
<ui-icon-button slot="actions" label="แก้ไข"><svg viewBox="0 0 16 16"><path d="M1 13h14v1H1zM12.7 4.5 10.5 2.3a1 1 0 0 0-1.4 0L3 8.4V11h2.6l6.1-6.1a1 1 0 0 0 0-1.4zM5.2 10H4V8.8l4-4 1.2 1.2zm4.7-4.7L8.7 4.1l1.1-1.1L11 4.2z" /></svg></ui-icon-button>
<ui-icon-button slot="actions" label="ลบ"><svg viewBox="0 0 16 16"><path d="M6 6h1v6H6zm3 0h1v6H9zM2 3v1h1v10a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V4h1V3zm2 11V4h8v10zM6 1h4v1H6z" /></svg></ui-icon-button>
สาขาสีลม ชั้นสอง ผู้รับเหมาเริ่มงาน 1 พฤศจิกายน
</ui-productive-card>
<p>กดแล้ว: <output id="product-card-icons-out">ยังไม่มี</output></p>
<script type="module">
const out = document.getElementById('product-card-icons-out');
for (const button of document.querySelectorAll('#product-card-icons ui-icon-button')) {
button.addEventListener('click', () => (out.value = button.label));
}
</script>
<UiProductiveCard heading="ปรับปรุงสาขา" description="ครบกำหนดใน 3 วัน">
<UiIconButton slot="actions" label="แก้ไข" onClick={edit}>{editIcon}</UiIconButton>
<UiIconButton slot="actions" label="ลบ" onClick={remove}>{trashIcon}</UiIconButton>
สาขาสีลม ชั้นสอง ผู้รับเหมาเริ่มงาน 1 พฤศจิกายน
</UiProductiveCard>
<ProductiveCard
title="ปรับปรุงสาขา"
description="ครบกำหนดใน 3 วัน"
actionIcons={[
{ id: 'edit', icon: editIcon, iconDescription: 'แก้ไข', onClick: edit },
{ id: 'delete', icon: trashIcon, iconDescription: 'ลบ', onClick: remove },
]}
>
สาขาสีลม ชั้นสอง ผู้รับเหมาเริ่มงาน 1 พฤศจิกายน
</ProductiveCard>
productive card แสดงปุ่มเป็น overflow menu แทนได้ ใส่ ui-menu-item ใน slot overflow (React + Tailwind ใช้ overflowActions) เมื่อมีรายการในเมนู มันจะแทนที่ปุ่มไอคอน ปุ่มเมนูมีชื่อว่า "ตัวเลือก" (แปลตามภาษา) เปลี่ยนได้ด้วย overflow-aria-label เลือกรายการแล้วจะยิง ui-select ซึ่ง bubble ขึ้นมาถึง card
HTMLReactReact + Tailwind<ui-productive-card id="product-card-menu" heading="สัญญาซื้อขาย C-2026-014" description="โรงงานเชียงใหม่" overflow-aria-label="การกระทำกับสัญญา" style="max-width: 360px">
<ui-menu-item slot="overflow" label="ทำสำเนา"></ui-menu-item>
<ui-menu-item slot="overflow" label="ส่งให้ลงนาม"></ui-menu-item>
<ui-menu-item slot="overflow" label="ลบ" kind="danger"></ui-menu-item>
วัสดุบรรจุภัณฑ์ ส่งทุกเดือน ถึงธันวาคม 2570
</ui-productive-card>
<p>เลือกแล้ว: <output id="product-card-menu-out">ยังไม่มี</output></p>
<script type="module">
const card = document.getElementById('product-card-menu');
const out = document.getElementById('product-card-menu-out');
card.addEventListener('ui-select', (event) => (out.value = event.detail.label));
</script>
<UiProductiveCard heading="สัญญาซื้อขาย C-2026-014" description="โรงงานเชียงใหม่" overflowAriaLabel="การกระทำกับสัญญา">
<UiMenuItem slot="overflow" label="ทำสำเนา" onUiSelect={duplicate} />
<UiMenuItem slot="overflow" label="ส่งให้ลงนาม" onUiSelect={send} />
<UiMenuItem slot="overflow" label="ลบ" kind="danger" onUiSelect={remove} />
วัสดุบรรจุภัณฑ์ ส่งทุกเดือน ถึงธันวาคม 2570
</UiProductiveCard>
<ProductiveCard
title="สัญญาซื้อขาย C-2026-014"
description="โรงงานเชียงใหม่"
overflowAriaLabel="การกระทำกับสัญญา"
overflowActions={[
{ id: 'duplicate', itemText: 'ทำสำเนา', onClick: duplicate },
{ id: 'send', itemText: 'ส่งให้ลงนาม', onClick: send },
{ id: 'delete', itemText: 'ลบ', kind: 'danger', onClick: remove },
]}
>
วัสดุบรรจุภัณฑ์ ส่งทุกเดือน ถึงธันวาคม 2570
</ProductiveCard>
ปุ่มด้านล่าง
actions-placement="bottom" ย้ายปุ่มไอคอน (หรือเมนู) ลงไปที่ footer เป็นขนาดกลาง ถ้ามีปุ่ม primary อยู่ด้วย ปุ่มจะอยู่ด้านหน้าและไอคอนอยู่ด้านท้าย
ลงนามแล้ว 48 ฉบับ หมดอายุใน 30 วันข้างหน้า 5 ฉบับ
HTMLReactReact + Tailwind<ui-productive-card heading="สรุปสัญญาประจำเดือน" description="กันยายน 2569" actions-placement="bottom" primary-button-text="ดูรายงาน" style="max-width: 360px">
<ui-icon-button slot="actions" label="ดาวน์โหลด"><svg viewBox="0 0 16 16"><path d="M13 12v2H3v-2H2v2a1 1 0 0 0 1 1h10a1 1 0 0 0 1-1v-2zM13 7l-.7-.7-3.8 3.8V1h-1v9.1L3.7 6.3 3 7l5 5z" /></svg></ui-icon-button>
ลงนามแล้ว 48 ฉบับ หมดอายุใน 30 วันข้างหน้า 5 ฉบับ
</ui-productive-card>
<UiProductiveCard heading="สรุปสัญญาประจำเดือน" description="กันยายน 2569" actionsPlacement="bottom" primaryButtonText="ดูรายงาน">
<UiIconButton slot="actions" label="ดาวน์โหลด">{downloadIcon}</UiIconButton>
ลงนามแล้ว 48 ฉบับ หมดอายุใน 30 วันข้างหน้า 5 ฉบับ
</UiProductiveCard>
<ProductiveCard
title="สรุปสัญญาประจำเดือน"
description="กันยายน 2569"
actionsPlacement="bottom"
primaryButtonText="ดูรายงาน"
actionIcons={[{ id: 'download', icon: downloadIcon, iconDescription: 'ดาวน์โหลด' }]}
>
ลงนามแล้ว 48 ฉบับ หมดอายุใน 30 วันข้างหน้า 5 ฉบับ
</ProductiveCard>
ปุ่ม
primary-button-text และ secondary-button-text เพิ่มปุ่ม บน productive card ทั้งสองเป็นปุ่ม ghost ค่าเริ่มต้นอยู่ใน footer primary-button-placement="top" ย้ายปุ่ม primary ไปอยู่ข้างปุ่มด้านบนเป็นปุ่ม ghost ขนาดเล็ก secondary-button-placement="top" ทำแบบเดียวกันกับปุ่ม secondary แต่เฉพาะเมื่อมีปุ่มอื่นอยู่ด้านบนแล้ว เหมือน Carbon กดแล้วยิง ui-primary-button-click หรือ ui-secondary-button-click
ซื้อแล็ปท็อป 20 เครื่องให้ฝ่ายการเงิน 640,000 บาท
ต่อสัญญาทำความสะอาด 12 เดือน
กดแล้ว:
HTMLReactReact + Tailwind<ui-productive-card id="product-card-buttons" heading="คำขออนุมัติ" description="จาก มาลี ส." primary-button-text="อนุมัติ" secondary-button-text="ปฏิเสธ" style="max-width: 360px">
ซื้อแล็ปท็อป 20 เครื่องให้ฝ่ายการเงิน 640,000 บาท
</ui-productive-card>
<ui-productive-card id="product-card-top" heading="คำขออนุมัติ" description="จาก สมชาย ก." primary-button-text="อนุมัติ" primary-button-placement="top" style="max-width: 360px">
ต่อสัญญาทำความสะอาด 12 เดือน
</ui-productive-card>
<p>กดแล้ว: <output id="product-card-buttons-out">ยังไม่มี</output></p>
<script type="module">
const out = document.getElementById('product-card-buttons-out');
for (const id of ['product-card-buttons', 'product-card-top']) {
const card = document.getElementById(id);
card.addEventListener('ui-primary-button-click', () => (out.value = `${card.description}: อนุมัติ`));
card.addEventListener('ui-secondary-button-click', () => (out.value = `${card.description}: ปฏิเสธ`));
}
</script>
<UiProductiveCard heading="คำขออนุมัติ" description="จาก มาลี ส." primaryButtonText="อนุมัติ" secondaryButtonText="ปฏิเสธ" onUiPrimaryButtonClick={approve} onUiSecondaryButtonClick={reject}>
ซื้อแล็ปท็อป 20 เครื่องให้ฝ่ายการเงิน 640,000 บาท
</UiProductiveCard>
<UiProductiveCard heading="คำขออนุมัติ" description="จาก สมชาย ก." primaryButtonText="อนุมัติ" primaryButtonPlacement="top" onUiPrimaryButtonClick={approve}>
ต่อสัญญาทำความสะอาด 12 เดือน
</UiProductiveCard>
<ProductiveCard title="คำขออนุมัติ" description="จาก มาลี ส." primaryButtonText="อนุมัติ" secondaryButtonText="ปฏิเสธ" onPrimaryButtonClick={approve} onSecondaryButtonClick={reject}>
ซื้อแล็ปท็อป 20 เครื่องให้ฝ่ายการเงิน 640,000 บาท
</ProductiveCard>
<ProductiveCard title="คำขออนุมัติ" description="จาก สมชาย ก." primaryButtonText="อนุมัติ" primaryButtonPlacement="top" onPrimaryButtonClick={approve}>
ต่อสัญญาทำความสะอาด 12 เดือน
</ProductiveCard>
primary-button-disabled และ secondary-button-disabled ปิดใช้งานปุ่ม
ปุ่มที่เป็นลิงก์และไอคอนในปุ่ม
primary-button-href และ secondary-button-href ทำให้ปุ่มใน footer เป็นลิงก์ (ปุ่ม primary ด้านบนรับ href ไม่ได้ เหมือน Carbon) ไอคอน 16px หลังข้อความใส่ใน slot primary-button-icon หรือ secondary-button-icon (React + Tailwind ใช้ primaryButtonIcon, secondaryButtonIcon)
ใครอนุมัติการจัดซื้อได้ และได้ถึงวงเงินเท่าไร
HTMLReactReact + Tailwind<ui-productive-card heading="ระเบียบการจัดซื้อ" description="ฉบับที่ 4 ปี 2569" primary-button-text="อ่านระเบียบ" primary-button-href="#accessibility" style="max-width: 360px">
<svg slot="primary-button-icon" viewBox="0 0 16 16" aria-hidden="true"><path d="M9.3 3.7 13.1 7.5H1v1h12.1l-3.8 3.8.7.7 5-5-5-5z" /></svg>
ใครอนุมัติการจัดซื้อได้ และได้ถึงวงเงินเท่าไร
</ui-productive-card>
<UiProductiveCard heading="ระเบียบการจัดซื้อ" description="ฉบับที่ 4 ปี 2569" primaryButtonText="อ่านระเบียบ" primaryButtonHref="/policies/procurement">
<svg slot="primary-button-icon" viewBox="0 0 16 16" aria-hidden="true"><path d="M9.3 3.7 13.1 7.5H1v1h12.1l-3.8 3.8.7.7 5-5-5-5z" /></svg>
ใครอนุมัติการจัดซื้อได้ และได้ถึงวงเงินเท่าไร
</UiProductiveCard>
<ProductiveCard
title="ระเบียบการจัดซื้อ"
description="ฉบับที่ 4 ปี 2569"
primaryButtonText="อ่านระเบียบ"
primaryButtonHref="/policies/procurement"
primaryButtonIcon={<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M9.3 3.7 13.1 7.5H1v1h12.1l-3.8 3.8.7.7 5-5-5-5z" /></svg>}
>
ใครอนุมัติการจัดซื้อได้ และได้ถึงวงเงินเท่าไร
</ProductiveCard>
ขนาดหัวข้อและระดับ heading
title-size="large" ทำให้หัวข้อของ productive card เป็น heading-03 แทน heading-compact-02 หัวข้อเป็น <h2> ตั้งระดับที่เหมาะกับหน้าได้ด้วย heading-level (h1 … h6 React + Tailwind ใช้ headingAs) ถ้าต้องการ markup ใน label หัวข้อ หรือคำอธิบาย ให้ใช้ slot label, title และ description
48 ฉบับ มากกว่าสิงหาคม 12 ฉบับ
ฝ่ายขาย 21 · ฝ่ายกฎหมาย 15 · ฝ่ายจัดซื้อ 12
HTMLReactReact + Tailwind<ui-productive-card heading="ลงนามเดือนนี้" heading-level="h3" title-size="large" style="max-width: 360px">
<span slot="description">48 ฉบับ <b>มากกว่า</b>สิงหาคม 12 ฉบับ</span>
ฝ่ายขาย 21 · ฝ่ายกฎหมาย 15 · ฝ่ายจัดซื้อ 12
</ui-productive-card>
<UiProductiveCard heading="ลงนามเดือนนี้" headingLevel="h3" titleSize="large">
<span slot="description">48 ฉบับ <b>มากกว่า</b>สิงหาคม 12 ฉบับ</span>
ฝ่ายขาย 21 · ฝ่ายกฎหมาย 15 · ฝ่ายจัดซื้อ 12
</UiProductiveCard>
<ProductiveCard title="ลงนามเดือนนี้" headingAs="h3" titleSize="large" description={<>48 ฉบับ <b>มากกว่า</b>สิงหาคม 12 ฉบับ</>}>
ฝ่ายขาย 21 · ฝ่ายกฎหมาย 15 · ฝ่ายจัดซื้อ 12
</ProductiveCard>
คลิกได้
clickable ทำให้ส่วนหนึ่งของ card เป็นปุ่มที่ยิง ui-click เมื่อคลิก กด Enter หรือ Space (ใน React + Tailwind แค่ส่ง onClick ก็พอ) click-zone เลือกส่วนนั้น: one ทั้ง card (ค่าเริ่มต้น) two header กับเนื้อหา three เฉพาะเนื้อหา ปุ่มของส่วนนั้นอยู่ใต้ปุ่มของ card เอง ซึ่งยังเป็นจุดหยุดของ Tab แยกกันและไม่ยิง ui-click หัวข้อเป็นชื่อของปุ่ม และคำอธิบายเป็นคำอธิบายของปุ่ม
คลิกตรงไหนก็ได้ยกเว้นปุ่มแก้ไข
เฉพาะข้อความนี้ที่เป็นปุ่ม
คลิกล่าสุด:
HTMLReactReact + Tailwind<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px">
<ui-productive-card id="product-card-zone-one" clickable heading="ส่วนที่หนึ่ง" description="ทั้ง card">
<ui-icon-button slot="actions" label="แก้ไข"><svg viewBox="0 0 16 16"><path d="M1 13h14v1H1zM12.7 4.5 10.5 2.3a1 1 0 0 0-1.4 0L3 8.4V11h2.6l6.1-6.1a1 1 0 0 0 0-1.4zM5.2 10H4V8.8l4-4 1.2 1.2zm4.7-4.7L8.7 4.1l1.1-1.1L11 4.2z" /></svg></ui-icon-button>
คลิกตรงไหนก็ได้ยกเว้นปุ่มแก้ไข
</ui-productive-card>
<ui-productive-card id="product-card-zone-three" clickable click-zone="three" heading="ส่วนที่สาม" description="เฉพาะเนื้อหา" primary-button-text="รายละเอียด">
เฉพาะข้อความนี้ที่เป็นปุ่ม
</ui-productive-card>
</div>
<p>คลิกล่าสุด: <output id="product-card-zone-out">ยังไม่มี</output></p>
<script type="module">
const out = document.getElementById('product-card-zone-out');
for (const id of ['product-card-zone-one', 'product-card-zone-three']) {
const card = document.getElementById(id);
card.addEventListener('ui-click', () => (out.value = `${card.heading}: ui-click`));
card.addEventListener('ui-primary-button-click', () => (out.value = `${card.heading}: ปุ่ม primary`));
}
document.querySelector('#product-card-zone-one ui-icon-button').addEventListener('click', () => (out.value = 'ส่วนที่หนึ่ง: ปุ่มแก้ไข'));
</script>
<UiProductiveCard clickable heading="ส่วนที่หนึ่ง" description="ทั้ง card" onUiClick={open}>
<UiIconButton slot="actions" label="แก้ไข" onClick={edit}>{editIcon}</UiIconButton>
คลิกตรงไหนก็ได้ยกเว้นปุ่มแก้ไข
</UiProductiveCard>
<UiProductiveCard clickable clickZone="three" heading="ส่วนที่สาม" description="เฉพาะเนื้อหา" primaryButtonText="รายละเอียด" onUiClick={open} onUiPrimaryButtonClick={details}>
เฉพาะข้อความนี้ที่เป็นปุ่ม
</UiProductiveCard>
<ProductiveCard title="ส่วนที่หนึ่ง" description="ทั้ง card" onClick={open} actionIcons={[{ id: 'edit', icon: editIcon, iconDescription: 'แก้ไข', onClick: edit }]}>
คลิกตรงไหนก็ได้ยกเว้นปุ่มแก้ไข
</ProductiveCard>
<ProductiveCard clickZone="three" title="ส่วนที่สาม" description="เฉพาะเนื้อหา" primaryButtonText="รายละเอียด" onClick={open} onPrimaryButtonClick={details}>
เฉพาะข้อความนี้ที่เป็นปุ่ม
</ProductiveCard>
ปิดใช้งาน
disabled แค่ประกาศว่า card ปิดใช้งาน (aria-disabled) และหยุด ui-click ไม่ได้ทำให้อะไรเป็นสีเทา เหมือน Carbon ปิดปุ่มด้วย primary-button-disabled และ secondary-button-disabled และบอกเหตุผลไว้ใน card ว่าทำไมใช้ไม่ได้
ฝ่ายกฎหมายกำลังปรับข้อกำหนดเรื่องดอกเบี้ย
HTMLReactReact + Tailwind<ui-productive-card clickable disabled heading="แม่แบบสัญญากู้ยืม" description="กำลังแก้ไขถึง 15 ตุลาคม" primary-button-text="ใช้แม่แบบ" primary-button-disabled style="max-width: 360px">
ฝ่ายกฎหมายกำลังปรับข้อกำหนดเรื่องดอกเบี้ย
</ui-productive-card>
<UiProductiveCard clickable disabled heading="แม่แบบสัญญากู้ยืม" description="กำลังแก้ไขถึง 15 ตุลาคม" primaryButtonText="ใช้แม่แบบ" primaryButtonDisabled>
ฝ่ายกฎหมายกำลังปรับข้อกำหนดเรื่องดอกเบี้ย
</UiProductiveCard>
<ProductiveCard disabled onClick={open} title="แม่แบบสัญญากู้ยืม" description="กำลังแก้ไขถึง 15 ตุลาคม" primaryButtonText="ใช้แม่แบบ" primaryButtonDisabled>
ฝ่ายกฎหมายกำลังปรับข้อกำหนดเรื่องดอกเบี้ย
</ProductiveCard>
Expressive card
ui-expressive-card ใช้กับเนื้อหา รูปอยู่ด้านบน (slot="media" แสดงตามขนาดจริงไม่เกินความกว้างของ card) pictogram อยู่เหนือหัวข้อ (slot="pictogram") และปุ่มอยู่ใน footer ค่าเริ่มต้นเป็นปุ่ม primary และ secondary ปุ่มไอคอน (slot="actions") เป็นขนาดเล็กอยู่ท้าย footer
ตรวจคู่สัญญา ลงนามด้วยรหัสใช้ครั้งเดียว แล้วดาวน์โหลดฉบับที่ลงนามแล้ว
กดแล้ว:
HTMLReactReact + Tailwind<ui-expressive-card id="product-card-expressive" label="คู่มือ" heading="ลงนามสัญญาออนไลน์" primary-button-text="เริ่ม" secondary-button-text="ไว้ทีหลัง" style="max-width: 360px">
<img slot="media" alt="" width="360" height="203" src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 90'%3E%3Crect width='160' height='90' fill='%23d0e2ff'/%3E%3Cpath d='M66 20h22l10 10v40H66z' fill='%23ffffff'/%3E%3Cpath d='M72 42h20M72 50h20M72 58h12' stroke='%230f62fe' stroke-width='2'/%3E%3C/svg%3E" />
<ui-icon-button slot="actions" label="เก็บไว้อ่านทีหลัง"><svg viewBox="0 0 16 16"><path d="M12 2v12.2l-3.5-2.6-.5-.4-.5.4L4 14.2V2h8m0-1H4a1 1 0 0 0-1 1v14l5-3.7 5 3.7V2a1 1 0 0 0-1-1Z" /></svg></ui-icon-button>
ตรวจคู่สัญญา ลงนามด้วยรหัสใช้ครั้งเดียว แล้วดาวน์โหลดฉบับที่ลงนามแล้ว
</ui-expressive-card>
<p>กดแล้ว: <output id="product-card-expressive-out">ยังไม่มี</output></p>
<script type="module">
const card = document.getElementById('product-card-expressive');
const out = document.getElementById('product-card-expressive-out');
card.addEventListener('ui-primary-button-click', () => (out.value = 'เริ่ม'));
card.addEventListener('ui-secondary-button-click', () => (out.value = 'ไว้ทีหลัง'));
</script>
<UiExpressiveCard label="คู่มือ" heading="ลงนามสัญญาออนไลน์" primaryButtonText="เริ่ม" secondaryButtonText="ไว้ทีหลัง" onUiPrimaryButtonClick={start} onUiSecondaryButtonClick={later}>
<img slot="media" alt="" width={360} height={203} src={guideImage} />
<UiIconButton slot="actions" label="เก็บไว้อ่านทีหลัง">{bookmarkIcon}</UiIconButton>
ตรวจคู่สัญญา ลงนามด้วยรหัสใช้ครั้งเดียว แล้วดาวน์โหลดฉบับที่ลงนามแล้ว
</UiExpressiveCard>
<ExpressiveCard
label="คู่มือ"
title="ลงนามสัญญาออนไลน์"
primaryButtonText="เริ่ม"
secondaryButtonText="ไว้ทีหลัง"
onPrimaryButtonClick={start}
onSecondaryButtonClick={later}
media={<img alt="" width={360} height={203} src={guideImage} />}
actionIcons={[{ id: 'save', icon: bookmarkIcon, iconDescription: 'เก็บไว้อ่านทีหลัง' }]}
>
ตรวจคู่สัญญา ลงนามด้วยรหัสใช้ครั้งเดียว แล้วดาวน์โหลดฉบับที่ลงนามแล้ว
</ExpressiveCard>
primary-button-kind รับ primary (ค่าเริ่มต้น) หรือ ghost ส่วน secondary-button-kind รับ secondary (ค่าเริ่มต้น) หรือ ghost
Pictogram และรูปด้านหน้า
pictogram อยู่เหนือหัวข้อ ห่างขอบ 16px media-position="left" วางรูปไว้ด้านหน้าและเนื้อหาอยู่ข้าง ๆ
NDA แบบสองฝ่าย ภาษาไทยและอังกฤษ ผ่านการอนุมัติจากฝ่ายกฎหมาย
เลือกผู้อนุมัติ เพิ่มบันทึก แล้วติดตามคำขอจากกล่องข้อความของคุณ
HTMLReactReact + Tailwind<ui-expressive-card heading="สัญญารักษาความลับ" primary-button-text="ใช้แม่แบบ" primary-button-kind="ghost" style="max-width: 360px">
<svg slot="pictogram" width="48" height="48" viewBox="0 0 32 32" fill="none" stroke="currentColor" aria-hidden="true"><path d="M8 3h11l5 5v21H8zM19 3v5h5M12 14h8M12 18h8M12 22h5" /></svg>
NDA แบบสองฝ่าย ภาษาไทยและอังกฤษ ผ่านการอนุมัติจากฝ่ายกฎหมาย
</ui-expressive-card>
<ui-expressive-card heading="ขออนุมัติ" media-position="left" primary-button-text="อ่าน" primary-button-kind="ghost" style="max-width: 560px">
<img slot="media" alt="" width="180" height="180" src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 90 90'%3E%3Crect width='90' height='90' fill='%23d0e2ff'/%3E%3Cpath d='M34 20h18l8 8v42H34z' fill='%23ffffff'/%3E%3Cpath d='M40 42h14M40 50h14M40 58h8' stroke='%230f62fe' stroke-width='2'/%3E%3C/svg%3E" />
เลือกผู้อนุมัติ เพิ่มบันทึก แล้วติดตามคำขอจากกล่องข้อความของคุณ
</ui-expressive-card>
<UiExpressiveCard heading="สัญญารักษาความลับ" primaryButtonText="ใช้แม่แบบ" primaryButtonKind="ghost">
<svg slot="pictogram" width="48" height="48" viewBox="0 0 32 32" fill="none" stroke="currentColor" aria-hidden="true">…</svg>
NDA แบบสองฝ่าย ภาษาไทยและอังกฤษ ผ่านการอนุมัติจากฝ่ายกฎหมาย
</UiExpressiveCard>
<UiExpressiveCard heading="ขออนุมัติ" mediaPosition="left" primaryButtonText="อ่าน" primaryButtonKind="ghost">
<img slot="media" alt="" width={180} height={180} src={approvalImage} />
เลือกผู้อนุมัติ เพิ่มบันทึก แล้วติดตามคำขอจากกล่องข้อความของคุณ
</UiExpressiveCard>
<ExpressiveCard title="สัญญารักษาความลับ" primaryButtonText="ใช้แม่แบบ" primaryButtonKind="ghost" pictogram={documentPictogram}>
NDA แบบสองฝ่าย ภาษาไทยและอังกฤษ ผ่านการอนุมัติจากฝ่ายกฎหมาย
</ExpressiveCard>
<ExpressiveCard title="ขออนุมัติ" mediaPosition="left" primaryButtonText="อ่าน" primaryButtonKind="ghost" media={<img alt="" width={180} height={180} src={approvalImage} />}>
เลือกผู้อนุมัติ เพิ่มบันทึก แล้วติดตามคำขอจากกล่องข้อความของคุณ
</ExpressiveCard>
Expressive card ที่คลิกได้
บน expressive card clickable ทำให้ทั้ง card เป็นปุ่มเสมอ ปุ่มของ card เองยังแยกกัน
เริ่มสัญญาเช่าใหม่จากแม่แบบที่อนุมัติแล้ว
กดล่าสุด:
HTMLReactReact + Tailwind<ui-expressive-card id="product-card-pick" clickable heading="สัญญาเช่า" description="ทรัพย์สิน ค่าเช่า และระยะเวลา" primary-button-text="ดูตัวอย่าง" primary-button-kind="ghost" style="max-width: 360px">
เริ่มสัญญาเช่าใหม่จากแม่แบบที่อนุมัติแล้ว
</ui-expressive-card>
<p>กดล่าสุด: <output id="product-card-pick-out">ยังไม่มี</output></p>
<script type="module">
const card = document.getElementById('product-card-pick');
const out = document.getElementById('product-card-pick-out');
card.addEventListener('ui-click', () => (out.value = 'card: เริ่มสัญญาเช่า'));
card.addEventListener('ui-primary-button-click', () => (out.value = 'ปุ่มดูตัวอย่าง'));
</script>
<UiExpressiveCard clickable heading="สัญญาเช่า" description="ทรัพย์สิน ค่าเช่า และระยะเวลา" primaryButtonText="ดูตัวอย่าง" primaryButtonKind="ghost" onUiClick={start} onUiPrimaryButtonClick={preview}>
เริ่มสัญญาเช่าใหม่จากแม่แบบที่อนุมัติแล้ว
</UiExpressiveCard>
<ExpressiveCard title="สัญญาเช่า" description="ทรัพย์สิน ค่าเช่า และระยะเวลา" primaryButtonText="ดูตัวอย่าง" primaryButtonKind="ghost" onClick={start} onPrimaryButtonClick={preview}>
เริ่มสัญญาเช่าใหม่จากแม่แบบที่อนุมัติแล้ว
</ExpressiveCard>
Decorator และ layer
slot decorator วาง element เล็ก ๆ ห่างมุมบนด้านท้าย 16px เช่น AI label หรือ tag card ทั้งสองแบบวาดตัวเองด้วยสีของ layer ที่วางอยู่ ใน ui-layer จึงใช้สีของ layer ถัดไป
AI
สัญญาเช่าสามปี ค่าเช่าเพิ่มปีละ 5%
HTMLReactReact + Tailwind<ui-layer level="1" with-background style="padding: 16px">
<ui-productive-card heading="สรุปสัญญา" description="สร้างจากเอกสาร 14 หน้า" style="max-width: 360px">
<ui-tag slot="decorator" type="purple" size="sm">AI</ui-tag>
สัญญาเช่าสามปี ค่าเช่าเพิ่มปีละ 5%
</ui-productive-card>
</ui-layer>
<UiLayer level={1} withBackground style={{ padding: 16 }}>
<UiProductiveCard heading="สรุปสัญญา" description="สร้างจากเอกสาร 14 หน้า">
<UiTag slot="decorator" type="purple" size="sm">AI</UiTag>
สัญญาเช่าสามปี ค่าเช่าเพิ่มปีละ 5%
</UiProductiveCard>
</UiLayer>
<Layer level={1} withBackground className="p-4">
<ProductiveCard title="สรุปสัญญา" description="สร้างจากเอกสาร 14 หน้า" decorator={<Tag type="purple" size="sm">AI</Tag>}>
สัญญาเช่าสามปี ค่าเช่าเพิ่มปีละ 5%
</ProductiveCard>
</Layer>
คีย์บอร์ด
| ปุ่ม |
ทำอะไร |
| Tab |
ไปที่ส่วนที่คลิกได้และปุ่มหรือลิงก์ของ card ตามลำดับในหน้า |
| Enter, Space |
กดส่วนที่คลิกได้ หรือปุ่มที่มี focus |
Accessibility
- หัวข้อเป็น heading จริง (ค่าเริ่มต้น
<h2>) ตั้ง heading-level ให้โครงหัวข้อของหน้าถูกต้อง
- ส่วนที่คลิกได้คือ
<button> ที่ใช้หัวข้อเป็นชื่อ (ถ้าไม่มีใช้ label ถ้าไม่มีอีกใช้เนื้อหา) และใช้คำอธิบายเป็นคำอธิบายของปุ่ม
disabled ตั้งแค่ aria-disabled หน้าตาของ card ไม่เปลี่ยน จึงต้องบอกเหตุผลว่าทำไมใช้ไม่ได้
- ปุ่มไอคอนทุกปุ่มต้องมี
label เป็นทั้งชื่อและ tooltip ของปุ่ม
- รูปและ pictogram เป็นแค่การตกแต่ง เว้นแต่คุณใส่
alt หรือชื่อจริงให้
ต้องการแค่พฤติกรรมโดยไม่มี style: Headless Product card
API
สร้างจากแพ็กเกจโดยตรง ใน React ส่ง property เป็น prop ชื่อเดียวกัน ส่วน event ก็เป็น prop เช่นกัน (ดูคอลัมน์ React)
<ui-productive-card> · React UiProductiveCard
Attribute
| Attribute |
Property |
ชนิด |
ค่าเริ่มต้น |
คำอธิบาย |
click-zone |
clickZone |
ProductCardClickZone |
'one' |
Which zone clickable makes one button: one = the card, two = the header with the body, three = the body. |
actions-placement |
actionsPlacement |
ProductCardPlacement |
'top' |
Where the action icons (or the overflow menu) go. |
title-size |
titleSize |
ProductCardTitleSize |
'default' |
default: heading-compact-02; large: heading-03. |
overflow-aria-label |
overflowAriaLabel |
string |
'' |
The overflow menu's name and tooltip (default: the translation's "Options", as Carbon's iconDescription). |
primary-button-placement |
primaryButtonPlacement |
ProductCardPlacement |
'bottom' |
At the top the primary button joins the top actions (a ghost sm button, without href). |
secondary-button-placement |
secondaryButtonPlacement |
ProductCardPlacement |
'bottom' |
At the top the secondary button joins the top actions, only when there are other top actions (as Carbon). |
heading |
heading |
string |
'' |
The title (Carbon title; named heading because title is every element's native tooltip). |
heading-level |
headingLevel |
string |
'h2' |
The title's element (h1 … h6; Carbon Heading in its Section, an <h2> at the top of a page). |
label |
label |
string |
'' |
Text above the title (label-01). |
description |
description |
string |
'' |
Text below the title (label-01). |
clickable |
clickable |
boolean |
false |
Makes the card's click zone one button (Carbon: an onClick); listen for ui-click. |
disabled |
disabled |
boolean |
false |
Announced as disabled (aria-disabled, as Carbon); a clickable zone then fires no ui-click. No other change, as Carbon. |
primary-button-text |
primaryButtonText |
string |
'' |
|
primary-button-href |
primaryButtonHref |
string |
'' |
Makes the primary button a link (in the footer; Carbon's button at the top takes no href). |
primary-button-disabled |
primaryButtonDisabled |
boolean |
false |
|
secondary-button-text |
secondaryButtonText |
string |
'' |
|
secondary-button-href |
secondaryButtonHref |
string |
'' |
Makes the secondary button a link. |
secondary-button-disabled |
secondaryButtonDisabled |
boolean |
false |
|
Event
| Event |
React |
คำอธิบาย |
ui-click |
ไม่มี (ใช้ ref) |
The click zone was activated (a click, Enter or Space); not while disabled |
ui-primary-button-click |
ไม่มี (ใช้ ref) |
The primary button was activated |
ui-secondary-button-click |
ไม่มี (ใช้ ref) |
The secondary button was activated |
Slot
| Slot |
คำอธิบาย |
| (ค่าเริ่มต้น) |
The body (body-compact-01) |
label |
Replaces label |
title |
Replaces heading |
description |
Replaces description |
actions |
Icon buttons (<ui-icon-button label="…">); the card sets their size |
overflow |
<ui-menu-item>s of the overflow menu, shown instead of the action icons |
primary-button-icon |
A 16px icon after the primary button's text (Carbon primaryButtonIcon) |
secondary-button-icon |
A 16px icon after the secondary button's text |
decorator |
E.g. an AI label, 16px from the top-end corner |
CSS part
| Part |
คำอธิบาย |
base |
The card |
click-zone |
The clickable zone's button (clickable only), covering the zone |
content |
The header, body and footer |
header |
The header |
label |
The label |
title |
The title (<h2> by default) |
description |
The description |
actions |
The action icons' (or overflow menu's) box, with the top buttons |
overflow |
The <ui-overflow-menu> |
body |
The body |
footer |
The footer |
primary-button |
The primary <ui-button> |
secondary-button |
The secondary <ui-button> |
decorator |
The decorator's box |
CSS custom property
| Custom property |
ค่าเริ่มต้น |
คำอธิบาย |
--ui-tile-border-color |
|
Its 1px border, as the selectable tiles (default transparent; Kanok: a hairline) |
--ui-card-background |
|
Its fill (default --ui-surface-1; Kanok paper: a cool grey that sets it apart from the page, no border) |
--ui-card-radius |
|
/ --ui-card-overflow - Corners and clipping, as <ui-card> (default square, visible; Kanok: 12px, clipped) |
<ui-expressive-card> · React UiExpressiveCard
Attribute
| Attribute |
Property |
ชนิด |
ค่าเริ่มต้น |
คำอธิบาย |
media-position |
mediaPosition |
ProductCardMediaPosition |
'top' |
Where the media goes: across the top, or at the start with the content beside it. |
primary-button-kind |
primaryButtonKind |
ProductCardPrimaryKind |
'primary' |
|
secondary-button-kind |
secondaryButtonKind |
ProductCardSecondaryKind |
'secondary' |
|
heading |
heading |
string |
'' |
The title (Carbon title; named heading because title is every element's native tooltip). |
heading-level |
headingLevel |
string |
'h2' |
The title's element (h1 … h6; Carbon Heading in its Section, an <h2> at the top of a page). |
label |
label |
string |
'' |
Text above the title (label-01). |
description |
description |
string |
'' |
Text below the title (label-01). |
clickable |
clickable |
boolean |
false |
Makes the card's click zone one button (Carbon: an onClick); listen for ui-click. |
disabled |
disabled |
boolean |
false |
Announced as disabled (aria-disabled, as Carbon); a clickable zone then fires no ui-click. No other change, as Carbon. |
primary-button-text |
primaryButtonText |
string |
'' |
|
primary-button-href |
primaryButtonHref |
string |
'' |
Makes the primary button a link (in the footer; Carbon's button at the top takes no href). |
primary-button-disabled |
primaryButtonDisabled |
boolean |
false |
|
secondary-button-text |
secondaryButtonText |
string |
'' |
|
secondary-button-href |
secondaryButtonHref |
string |
'' |
Makes the secondary button a link. |
secondary-button-disabled |
secondaryButtonDisabled |
boolean |
false |
|
Event
| Event |
React |
คำอธิบาย |
ui-click |
ไม่มี (ใช้ ref) |
The card was activated (a click, Enter or Space); not while disabled |
ui-primary-button-click |
ไม่มี (ใช้ ref) |
The primary button was activated |
ui-secondary-button-click |
ไม่มี (ใช้ ref) |
The secondary button was activated |
Slot
| Slot |
คำอธิบาย |
| (ค่าเริ่มต้น) |
The body (body-compact-01) |
label |
Replaces label |
title |
Replaces heading |
description |
Replaces description |
media |
An image or video across the top (or at the start), shown at its own size up to the card's width |
pictogram |
A pictogram above the title, 16px in |
actions |
Icon buttons (<ui-icon-button label="…">, ghost); the card makes them sm |
primary-button-icon |
A 16px icon after the primary button's text (Carbon primaryButtonIcon) |
secondary-button-icon |
A 16px icon after the secondary button's text |
decorator |
E.g. an AI label, 16px from the top-end corner |
CSS part
| Part |
คำอธิบาย |
base |
The card |
click-zone |
The card's button (clickable only), covering the card |
media |
The media's box |
pictogram |
The pictogram's box |
content |
The header, body and footer |
header |
The header |
label |
The label |
title |
The title (<h2> by default) |
description |
The description |
actions |
The action icons' box |
body |
The body |
footer |
The footer |
primary-button |
The primary <ui-button> |
secondary-button |
The secondary <ui-button> |
decorator |
The decorator's box |