Skip to content

Commit

Permalink
feat(compositions): add alert
Browse files Browse the repository at this point in the history
  • Loading branch information
segunadebayo committed Jun 19, 2024
1 parent 1c26920 commit f813129
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/react/composition/alert.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { forwardRef } from "react"
import { Box, Alert as ChakraAlert } from "../src"

export interface AlertProps extends ChakraAlert.RootProps {
title?: string
icon?: React.ReactElement
}

export const Alert = forwardRef<HTMLDivElement, AlertProps>(
function Alert(props, ref) {
const { title, children, icon, ...rest } = props
return (
<ChakraAlert.Root ref={ref} {...rest}>
<ChakraAlert.Icon>{icon}</ChakraAlert.Icon>
{children ? (
<Box>
<ChakraAlert.Title>{title}</ChakraAlert.Title>
<ChakraAlert.Description>{children}</ChakraAlert.Description>
</Box>
) : (
<ChakraAlert.Title>{title}</ChakraAlert.Title>
)}
</ChakraAlert.Root>
)
},
)

0 comments on commit f813129

Please sign in to comment.