Skip to content

Map dynamic variables to css variables #78

@danieldelcore

Description

@danieldelcore

... to avoid remounting the same styles with dynamic expressions multiple times...

Inspired by https://compiledcssinjs.com/

import React from 'react';
import { CC, CS } from '@compiled/css-in-js';
export const EmphasisText = (props) => {
  const color = props.massive ? '#00B8D9' : '#36B37E';
  return (
    <CC>
      <CS hash="vmwvfg">
        {[
          '.cc-vmwvfg{color:var(--var-1ylxx6h);text-transform:uppercase;font-weight:600}',
        ]}
      </CS>
      <span className="cc-vmwvfg" style={{ '--var-1ylxx6h': color }}>
        {props.children}
      </span>
    </CC>
  );
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions