Skip to main content
Decoderen
Browse documentation

Callout

Set apart a useful supporting note on Material 3's filled card.

Default

Show code
Example.astroAstro
---
import Callout from '@dhekode/ui/primitives/Callout.tsx';
---

<Callout><p>Native disclosures work without JavaScript.</p></Callout>

With title

Show code
Example.astroAstro
---
import Callout from '@dhekode/ui/primitives/Callout.tsx';
---

<Callout title="Good to know"><p>Use supporting notes where they add useful context.</p></Callout>

Brand surface

Show code
Example.astroAstro
---
import Callout from '@dhekode/ui/primitives/Callout.tsx';
import TextLink from '@dhekode/ui/primitives/TextLink.tsx';
---

<Callout variant="brand" title="Keep exploring"><p>Read the component reference.</p><TextLink href="/decoderen/disclosure/" arrow>View Disclosure</TextLink></Callout>
API reference
title

Type: string

Default: unset

Optional supporting title.

variant

Type: 'subtle' | 'brand'

Default: 'subtle'

Steel tint or navy surface with contextual text roles.

className

Type: string | undefined

Default: unset

Adds classes to the React component root, after its own utilities. React components take className, not class.

Slots: Default: note content and optional links.

Uses role="note" for static content. Urgent validation and live announcements need their own behavior.

Original component source
packages/ui/src/primitives/Callout.tsxAstro
import type { ReactNode } from 'react';
import { classNames } from '@dhekode/utils/class-names';

export interface CalloutProps {
  title?: string | undefined;
  /** The surface the note sits on: a quiet steel tint or the brand navy. */
  variant?: 'subtle' | 'brand' | undefined;
  className?: string | undefined;
  children: ReactNode;
}

/*
 * The quiet note takes the steel tint, the fill of Card's filled variant: paper sits within a shade
 * of the page canvas, so a note filled with it does not read as a card.
 */
const surfaces = { subtle: 'steel', brand: 'brand' } as const;

/**
 * A supporting note on Material 3's filled card. It sets its own surface, so text, links and
 * buttons inside follow that surface's roles.
 */
export default function Callout({ title, variant = 'subtle', className, children }: CalloutProps) {
  return (
    <aside
      role="note"
      className={classNames(
        'dk-callout grid grid-cols-1 gap-sm rounded-card bg-surface-bg p-lg text-body-sm text-surface-text wrap-anywhere *:max-w-prose',
        className,
      )}
      data-variant={variant}
      data-surface={surfaces[variant]}
    >
      {title && <p className="dk-callout__title font-medium text-surface-accent">{title}</p>}
      {children}
    </aside>
  );
}

Best practices

  • Keep notes concise and avoid repeating the adjacent heading.