/images/blog/how-to-add-advanced-css-styling-to-framer-code-components/framer-code-component-with-css-4.webp

How to Add Advanced CSS Styling to Framer Code Components

April 3, 2025

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" />
    </>
  );
}

This example shows how to customize a range slider's thumb appearance using -webkit-appearance and pseudo-elements - something impossible with regular inline styling.

This technique essentially embeds a CSS file within your JavaScript, giving you complete styling flexibility within Framer's component structure.

Author: David McBacon

Sign up for the newsletter_

Get notifications about the latest Framer components or templates from BACHOFF Studio directly to your inbox.