I have been able create the above part but I want to create the as shown in the bottom part of the image highlighted by the red circle. I have to use Chakra UI 2.10.4 in React
my code:
<Box bg={"white"} rounded={"sm"} w={"100%"} p={5}>
<Flex justifyContent={"space-between"} align={"center"}>
<HStack>
<Text fontWeight={"bold"}>Accelerator Program</Text>
<RiInformation2Line />
</HStack>
<Box position={"relative"} overflow={"visible"}>
<Button
bg={"green.400"}
color={"white"}
size={"xs"}
px={4}
py={2}
borderRadius={"sm"}
boxShadow={"lg"}
pos={"absolute"}
top={"-5px"} //Move button slightly upwards
right={"-30px"} //adjust for 3D effect
_hover={{ bg: "green.500" }}
>
Cohart Number: N/A
</Button>
<Text fontSize={"xx-small"} mt={8}>
<b>Time Spent:</b> 0hr 0m
</Text>
</Box>
</Flex>
</Box>
how do i achieve the same? is there chakra ui snippet or some other library that gets this?
2
Answers
You need to write some CSS to achieve that.
You can add a
&::before
pseudoelement to the button and then useposition: absolute
to position it where you want it, the Button needs position: relative to contain the::before
.You can create that shape with CSS for the
::before
: https://www.cssportal.com/css-triangle-generator/Using
::after
you can solve using clipPath and using css triangle both, here is the completed code for your instance:and same using css triangle:
Both ::before and ::after pseudo-elements are used to insert content before or after the content of an element, respectively. They are often used for decorative purposes, such as adding icons or shapes.