box.py 814 B

1234567891011121314151617181920212223242526272829303132
  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. from typing import Optional
  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. )