Skip to content

Alert

Alerts provide contextual feedback for user actions — info, success, warning, and error.

Use Alert for inline status on a screen. For blocking decisions, prefer Dialog or AlertDialog.

Compound children inherit severity text color automatically — no manual color on AlertTitle or body Typography.

import { Alert, AlertTitle, Typography } from '@truongdq01/ui';
<Alert severity="success">
<AlertTitle>Success</AlertTitle>
<Typography variant="body2">Your changes have been saved.</Typography>
</Alert>;

Plain string/number children are wrapped in Text internally (React Native requirement).

<Alert variant="standard" severity="info">
<AlertTitle>Info</AlertTitle>
Standard fill + 1px severity border
</Alert>
<Alert variant="filled" severity="error">
<Typography variant="body2" color="inverse">
Filled — use inverse text on saturated background
</Typography>
</Alert>
<Alert variant="outlined" severity="warning">
<Typography variant="body2">Outlined — transparent fill, severity border</Typography>
</Alert>
PropTypeDefaultDescription
severityerror | warning | info | successinfoSeverity (color + default icon)
variantstandard | filled | outlinedstandardVisual variant
onClose() => void—Shows close control when set
iconReactNode | false—Custom icon or hide icon
actionReactNode—Trailing action (e.g. Button)
childrenReactNode—Message or compound layout
ChildBehavior
AlertTitleInherits severity text color from parent
Typography without colorCloned with severity color
Typography with explicit colorPreserved (e.g. color="brand")
Plain string / numberWrapped in Text with severity color
import { useAlert } from '@truongdq01/headless';
import { Alert, Button } from '@truongdq01/ui';
const MyAlert = () => {
const { isOpen, close, getAlertProps } = useAlert({
onClose: () => console.log('closed'),
});
if (!isOpen) return <Button label="Show" onPress={() => {}} />;
return (
<Alert severity="info" onClose={close} {...getAlertProps()}>
Managed by useAlert
</Alert>
);
};

Native demos: apps/example → Alert screen — standard, filled, outlined, and action variants.

See Example app guide and Visual Baseline.