Callout
To create a callout, import and compose the following <Callout> components:
import { Button } from "stylus-ui/Button";import { Callout, CalloutContent, CalloutDescription, CalloutTitle, CalloutTrigger,} from "stylus-ui/Callout";
export default () => ( <Callout defaultOpen> <CalloutTrigger asChild> <Button variant="secondary">Open Callout</Button> </CalloutTrigger> <CalloutContent> <CalloutTitle title="Callout" /> <CalloutDescription> Callouts bring attention to a particular element or feature. </CalloutDescription> </CalloutContent> </Callout>);Usage without a trigger
Section titled “Usage without a trigger”For scenarios where you want to position the callout without a trigger, you can use <CalloutAnchor>.
import { Button } from "stylus-ui/Button";import { Callout, CalloutContent, CalloutDescription, CalloutTitle, CalloutAnchor,} from "stylus-ui/Callout";
export default () => ( <Callout defaultOpen> <CalloutAnchor /> <CalloutContent> <CalloutTitle title="Callout" /> <CalloutDescription> Callouts bring attention to a particular element or feature. </CalloutDescription> </CalloutContent> </Callout>);Title icon
Section titled “Title icon”You can pass a Font Awesome icon into <CalloutTitle>.
import { Button } from "stylus-ui/Button";import { Callout, CalloutContent, CalloutDescription, CalloutTitle, CalloutTrigger,} from "stylus-ui/Callout";import { faSparkles } from "@fortawesome/pro-regular-svg-icons";
export default () => ( <Callout> <CalloutTrigger asChild> <Button variant="secondary">Open Callout</Button> </CalloutTrigger> <CalloutContent> <CalloutTitle title="Callout with icon" icon={faSparkles} /> <CalloutDescription> Import your Font Awesome icon and pass it to{" "} <code><CalloutTitle></code>. </CalloutDescription> </CalloutContent> </Callout>);Buttons
Section titled “Buttons”To display buttons in your callout, you can pass primaryAction, primaryActionText, secondaryAction, and secondaryActionText to <CalloutContent>.
import { Button } from "stylus-ui/Button";import { Callout, CalloutContent, CalloutDescription, CalloutTitle, CalloutTrigger,} from "stylus-ui/Callout";import { useToast } from "stylus-ui/Toast";
export default () => { const { toast } = useToast(); const handlePrimaryAction = () => toast({ title: "Clicked primary action" }); const handleSecondaryAction = () => toast({ title: "Clicked secondary action" });
return ( <Callout> <CalloutTrigger asChild> <Button variant="secondary">Open Callout</Button> </CalloutTrigger> <CalloutContent primaryAction={handlePrimaryAction} primaryActionText="Primary Action" secondaryAction={handleSecondaryAction} secondaryActionText="Secondary Action" > <CalloutTitle title="Callout with buttons" /> <CalloutDescription> Buttons defined in <code><CalloutContent></code> will display below. </CalloutDescription> </CalloutContent> </Callout> );};Close button
Section titled “Close button”To display a close button on the callout, set showCloseButton on <CalloutContent>.
import { Button } from "stylus-ui/Button";import { Callout, CalloutContent, CalloutDescription, CalloutTitle, CalloutTrigger,} from "stylus-ui/Callout";
export default () => ( <Callout> <CalloutTrigger asChild> <Button variant="secondary">Open Callout</Button> </CalloutTrigger> <CalloutContent showCloseButton> <CalloutTitle title="Callout with close button" /> <CalloutDescription> A close icon will display in the top right. </CalloutDescription> </CalloutContent> </Callout>);Arrows
Section titled “Arrows”To display an arrow pointing to the trigger, set withArrow on <CalloutContent>.
import { Button } from "stylus-ui/Button";import { Callout, CalloutContent, CalloutDescription, CalloutTitle, CalloutTrigger,} from "stylus-ui/Callout";
export default () => ( <Callout> <CalloutTrigger asChild> <Button variant="secondary">Open Callout</Button> </CalloutTrigger> <CalloutContent withArrow> <CalloutTitle title="Callout with arrow" /> <CalloutDescription> An arrow points to the callout trigger. </CalloutDescription> </CalloutContent> </Callout>);Images
Section titled “Images”To display an image in the callout, import <CalloutImg>. Pass an <img> or NextJS <Image> component as a child.
import { Button } from "stylus-ui/Button";import { Callout, CalloutContent, CalloutDescription, CalloutImg, CalloutTitle, CalloutTrigger,} from "stylus-ui/Callout";
export default () => ( <Callout> <CalloutTrigger asChild> <Button variant="secondary">Open Callout</Button> </CalloutTrigger> <CalloutContent> <CalloutImg> <img src="https://cdn.prod.website-files.com/615f415173b71a5211e28de7/654ac9c921b76a875209ffbe_auto-redact.webp" className="w-full" /> </CalloutImg> <CalloutTitle title="Callout with image" /> <CalloutDescription> Highlight product features with images. </CalloutDescription> </CalloutContent> </Callout>);API Reference
Section titled “API Reference”Callout
Section titled “Callout”A high-contrast popover to draw attention to features and information.
defaultOpen
modal
onOpenChange
open
CalloutAnchor
Section titled “CalloutAnchor”Use this to position Callout without a trigger.
asChild
virtualRef
CalloutTrigger
Section titled “CalloutTrigger”The trigger that, when clicked, opens a Callout.
asChild
CalloutArrow
Section titled “CalloutArrow” asChild
CalloutClose
Section titled “CalloutClose” asChild
CalloutTitle
Section titled “CalloutTitle”A title for a Callout.
title
Heading text.
className
Classes for the title wrapper.
icon
Optional icon before the title.
iconClassName
Classes for the icon.
titleClassName
Classes for the title text.
CalloutImg
Section titled “CalloutImg”An image for a Callout.
children
Image or media content to display in the callout.
CalloutDescription
Section titled “CalloutDescription”A description for a Callout.
children
Body text or content below the title.
className
Optional class for the description wrapper.
CalloutContent
Section titled “CalloutContent”The content of a Callout. Renders the container with contents, an optional close button, and optional
primary and secondary actions.
children
Main content (title, description, etc.).
align
alignOffset
arrowPadding
asChild
avoidCollisions
collisionBoundary
collisionPadding
forceMount
Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
hideWhenDetached
onCloseAction
Called when the user clicks the close button.
onCloseAutoFocus
Event handler called when auto-focusing on close. Can be prevented.
onEscapeKeyDown
Event handler called when the escape key is down. Can be prevented.
onFocusOutside
Event handler called when the focus moves outside of the DismissableLayer.
Can be prevented.
onInteractOutside
Event handler called when an interaction happens outside the DismissableLayer.
Specifically, when a pointerdown event happens outside or focus moves outside of it.
Can be prevented.
onOpenAutoFocus
Event handler called when auto-focusing on open. Can be prevented.
onPointerDownOutside
Event handler called when the a pointerdown event happens outside of the DismissableLayer.
Can be prevented.
portalContainer
DOM node to portal the callout into.
primaryAction
Click handler for the primary action button.
primaryActionText
Label for the primary action button.
secondaryAction
Click handler for the secondary action button.
secondaryActionText
Label for the secondary action button.
showCloseButton
Show a close (X) button in the header.
side
sideOffset
sticky
updatePositionStrategy
withArrow
Show a small arrow pointing at the trigger.