Welcome to another delicious UI recipe! If you want to impress your website visitors right from the moment they try to log in, a static form just won’t cut it anymore. Today, we are serving up a sleek, interactive dual-form component that houses both your Sign-In and Sign-Up forms in one beautiful, animated modal.

Instead of opening a new page, this design uses a sliding colored panel to smoothly transition between the two forms. It is lightweight, visually striking, and surprisingly easy to whip up.
Let’s break down the recipe and see how this code actually works!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- The title of the page that appears in the browser tab -->
<title>Sign Up - Sign In Forms</title>
<!-- Link to the external CSS file.
This file handles the layout, colors, and most importantly, the transition animations
triggered by the '.navigate' class. -->
<link rel="stylesheet" href="style.css" />
<!-- FontAwesome CDN link used to render the icons (user, envelope, and lock) inside the form inputs -->
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"
/>
<!-- Google Fonts preconnections to load the 'Signika Negative' and 'Handlee' typography -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Signika+Negative:wght@300;400;500;600;700&display=swap"
rel="stylesheet"
/>
</head>
<body>
<!-- MAIN CONTAINER:
This is the parent element for the entire UI.
HOW IT WORKS: JavaScript listens for clicks on the links below.
When "Sign Up" is clicked, JS adds a class called "navigate" to this container.
When "Sign In" is clicked, JS removes the "navigate" class.
The CSS uses this class to trigger all the sliding and fading animations. -->
<div class="container">
<!-- FORM WRAPPER: The main white modal card positioned in the center of the screen -->
<div class="form-wrapper">
<!-- ILLUSTRATIONS:
These are the two images. By default, the 'img-left' (Sign In image) is visible.
When the '.navigate' class is active, CSS fades out 'img-left' and fades in 'img-right' (Sign Up image). -->
<img src="images/sign-in.png" class="img-left" alt="Sign In Illustration" />
<img src="images/sign-up.png" class="img-right" alt="Sign Up Illustration" />
<!-- ANIMATED BACKGROUND:
This is the solid colored shape (the mint green block).
By default, it covers the left side.
When '.navigate' is triggered, CSS transformations (rotateZ, translateX, translateY)
smoothly slide this shape to the right side over 1.5 seconds. -->
<div class="form-wrapper-bg"></div>
<!-- ==========================================
SIGN UP SECTION (Left Side)
==========================================
This section is hidden by default (opacity: 0, visibility: hidden).
It fades in when the '.navigate' class is applied to the container. -->
<div class="form-wrapper-left">
<h1>Sign Up</h1>
<form class="form-signup">
<div class="input-group">
<input type="text" placeholder="Username" />
<i class="fa-solid fa-user"></i>
</div>
<div class="input-group">
<input type="email" placeholder="Email" />
<i class="fa-solid fa-envelope"></i>
</div>
<div class="input-group">
<input type="password" placeholder="Password" />
<i class="fa-solid fa-lock"></i>
</div>
<button class="form-btn" type="button">Sign Up</button>
</form>
<!-- SIGN IN TRIGGER: Clicking this link executes the JS code to remove the '.navigate' class, sliding back to the Sign In state. -->
<a href="#" class="signin-link">Sign In</a>
</div>
<!-- ==========================================
SIGN IN SECTION (Right Side)
==========================================
This section is visible by default.
It fades out when the '.navigate' class is applied to the container. -->
<div class="form-wrapper-right">
<h1>Sign In</h1>
<form class="form-signin">
<div class="input-group">
<input type="text" placeholder="Username" />
<i class="fa-solid fa-user"></i>
</div>
<div class="input-group">
<input type="password" placeholder="Password" />
<i class="fa-solid fa-lock"></i>
</div>
<button class="form-btn" type="button">Sign In</button>
</form>
<!-- SIGN UP TRIGGER: Clicking this link executes the JS code to add the '.navigate' class, sliding over to the Sign Up state. -->
<a href="#" class="signup-link">Sign Up</a>
</div>
</div>
</div>
<!-- Link to the external JavaScript file.
This file contains the logic that listens for the 'click' events on '.signup-link' and '.signin-link'
and toggles the '.navigate' class on the '.container' div. -->
<script src="script.js"></script>
</body>
</html>* {
margin: 0;
padding: 0;
box-sizing: border-box;
outline: none;
text-decoration: none;
font-family: "Handlee";
}
html {
font-size: 62.5%;
}
.container {
width: 100%;
height: 100vh;
background-color: #ecf2ff;
position: relative;
}
.form-wrapper {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 100rem;
height: 65rem;
background-color: #fff;
display: flex;
border-radius: 2rem;
box-shadow: 0 0.3rem 3rem rgba(32, 61, 127, 0.3);
overflow: hidden;
}
.form-wrapper-bg {
position: absolute;
width: 100rem;
height: 100rem;
background-color: #6cd17d;
border-radius: 15rem;
left: -40%;
top: -90%;
transform-origin: right bottom;
transform: rotateZ(-40deg);
transition: transform 1.5s;
}
.navigate .form-wrapper-bg {
transform: rotateZ(130deg) translateX(15rem) translateY(15rem);
}
.form-wrapper img {
width: 35rem;
position: absolute;
z-index: 100;
}
.img-left {
top: 25%;
left: 8%;
transition: all 0.5s 1s;
}
.navigate .img-left {
opacity: 0;
visibility: hidden;
transform: translateY(-5rem);
transition: all 0.5s;
}
.img-right {
top: 17%;
right: 7%;
opacity: 0;
visibility: hidden;
transform: translateY(-5rem);
transition: all 0.5s;
}
.navigate .img-right {
opacity: 1;
visibility: visible;
transform: translateY(5rem);
transition: all 0.5s 1s;
}
.form-wrapper-left,
.form-wrapper-right {
width: 50%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
}
.form-wrapper-left {
opacity: 0;
visibility: hidden;
transition: all 0.5s;
}
.navigate .form-wrapper-left {
opacity: 1;
visibility: visible;
transition: all 0.5s 1s;
}
.form-wrapper-right {
transition: all 0.5s 1s;
}
.navigate .form-wrapper-right {
opacity: 0;
visibility: hidden;
transition: all 0.5s;
}
.form-wrapper h1 {
font-size: 6rem;
color: #6cd17d;
margin: -5rem 0 6rem 0;
}
.input-group {
position: relative;
}
.input-group input {
width: 25rem;
height: 5rem;
margin: 1rem 0;
border: none;
border-bottom: 0.2rem solid rgba(60, 223, 168, 0.4);
color: #6cd17d;
font-size: 1.4rem;
padding-right: 2rem;
background-color: transparent;
}
.input-group input::placeholder {
color: #6cd17d;
letter-spacing: 0.1rem;
font-size: 1.2rem;
font-weight: 500;
text-transform: uppercase;
}
.input-group input:focus {
border-color: #6cd17d;
}
.input-group i {
position: absolute;
top: 50%;
right: 0.5rem;
transform: translateY(-50%);
font-size: 1.3rem;
color: #6cd17d;
}
.form-btn {
width: 20rem;
height: 4.5rem;
margin-top: 2rem;
border: none;
border-radius: 5rem;
background-color: #6cd17d;
color: #fff;
text-transform: uppercase;
font-size: 1.4rem;
font-weight: bold;
letter-spacing: 0.1rem;
box-shadow: 0 0.5rem 1rem rgba(60, 223, 168, 0.4);
cursor: pointer;
}
.form-btn:active {
transform: translateY(0.2rem);
}
.form-wrapper a {
position: absolute;
bottom: 4rem;
font-size: 1.6rem;
text-transform: uppercase;
font-weight: bold;
color: #6cd17d;
}
.signup-link {
right: 4rem;
}
.signin-link {
left: 4rem;
}
/**
* ==============================================================================
* SLIDING POPUP MODAL NAVIGATION SCRIPT
* ==============================================================================
*
* Overview:
* This script manages the state switching between the Sign-In and Sign-Up forms.
* It operates by toggling the CSS class '.navigate' on the main container element.
* All dynamic visual transitions (animations, sliding backgrounds, opacity shifts)
* are handled by CSS based on the presence or absence of this class.
*/
// 1. SELECT DOM ELEMENTS
// ------------------------------------------------------------------------------
// Select the main parent container that wraps the entire modal component.
// Adding/removing classes on this top-level element allows CSS rules to target
// child elements seamlessly (e.g., .navigate .form-wrapper-bg).
const container = document.querySelector(".container");
// Select the trigger links that allow users to toggle between forms.
const signUpLink = document.querySelector(".signup-link");
const signInLink = document.querySelector(".signin-link");
// 2. EVENT LISTENERS & STATE CONTROLLERS
// ------------------------------------------------------------------------------
/**
* Event Listener: Sign Up Link Click
* -----------------------------------
* When a user clicks the "Sign Up" link:
* - The 'navigate' class is appended to the main container.
* - CSS triggers the sliding background animation to move to the right.
* - CSS hides the Sign-In form & left image, while revealing the Sign-Up form & right image.
*/
signUpLink.addEventListener("click", () => {
container.classList.add("navigate");
});
/**
* Event Listener: Sign In Link Click
* -----------------------------------
* When a user clicks the "Sign In" link:
* - The 'navigate' class is removed from the main container.
* - CSS triggers the sliding background animation to move back to the left.
* - CSS reveals the Sign-In form & left image, while hiding the Sign-Up form & right image.
*/
signInLink.addEventListener("click", () => {
container.classList.remove("navigate");
});🍳 How the Magic Happens (The Code Breakdown)
This component relies on a perfect harmony between HTML for structure, CSS for the heavy-lifting animations, and a tiny sprinkle of JavaScript to trigger the actions.
- The HTML (The Structure): In the
index.htmlfile, we set up a main.containerthat holds a single.form-wrapper. Inside this wrapper, we place both the “Sign Up” and “Sign In” forms side-by-side, along with two overlapping illustration images. Everything is loaded upfront, meaning there is zero loading time when the user switches between forms. - The CSS (The Flavor & Animation): The
style.cssfile is the true star of this dish. By using absolute positioning and flexbox, we stack the elements perfectly. The sliding effect is achieved by manipulating a background shape (.form-wrapper-bg). When the.navigateclass is active, CSS transformations (rotateZ,translateX, andtranslateY) smoothly rotate and shift this background across the screen. We also usetransition-delayto ensure the text and images fade in and out at exactly the right moment, creating a choreographed, fluid motion. - The JavaScript (The Trigger): The
script.jsfile is kept incredibly light. It only has one job: listening for clicks. When a user clicks the “Sign Up” link, the script adds the.navigateclass to the main container. When they click “Sign In”, it removes that class. JavaScript hands the baton right back to CSS to execute the beautiful animations.
🎨 Make It Your Own: Customizable Variables
Want to tweak this recipe to match your brand’s unique taste? Here are the most important values in the style.css file that you can safely change:
1. The Color Palette (Brand Colors)
- Primary Accent Color (
#6cd17d): This lovely mint green is used for the sliding background card, headings, buttons, icons, and input borders. UseCtrl+F(orCmd+F) in your CSS file to find and replace#6cd17dwith your own brand’s hex code! - Page Background (
#ecf2ff): This is the soft blue background of the main.container. Change this to match your website’s primary background.
2. Animation Speeds & Delays
- The Big Slide (
transition: transform 1.5s;): Found in.form-wrapper-bg, this1.5sdictates how long the background takes to slide across the screen. Reduce it to1.0sfor a snappier feel, or increase it for a dramatic slow-motion effect. - The Fade-ins (
transition: all 0.5s 1s;): Applied to the forms and images. The0.5sis how fast the element fades in, and the1sis the delay (waiting for the background to move first). Tweak these to perfect the timing!
3. Card Dimensions & Geometry
- Popup Size (
width: 100rem; height: 65rem;): Located in.form-wrapper, this sets the total size of your modal. If you add more input fields (like “Confirm Password” or “Phone Number”), you might want to increase the height. - The Sliding Angle (
rotateZ): The background shape usesrotateZ(-40deg)by default and shifts torotateZ(130deg)when active. If you change the width or height of the modal, you may need to play with these degree values so the background covers the forms perfectly.
Happy Coding! Feel free to copy this snippet, swap out the images, update the colors, and serve it up to your users.