Meritsブロック
Merits は、MUI 上に構築されたマーケティング用メリットセクションで、中央揃えのヘッダー、メリットタイルの行、プライマリのコールトゥアクションリンクボタンを備えています。
インストール
- npm
- yarn
- pnpm
- bun
npm install @nodeblocks/frontend-merits-block
yarn add @nodeblocks/frontend-merits-block
pnpm add @nodeblocks/frontend-merits-block
bun add @nodeblocks/frontend-merits-block
必要なもの
| 項目 | 用途 |
|---|---|
subtitle | 補助テキスト行 |
meritsTitle | メイン見出し |
items | メリットタイルのコンテンツ |
buttonText | CTA のラベル |
buttonHref | デフォルト contained ボタンの href |
ヘッダーのコピー、メリット項目、CTA テキストをページまたは CMS から渡してください。各項目には imageUrl、text、subtext が必要です。画像は小画面・大画面とも固定アスペクト比フレーム内で object-fit: contain になります。
コード例
- クイックスタート
- ラベルと URL
- 複合コンポーネント
- ブロックのオーバーライド
function Example() { const items = [ { imageUrl: '/img/undraw_docusaurus_mountain.svg', text: '迅速な配送', subtext: '注文を迅速かつ効率的にお届けします', }, { imageUrl: '/img/undraw_docusaurus_react.svg', text: '品質保証', subtext: 'すべての製品で最高品質をお約束します', }, { imageUrl: '/img/undraw_docusaurus_tree.svg', text: '24時間サポート', subtext: 'いつでもお客様をサポートします', }, ]; return ( <Merits subtitle="選ばれる理由" meritsTitle="主なメリット" buttonText="詳しく見る" buttonHref="#about" items={items} /> ); }
ヘッダーのコピー、メリットタイルの内容、CTA の遷移先をカスタマイズします。
function Example() { const items = [ { imageUrl: '/img/undraw_docusaurus_mountain.svg', text: '一緒に開発', subtext: '明確なレビューと高速なイテレーションで、共有コードベースで協業できます。', }, { imageUrl: '/img/undraw_docusaurus_react.svg', text: '整理された状態を維持', subtext: 'タスクとチェックリストを同期し、次に何をするか全員が把握できます。', }, { imageUrl: '/img/undraw_docusaurus_tree.svg', text: '明確なコミュニケーション', subtext: 'フィードバックを一箇所でやり取りし、情報の取りこぼしを防ぎます。', }, ]; return ( <Merits subtitle="プロダクトチーム向けに構築" meritsTitle="より速く進めるために必要なすべて" buttonText="料金を見る" buttonHref="#pricing" items={items} /> ); }
Merits に subtitle、meritsTitle、buttonText、buttonHref、items を設定します。サブコンポーネントはコンテキストから読み取ります。複合子でレイアウトやスタイルを上書きするか、関数の子でブロックを差し替えてください。
Merits.Header、Merits.Content、Merits.ActionBar を直接構成し、各ブロックを sx でスタイルします。
function Example() { const items = [ { imageUrl: '/img/undraw_docusaurus_mountain.svg', text: '迅速な配送', subtext: '注文を迅速かつ効率的にお届けします', }, { imageUrl: '/img/undraw_docusaurus_react.svg', text: '品質保証', subtext: 'すべての製品で最高品質をお約束します', }, { imageUrl: '/img/undraw_docusaurus_tree.svg', text: '24時間サポート', subtext: 'いつでもお客様をサポートします', }, ]; return ( <Merits subtitle="選ばれる理由" meritsTitle="主なメリット" buttonText="詳しく見る" buttonHref="#about" items={items} sx={{ maxWidth: 960, mx: 'auto', px: 2 }} > <Merits.Header sx={{ px: 2, py: 3, borderRadius: 2, bgcolor: 'grey.50', '& .nbb-merits-merit-subtitle': { letterSpacing: 1, textTransform: 'uppercase' }, }} /> <Merits.Content sx={{ '& .nbb-merits-merit-item': { p: 2, borderRadius: 2, border: '1px solid', borderColor: 'divider', bgcolor: 'grey.50' }, '& .MuiDivider-root': { display: 'none' }, }} /> <Merits.ActionBar> <Merits.ActionBar.Button sx={{ px: 5, borderRadius: 99 }}> 今すぐ始める </Merits.ActionBar.Button> </Merits.ActionBar> </Merits> ); }
defaultBlocks と defaultBlockOrder を使う関数の children で、ブロックの注入、デフォルトの差し替え、順序の制御を行います。
function Example() { const items = [ { imageUrl: '/img/undraw_docusaurus_mountain.svg', text: '迅速な配送', subtext: '注文を迅速かつ効率的にお届けします', }, { imageUrl: '/img/undraw_docusaurus_react.svg', text: '品質保証', subtext: 'すべての製品で最高品質をお約束します', }, { imageUrl: '/img/undraw_docusaurus_tree.svg', text: '24時間サポート', subtext: 'いつでもお客様をサポートします', }, ]; return ( <Merits subtitle="選ばれる理由" meritsTitle="主なメリット" buttonText="詳しく見る" buttonHref="#about" items={items} sx={{ maxWidth: 960, mx: 'auto', px: 2 }} > {({ defaultBlocks, defaultBlockOrder }) => ({ blocks: { ...defaultBlocks, promo: ( <Alert severity="success" sx={{ textAlign: 'center' }}> 新規のお客様は追加費用なしで延長オンボーディングを利用できます。 </Alert> ), content: ( <Merits.Content sx={{ p: 2, borderRadius: 2, bgcolor: 'background.paper', border: '1px solid', borderColor: 'divider', }} /> ), }, blockOrder: ['header', 'promo', 'content', 'actionBar'], })} </Merits> ); }
ブロックのオーバーライドを使うタイミング
デフォルトの defaultBlockOrder は header、content、actionBar です。ルートはこの3ブロックをこの順でマッピングします。バナー(例: promo)の前置や、ルートに items を保持したままカスタムタイルレイアウトが必要な場合は content を差し替えてください。
主要プロパティ
コアプロパティ
| プロパティ | 型 | 必須 | デフォルト | 説明 |
|---|---|---|---|---|
subtitle | ReactNode | はい | — | 補助ヘッダー行(Merits.Header、プライマリカラー) |
meritsTitle | ReactNode | はい | — | Merits.Header のメイン見出し |
items | { imageUrl: string; text: ReactNode; subtext: ReactNode }[] | はい | — | Merits.Content でマッピングされるメリットタイル |
buttonText | string | はい | — | Merits.ActionBar のデフォルト CTA ボタンのラベル |
buttonHref | string | はい | — | デフォルトの Merits.ActionBar.Button に渡される href |
レイアウトと構成プロパティ
| プロパティ | 型 | 必須 | デフォルト | 説明 |
|---|---|---|---|---|
children | ReactNode | function | いいえ | undefined | 複合サブコンポーネント(Merits.Header、Merits.Content、Merits.ActionBar)、またはレイアウトブロックの注入・並べ替え用の関数 ({ defaultBlocks, defaultBlockOrder }) => ({ blocks, blockOrder }) |
className | string | いいえ | undefined | ルートスタックのクラス名(nbb-merits) |
sx | SxProps | いいえ | undefined | ルートスタック用の MUI システムスタイル |
spacing | StackProps['spacing'] | いいえ | { xs: 4, sm: 6 } | ルートスタックの垂直方向の間隔 |
Merits は StackProps(children を除く)を継承します。デフォルトの defaultBlockOrder: header、content、actionBar。
サブコンポーネントのプロパティ
サブコンポーネントはコンテキストから読み取り、同じコンテンツキーをプロパティとして渡すとローカルで上書きできます。
| サブコンポーネント | 主要プロパティ | 継承 | ベース |
|---|---|---|---|
Merits.Header | children、className、sx | StackProps | Stack + Typography |
Merits.Content | items、children、className、sx | StackProps | Stack + Merits.Content.MeritImage + Merits.Content.MeritText |
Merits.Content.MeritImage | meritSrc、meritAlt(デフォルト merit image)、className、sx | BoxProps | Box(component="img") |
Merits.Content.MeritText | children、className、sx | TypographyProps | Typography |
Merits.ActionBar | buttonText、buttonHref、children、className、sx | StackProps | Stack + Merits.ActionBar.Button |
Merits.ActionBar.Button | children、href、className、sx | ButtonProps | Button(variant="contained"、size="large") |
デフォルト UI ブロック
| ブロック | ベース | 備考 |
|---|---|---|
Merits(ルート) | Stack | 縦レイアウト、レスポンシブな間隔(nbb-merits) |
header(Merits.Header) | Stack + Typography | 中央揃えの subtitle(レスポンシブ h6/h4)とタイトル(レスポンシブで最大 45px) |
content(Merits.Content) | Stack + Divider | sm+ では横並び。各項目: 画像フレーム、text(MeritText)、subtext(MeritSubtext、body1) |
actionBar(Merits.ActionBar) | Stack + Button | buttonHref と buttonText 付き contained CTA。xs では全幅 |
デフォルトのルートレンダリング順序: header → content → actionBar。
TypeScript
import * as React from 'react';
import { Merits } from '@nodeblocks/frontend-merits-block';
import type { ReactNode } from 'react';
type MeritItem = {
imageUrl: string;
text: ReactNode;
subtext: ReactNode;
};
type MeritsSectionProps = {
subtitle: ReactNode;
meritsTitle: ReactNode;
buttonText: string;
buttonHref: string;
items: MeritItem[];
};
export function MeritsSection({
subtitle,
meritsTitle,
buttonText,
buttonHref,
items,
}: MeritsSectionProps) {
return (
<Merits
subtitle={subtitle}
meritsTitle={meritsTitle}
buttonText={buttonText}
buttonHref={buttonHref}
items={items}
/>
);
}