Skip to content
Discussion options

You must be logged in to vote

There are few discussion topics for this, but the solution is to use a variable. It's also used in the NextJS example in the repo.

Look at Card.tsx and how it uses a variable defined in CardTokens.stylex.ts

// CardTokens.stylex.ts

import * as stylex from '@stylexjs/stylex';

export const tokens = stylex.defineVars({
  arrowTransform: 'translateX(0)',
});
// Card.tsx

import * as stylex from '@stylexjs/stylex';
import { tokens } from '@/app/CardTokens.stylex';

const styles = stylex.create({
  link: {
    // ...
    [tokens.arrowTransform]: {
      default: 'translateX(0)',
      ':hover': 'translateX(4px)',
    },
  },
  span: {
    // ...
    transform: tokens.arrowTransform,
  },
  // ...

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Luko248
Comment options

Answer selected by nmn
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