Skip to content
Discussion options

You must be logged in to vote

You could use a css variable combined with assignInlineVars. Something like this:

// MyComponent.css.ts
import { createVar } from '@vanilla-extract/css';

export const contentVar = createVar();

export const shoppingCartIcon = style({
  selectors: {
    ['&:after']: {
      content: contentVar
    }
  }
});

// MyComponent.tsx
import * as styles from "./MyComponent.css";
import { assignInlineVars } from "@vanilla-extract/dynamic";

const MyComponent = () => {
  const content = getShoppingCartItems();

  return (
    <div
      className={styles.shoppingCartIcon}
      style={assignInlineVars({ [styles.contentVar]: content })}
    />
  );
};

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by javierrey
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants