box.py 815 B

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