SolidJSS
SolidJSโ€ข3y agoโ€ข
6 replies
Kyros

Add props to an element programmatically

In one of my components, I pass an element as a prop, although I'd like to add the class argument to it in order to style it.
import styles from "./css/MyElement.module.css";

interface Props {
  src: JSX.Element;
}

export default function MyElement(props: Props) {
  return (
      <div class={styles.wrapper}>
          {props.src} // props.src.addAttribute("class", {styles.my_class}) or smt would be nice, or anything that achieves the same result too
      </div>
    );
}
Was this page helpful?