X
X

Add Advanced CSS Styling to Framer Code Components

Link

Framer code components are powerful, but they have one limitation: you can’t include separate CSS files. This becomes problematic when you need to style pseudo-elements or use vendor-specific properties that don’t work with inline styles.

The solution is straightforward: create a multiline string variable for your CSS styles and inject it using a style tag. This gives you the full power of CSS while respecting Framer’s file constraints.

Example:

export default function Slider() {
  const style = \`
    input[type=range].customSlider {
        -webkit-appearance: none;
    }

    input[type=range].customSlider::-webkit-slider-thumb {
      -webkit-appearance: none;
      background: #f0591a;
      width: 16px;
      height: 16px;
      border-radius: 100%;
      cursor: pointer;
    }
  \`;
  return (
    <>
      <style>{style}</style>
      <input type="range" min={0} max={100} className="customSlider" />
    </>
  );
}