highlight.py 682 B

1234567891011121314151617181920212223
  1. """A highlight component."""
  2. from typing import List
  3. from pynecone.components.libs.chakra import ChakraComponent
  4. from pynecone.components.tags import Tag
  5. from pynecone.vars import Dict, Var
  6. class Highlight(ChakraComponent):
  7. """Highlights a specific part of a string."""
  8. tag = "Highlight"
  9. # A query for the text to highlight. Can be a string or a list of strings.
  10. query: Var[List[str]]
  11. # The style of the content.
  12. # Note: styles and style are different prop.
  13. styles: Var[Dict] = {"px": "2", "py": "1", "rounded": "full", "bg": "teal.100"} # type: ignore
  14. def _render(self) -> Tag:
  15. return super()._render().add_props(styles=self.style)