設定を変更してShareButtonsコンポーネントの表示を確認できます
異なる設定でのShareButtonsコンポーネントの表示例
<ShareButtons
title="サンプル記事タイトル"
url="https://example.com/sample-article"
direction="horizontal"
variant="icon-with-label"
size="md"
/><ShareButtons
title="サンプル記事タイトル"
url="https://example.com/sample-article"
direction="horizontal"
variant="icon-only"
size="md"
/><ShareButtons
title="サンプル記事タイトル"
url="https://example.com/sample-article"
direction="vertical"
variant="icon-with-label"
size="md"
/>ShareButtonsコンポーネントの実装方法とベストプラクティス
import { ShareButtons } from "@/app/components/ShareButtons";
export default function BlogPost() {
return (
<article>
<h1>記事タイトル</h1>
<div className="article-content">
{/* 記事内容 */}
</div>
{/* 記事下部にシェアボタンを設置 */}
<ShareButtons
title="記事タイトル"
url="https://example.com/article"
direction="horizontal"
variant="icon-with-label"
size="md"
/>
</article>
);
}// サイドバーやフローティング表示の場合
<div className="sidebar">
<ShareButtons
title="記事タイトル"
url="https://example.com/article"
direction="vertical"
variant="icon-only"
size="sm"
/>
</div>interface ShareButtonsProps {
title: string; // シェアする記事のタイトル
url: string; // シェアするURL
direction?: 'horizontal' | 'vertical'; // ボタンの配置方向
variant?: 'icon-only' | 'icon-with-label'; // アイコンのみ or ラベル付き
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'; // ボタンサイズ
className?: string; // 追加のCSSクラス
}