12

createdByModal is basically a chakra modal and I'm using tooltip in it.Whenever i hover on the icons the tooltip shows me on the top of the screen instead of on top of the icon.In the photo you can see the ignore element is showing on the top left corner


enter image description here

const CreatedByModal = () => {
  return (
    <Stack
      spacing={"4"}
      margin={"0px !important"}
      alignItems={"center"}
      px={{ base: "2", lg: "6" }}
      pt={"2"}
    >
      <HStack justifyContent={"space-between"}>
        <Tooltip
          bg={"white"}
          textAlign={"center"}
          color={"black"}
          placement="top"
          label="Tip"
          aria-label="A tooltip"
        >
          <AiFillWallet size={"1.2rem"} color={"#b1bad3"} />
        </Tooltip>
        <Tooltip
          bg={"white"}
          textAlign={"center"}
          color={"black"}
          placement="top"
          label="Ignore"
          aria-label="A tooltip"
        >
          <AiFillEyeInvisible size={"1.2rem"} color={"#b1bad3"} />
        </Tooltip>
      </HStack>
    </Stack>
  );
};

1 Answer 1

10

Have you wrapped your components that want the tooltip with forwardRef?

https://chakra-ui.com/docs/components/tooltip#usage

Or wrap your icon component in a span

https://chakra-ui.com/docs/components/tooltip#with-an-icon

Sign up to request clarification or add additional context in comments.

2 Comments

Actually, I'm not using custom card to show tooltip. Anways, I wrapped the icon with span and it works. Thanks!! . May i know what issue i was having ??
I would assume it just needed a parent element of the icon to attach a position: relative style to

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.