link.py 746 B

123456789101112131415161718192021222324252627282930
  1. """A link component."""
  2. from pynecone.components.libs.chakra import ChakraComponent
  3. from pynecone.components.navigation.nextlink import NextLink
  4. from pynecone.utils import imports
  5. from pynecone.vars import BaseVar, Var
  6. class Link(ChakraComponent):
  7. """Link to another page."""
  8. tag = "Link"
  9. # The rel.
  10. rel: Var[str]
  11. # The page to link to.
  12. href: Var[str]
  13. # The text to display.
  14. text: Var[str]
  15. # What the link renders to.
  16. as_: Var[str] = BaseVar.create("{NextLink}", is_local=False) # type: ignore
  17. # If true, the link will open in new tab.
  18. is_external: Var[bool]
  19. def _get_imports(self) -> imports.ImportDict:
  20. return {**super()._get_imports(), **NextLink.create()._get_imports()}