Skip to content

Commit 89d2236

Browse files
x0rguspqoqubbw
andauthored
add: callout title prop (#216)
* add: callout title prop * Update packages/components/src/components/callout/callout.tsx Co-authored-by: dmytro <71014515+pqoqubbw@users.noreply.github.com> * Update packages/components/src/components/callout/callout.tsx Co-authored-by: dmytro <71014515+pqoqubbw@users.noreply.github.com> * fix: consistent spacing when title is present * fix: lint --------- Co-authored-by: dmytro <71014515+pqoqubbw@users.noreply.github.com>
1 parent f85a948 commit 89d2236

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

packages/components/src/components/callout/callout.stories.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ const meta: Meta<typeof Callout> = {
1414
options: ["info", "warning", "note", "tip", "check", "danger", "custom"],
1515
description: "Predefined callout variant",
1616
},
17+
title: {
18+
control: "text",
19+
description: "Optional title displayed above the callout content",
20+
},
1721
icon: {
1822
control: "text",
1923
description: "Icon name or custom React node (for custom variant)",
@@ -312,3 +316,11 @@ export const BackwardCompatibilityAllTypes: Story = {
312316
</div>
313317
),
314318
};
319+
320+
export const WithTitle: Story = {
321+
args: {
322+
variant: "note",
323+
title: "Authentication",
324+
children: <p>You must provide an API key.</p>,
325+
},
326+
};

packages/components/src/components/callout/callout.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type CalloutVariant =
2424

2525
type CalloutProps = {
2626
children: ReactNode;
27+
title?: string;
2728
variant?: CalloutVariant;
2829
icon?: ReactNode | string;
2930
iconType?: IconType;
@@ -80,6 +81,7 @@ const variantConfig = {
8081

8182
const Callout = ({
8283
children,
84+
title,
8385
variant = "custom",
8486
icon,
8587
iconType,
@@ -181,11 +183,17 @@ const Callout = ({
181183
<div
182184
className={cn(
183185
"prose dark:prose-invert w-full min-w-0 text-sm [&_a]:border-current [&_a]:text-current! [&_code]:text-current! [&_kbd]:bg-stone-100 [&_kbd]:text-current! dark:[&_kbd]:bg-stone-800 [&_strong]:text-current!",
186+
title && "[&>:nth-child(2)]:mt-3",
184187
childrenClassName
185188
)}
186189
data-component-part="callout-content"
187190
style={customTextStyle}
188191
>
192+
{title && (
193+
<div className="font-semibold" data-component-part="callout-title">
194+
{title}
195+
</div>
196+
)}
189197
{children}
190198
</div>
191199
</div>

0 commit comments

Comments
 (0)