Components
'use client' ;
import { Alert, AlertAction, AlertDescription, AlertTitle } from '@/registry/san-francisco/ui/alert' ;
import { Button } from '@/registry/san-francisco/ui/button' ;
export default function AlertDemo () {
return (
< Alert className = "max-w-sm" >
< AlertTitle >Heads up!</ AlertTitle >
< AlertDescription >You can add components to your app using the CLI.</ AlertDescription >
</ Alert >
);
}
Show code
bunx shadcn@latest add @sft-ui/alert
'use client' ;
import { Alert, AlertAction, AlertDescription, AlertTitle } from '@/registry/san-francisco/ui/alert' ;
import { Button } from '@/registry/san-francisco/ui/button' ;
export default function AlertDemoVariants () {
return (
<>
< Alert variant = "default" className = "max-w-sm" >
< AlertTitle >Default</ AlertTitle >
< AlertDescription >This is a default alert.</ AlertDescription >
</ Alert >
< Alert variant = "destructive" className = "max-w-sm" >
< AlertTitle >Error</ AlertTitle >
< AlertDescription >Something went wrong.</ AlertDescription >
</ Alert >
</>
);
}
Show code
'use client' ;
import { Alert, AlertAction, AlertDescription, AlertTitle } from '@/registry/san-francisco/ui/alert' ;
import { Button } from '@/registry/san-francisco/ui/button' ;
export default function AlertDemoWithAction () {
return (
< Alert className = "max-w-sm" >
< AlertTitle >Update available</ AlertTitle >
< AlertDescription >A new version is ready to install.</ AlertDescription >
< AlertAction >
< Button variant = "outline" size = "sm" >
Update
</ Button >
</ AlertAction >
</ Alert >
);
}
Show code
The root alert container with role="alert".
Prop Type Default Description variant"default" | "destructive""default"The visual style of the alert. classNamestring— Additional CSS classes to apply.
All standard HTML div attributes are supported.
The heading text of the alert.
The body text of the alert.
An absolutely positioned container (top-right) for action elements like a dismiss button.