Skip to content

Sliding Login and Register Form

Pure CSS sign in and sign up forms with a gradient overlay panel that slides between them, plus a mobile switcher and client-side validation.

Also known as: login and signup form, sign in sign up toggle, sliding auth form, login register page

Sliding Login and Register Form live demo

Open in new tab

Pure CSS code (HTML, CSS, JS)

A combined sign in and sign up card built with pure CSS and vanilla JavaScript. On desktop the two forms sit side by side and a plum-to-orange gradient panel slides across to cover the inactive one; on phones the card turns into a single form with a segmented switcher. Use it for SaaS dashboards or community sites that offer login and registration in one place.

How it works

The root section.slr-auth holds one .slr-box. Inside are the mobile .slr-switcher, the two form panels .slr-panel--signin and .slr-panel--signup, and the .slr-overlay-wrap with a .slr-overlay that contains two .slr-overlay-pane blocks (left and right).

From 768px the panels are absolutely positioned at 50% width. The overlay wrapper covers the right half, and the gradient .slr-overlay inside it is twice as wide and shifted left by 100%, so each half of the wrapper shows one pane. Adding is-signup to .slr-box moves the sign up panel to the right, slides the wrapper to the left half and shifts the inner overlay by 50% in the opposite direction, which produces the smooth double slide. Below 768px the overlay is hidden and is-signup simply swaps which panel is displayed.

The script handles every .slr-box on the page. Any element with data-slr-mode (the overlay buttons and the switcher) calls setMode(), which toggles is-signup, updates aria-pressed and sets inert on the hidden panel and overlay pane. Each .slr-form uses novalidate; on submit validateField() checks required fields, the email format and the minimum password length, writes messages into the matching .slr-error element and focuses the first invalid input. Valid forms show a short loading state and a success message in .slr-status.

Customization

  • --slr-overlay on .slr-auth: the gradient used by the sliding panel, the submit buttons and the active switcher tab.
  • --slr-accent: focus border of inputs, links, checkbox color and focus outlines.
  • --slr-speed and --slr-ease: duration and easing of the slide, e.g. 0.45s for a quicker swap.
  • --slr-height: height of the desktop card; raise it if you add fields.
  • Add is-signup to .slr-box in the markup to open the card on the registration form.
  • MIN_PASSWORD in script.js: the minimum password length checked before submit.
  • Replace the window.setTimeout call (delay FAKE_DELAY) in the submit handler with a fetch() to your authentication endpoint.

Use cases

  • SaaS dashboards: one card offers sign in and registration, with a gradient panel sliding between them
  • Community sites: new and returning members switch forms without leaving the page
  • Mobile signups: on phones a segmented switcher swaps between the two forms
  • Account pages: client-side validation checks the email and password length before submitting

Accessibility

Every input has a visible label, a matching autocomplete value and aria-describedby pointing to its hint and error text. Invalid fields get aria-invalid="true", and results are announced through role="status". Each form is labelled by its heading. The inactive form and overlay pane are made inert, so keyboard and screen reader users only reach the visible content; switching through the overlay moves focus to the first field of the new form. Focus outlines use --slr-accent, and prefers-reduced-motion: reduce turns off the sliding transitions.

Usage notes

The demo never submits; validate again on your server. Element IDs end in -1, so give them a new suffix when you place a second card on the same page.

Sliding Login and Register Form at a glance

Framework
Pure CSS
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
None
Layout
Responsive, works on mobile
Category
Login & Sign Up
License
Free for personal and commercial use

Questions about this template

Can I use the Sliding Login and Register Form code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

There is nothing to install. Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

No dependencies. Pure HTML, CSS and JavaScript.

Sliding Login and Register Form – free Pure CSS login & sign up form template
Sliding Login and Register Form · free Pure CSS login & sign up form template

More Login & Sign Up

Login Form with Floating Labels – free Pure CSS login & sign up form template

Login Form with Floating Labels

Clean pure CSS login card with animated floating labels, show/hide password, inline validation and a simulated sign-in state in vanilla JavaScript.

Forgot Password Form – free Tailwind CSS login & sign up form template

Forgot Password Form

Tailwind CSS forgot password form with email validation, loading spinner, check-your-inbox success state and a resend cooldown timer.

Signup Form with Validation – free Bootstrap 5 login & sign up form template

Signup Form with Validation

Bootstrap 5 signup form with live password rules, a strength meter, show/hide toggle, password confirmation and a required terms checkbox.

Split Login Page with Image – free Bootstrap 6 login & sign up form template

Split Login Page with Image

Bootstrap 6 split-screen login page with a full-height photo and testimonial on one side and a floating-label form with Google and Apple sign-in on the other.

Forgot Password Form – free Bootstrap 6 login & sign up form template

Forgot Password Form

Bootstrap 6 forgot password form with an email field, inline validation, a loading button, a stepper and a check-your-inbox success state with resend timer.

Login and Signup Tabs – free Bootstrap 6 login & sign up form template

Login and Signup Tabs

Bootstrap 6 card with segmented tabs that switch between a sign-in form and a create-account form, with validation, cross-links and simulated submits.