box.py 768 B

12345678910111213141516171819202122232425262728293031
  1. """A box component that can contain other components."""
  2. from pynecone.components.libs.chakra import ChakraComponent
  3. from pynecone.components.tags import Tag
  4. from pynecone.var import Var
  5. class Box(ChakraComponent):
  6. """A generic container component that can contain other components."""
  7. tag = "Box"
  8. # The type element to render. You can specify as an image, video, or any other HTML element such as iframe.
  9. element: Var[str]
  10. # The source of the content.
  11. src: Var[str]
  12. # The alt text of the content.
  13. alt: Var[str]
  14. def _render(self) -> Tag:
  15. return (
  16. super()
  17. ._render()
  18. .add_props(
  19. **{
  20. "as": self.element,
  21. }
  22. )
  23. )