Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="root"></div>
              
            
!

CSS

              
                body {
    background-color: #000;
}

.shine {
    background-image: repeating-linear-gradient(
        125deg, 
        transparent 0%,
        transparent 15%,
        #fff4 25%,
        transparent 35%,
        transparent 50%
    );
    background-size: 200%;
    background-position: calc(var(--mx) + 20%) var(--my);
}

.glow {
    background-image: radial-gradient(
        100% 50% at calc(50% - var(--mx)) 0%,
        #fff4 0%,
        transparent 80%
    ),
    radial-gradient(
        100% 50% at calc(var(--mx) + 50%) 100%,
        #fff4 0%,
        transparent 80%
    )
}
              
            
!

JS

              
                import React, {
    useEffect,
    useRef,
    useState
} from "https://esm.sh/react@18.2.0";
import ReactDOM from "https://esm.sh/react-dom@18.2.0";

function App() {
    return (
        <div className="w-screen h-screen flex items-center justify-center text-white">
            <Button />
        </div>
    );
}

function Button() {
    const buttonRef = useRef(null);
    const [mouseX, setMouseX] = useState<number>(0.5);
    const [mouseY, setMouseY] = useState<number>(0.5);
    
    const mouseMove = (e) => {
        const rect = buttonRef.current.getBoundingClientRect();
        setMouseX((e.clientX - rect.left) / rect.width);
        setMouseY((e.clientY - rect.top) / rect.height);
    };
    
    return (
        <button
            ref={buttonRef}
            onPointerMove={mouseMove}
            className="group relative py-3.5 px-7 rounded-[20px] bg-zinc-800 overflow-hidden"
        >
            <div className="absolute inset-0 opacity-0 group-hover:opacity-100 transition-opacity duration-300"
                style={{
                    "--mx": `${mouseX * 100}%`,
                    "--my": `${mouseY * 100}%`
                }}
            >
               <div className="absolute inset-0 glow"></div>
               <div className="absolute inset-0 shine mix-blend-screen"></div>
            </div>
            <div className="absolute inset-0.5 rounded-[18px] bg-zinc-900/75"></div>
            <div className="relative text-zinc-300 group-hover:text-zinc-50 transition-colors duration-100">
                Shiny Button
            </div>
        </button>
    )
}

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<App />);

              
            
!
999px

Console