Callout

Short message to attract user's attention.

use radix_yew_icons::InfoCircledIcon;
use radix_yew_themes::{Callout, CalloutIcon, CalloutText};
use yew::prelude::*;

#[function_component]
pub fn CalloutExample() -> Html {
    html! {
        <Callout>
            <CalloutIcon>
                <InfoCircledIcon />
            </CalloutIcon>
            <CalloutText>
                {"You will need admin privileges to install and access this application."}
            </CalloutText>
        </Callout>
    }
}

API Reference

Root

Groups Icon and Text parts. This component is based on the div element and supports common margin props.

PropTypeDefault
as_childOption<Callback<CalloutChildProps>>-
sizeResponsive<1..3>1
variantCalloutVariantCalloutVariant::Soft
colorOption<AccentColor>-
high_contrastOption<bool>-

Icon

Provides width and height for the icon associated with the callout. This component is based on the div element.

Text

Renders the callout text. This component is based on the p element.

Examples

Size

Use the size prop to control the size.

use radix_yew_icons::InfoCircledIcon;
use radix_yew_themes::{Callout, CalloutIcon, CalloutText, Flex, FlexAlign, FlexDirection};
use yew::prelude::*;

#[function_component]
pub fn CalloutSizeExample() -> Html {
    html! {
        <Flex direction={FlexDirection::Column} gap=3 align={FlexAlign::Start}>
            <Callout size=1>
                <CalloutIcon>
                    <InfoCircledIcon />
                </CalloutIcon>
                <CalloutText>
                    {"You will need admin privileges to install and access this application."}
                </CalloutText>
            </Callout>

            <Callout size=2>
                <CalloutIcon>
                    <InfoCircledIcon />
                </CalloutIcon>
                <CalloutText>
                    {"You will need admin privileges to install and access this application."}
                </CalloutText>
            </Callout>

            <Callout size=3>
                <CalloutIcon>
                    <InfoCircledIcon />
                </CalloutIcon>
                <CalloutText>
                    {"You will need admin privileges to install and access this application."}
                </CalloutText>
            </Callout>
        </Flex>
    }
}

Variant

Use the variant prop to control the visual style.

use radix_yew_icons::InfoCircledIcon;
use radix_yew_themes::{
    Callout, CalloutIcon, CalloutText, CalloutVariant, Flex, FlexDirection, Link,
};
use yew::prelude::*;

#[function_component]
pub fn CalloutVariantExample() -> Html {
    html! {
        <Flex direction={FlexDirection::Column} gap=3>
            <Callout variant={CalloutVariant::Soft}>
                <CalloutIcon>
                    <InfoCircledIcon />
                </CalloutIcon>
                <CalloutText>
                    {"You will need "}<Link href="#">{"admin privileges"}</Link>{" to install and access
                    this application."}
                </CalloutText>
            </Callout>

            <Callout variant={CalloutVariant::Surface}>
                <CalloutIcon>
                    <InfoCircledIcon />
                </CalloutIcon>
                <CalloutText>
                    {"You will need "}<Link href="#">{"admin privileges"}</Link>{" to install and access
                    this application."}
                </CalloutText>
            </Callout>

            <Callout variant={CalloutVariant::Outline}>
                <CalloutIcon>
                    <InfoCircledIcon />
                </CalloutIcon>
                <CalloutText>
                    {"You will need "}<Link href="#">{"admin privileges"}</Link>{" to install and access
                    this application."}
                </CalloutText>
            </Callout>
        </Flex>
    }
}

Color

Use the color prop to assign a specific color.

use radix_yew_icons::InfoCircledIcon;
use radix_yew_themes::{AccentColor, Callout, CalloutIcon, CalloutText, Flex, FlexDirection, Link};
use yew::prelude::*;

#[function_component]
pub fn CalloutColorExample() -> Html {
    html! {
        <Flex direction={FlexDirection::Column} gap=3>
            <Callout color={AccentColor::Blue}>
                <CalloutIcon>
                    <InfoCircledIcon />
                </CalloutIcon>
                <CalloutText>
                    {"You will need "}<Link href="#">{"admin privileges"}</Link>{" to install and access
                    this application."}
                </CalloutText>
            </Callout>

            <Callout color={AccentColor::Green}>
                <CalloutIcon>
                    <InfoCircledIcon />
                </CalloutIcon>
                <CalloutText>
                    {"You will need "}<Link href="#">{"admin privileges"}</Link>{" to install and access
                    this application."}
                </CalloutText>
            </Callout>

            <Callout color={AccentColor::Red}>
                <CalloutIcon>
                    <InfoCircledIcon />
                </CalloutIcon>
                <CalloutText>
                    {"You will need "}<Link href="#">{"admin privileges"}</Link>{" to install and access
                    this application."}
                </CalloutText>
            </Callout>
        </Flex>
    }
}

High-Contrast

Use the high_contrast prop to increase color contrast.

use radix_yew_icons::InfoCircledIcon;
use radix_yew_themes::{
    AccentColor, Callout, CalloutIcon, CalloutText, CalloutVariant, Flex, FlexDirection,
};
use yew::prelude::*;

#[function_component]
pub fn CalloutHighContrastExample() -> Html {
    html! {
        <Flex direction={FlexDirection::Column} gap=3>
            <Callout color={AccentColor::Gray} variant={CalloutVariant::Soft}>
                <CalloutIcon>
                    <InfoCircledIcon />
                </CalloutIcon>
                <CalloutText>
                    {"An update to Radix Themes is available. See what's new in version 3.2.0."}
                </CalloutText>
            </Callout>

            <Callout color={AccentColor::Gray} variant={CalloutVariant::Soft} high_contrast=true>
                <CalloutIcon>
                    <InfoCircledIcon />
                </CalloutIcon>
                <CalloutText>
                    {"An update to Radix Themes is available. See what's new in version 3.2.0."}
                </CalloutText>
            </Callout>
        </Flex>
    }
}

As Alert

Add a native WAI-ARIA alert role to the callout when the user's immediate attention is required, like when an error message appears. The screen reader will be interrupted, announcing the new content immediately.

use radix_yew_icons::ExclamationTriangleIcon;
use radix_yew_themes::{AccentColor, Callout, CalloutIcon, CalloutText};
use yew::prelude::*;

#[function_component]
pub fn CalloutAsAlertExample() -> Html {
    html! {
        <Callout color={AccentColor::Red} role="alert">
            <CalloutIcon>
                <ExclamationTriangleIcon />
            </CalloutIcon>
            <CalloutText>
                {"Access denied. Please contact the network administrator to view this page."}
            </CalloutText>
        </Callout>
    }
}

See Also