npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@7f51-utilities/css-form-disable

v1.0.0-beta.1

Published

Framework-agnostic CSS form validation with automatic submit button disabling. Works with Vanilla JS, Vue, React, or any framework.

Readme

CSS Form Disable

A lightweight, framework-agnostic CSS package for automatically disabling form submit buttons when forms contain invalid fields. Works with pure CSS (no JavaScript required) and provides optional Vue.js integration with customizable SCSS and class purging capabilities.

✨ Features

  • 🚀 Pure CSS - Works without JavaScript in any framework
  • 🎯 Framework Agnostic - Works with Vanilla JS, Vue, React, Angular, Laravel, etc.
  • 🔧 Customizable - Configure which classes to include/exclude
  • 🧹 Tree Shakable - Purge unused classes for optimal bundle size
  • 🎨 Themeable - Multiple pre-built themes (minimal, modern)
  • Vue Integration - Optional Vue.js plugin for enhanced features
  • 📱 Modern CSS - Uses :has() selector for advanced form detection
  • 🛡️ Exception Handling - Respects novalidate attribute and logout forms

🚀 Quick Start

Installation

npm install @7f51-utilities/css-form-disable

Usage Options

1. Pure CSS (Any Framework/Vanilla JS)

Simply include the CSS file and it works automatically:

<link rel="stylesheet" href="node_modules/@7f51-utilities/css-form-disable/src/styles/css/form-disable.css">

<form>
  <input type="email" required>
  <input type="password" required minlength="8">
  <!-- Automatically disabled when form has invalid fields -->
  <button type="submit">Submit</button>
</form>

2. CSS Import (Webpack/Vite/Build Tools)

@import '@7f51-utilities/css-form-disable/css';

Or in JavaScript:

import '@7f51-utilities/css-form-disable/css'

3. Vue Plugin (Enhanced Features)

import { createApp } from 'vue'
import VueFormDisable from '@7f51-utilities/css-form-disable'

const app = createApp({})

// Basic usage
app.use(VueFormDisable)

// With options
app.use(VueFormDisable, {
  theme: 'minimal',
  customSelectors: ['.my-submit-btn', '[data-action="save"]'],
  respectNoValidate: true
})

3. SCSS Customization

// Configure before importing
$form-disable-classes: (
  submit: '.btn-submit',
  form-submit: '.form-submit-btn'
  // Only include classes you actually use
);

$form-disable-include-wire: false; // Disable Livewire support
$form-disable-include-role: false; // Disable role-button support

@import 'vue-form-disable/src/styles/scss/index';

📖 How It Works

The package uses modern CSS :has() selectors to detect invalid form fields and automatically disable submit buttons:

/* Disables submit buttons when form has invalid fields */
form:has(*:invalid, *:out-of-range):not([novalidate]) button[type="submit"] {
  pointer-events: none !important;
  cursor: not-allowed !important;
}

/* Global classes (when no novalidate forms exist) */
:root:not(:has(form[novalidate])):has(*:invalid, *:out-of-range) .submit {
  pointer-events: none !important;
  cursor: not-allowed !important;
}

🎯 Supported Selectors

Default Classes

  • .submit
  • .submit-btn
  • .submit-button
  • .submit-link
  • .form-submit

Framework Integration

  • [wire:click*="validate"] (Livewire)
  • [wire:click*="submit"] (Livewire)
  • [wire:click*="save"] (Livewire)
  • [role="button"][data-submit] (Accessible buttons)
  • [data-submit] (Data attributes)

Form Elements (Always Included)

  • button[type="submit"]
  • button:not([type]) (buttons without type are submit by default)
  • input[type="submit"]

🛡️ Exception Handling

Exception Classes

Add these classes to prevent disabling:

  • .no-disable
  • .ndsbl
  • .form-disable-ignore

Exception Forms

These forms are automatically excluded:

  • form[action*="logout"]
  • form[action*="signout"]
  • form[action*="sign-out"]
  • form[novalidate]

Example

<!-- This submit button will be disabled when email is invalid -->
<form>
  <input type="email" required>
  <button type="submit">Submit</button>
</form>

<!-- This form is ignored (novalidate) -->
<form novalidate>
  <input type="email" required>
  <button type="submit">Submit</button> <!-- Never disabled -->
</form>

<!-- This button is ignored (exception class) -->
<form>
  <input type="email" required>
  <button type="submit" class="no-disable">Force Submit</button>
</form>

🔧 Build Scripts

# Build all CSS
npm run build

# Build with purging
npm run build:purge

# Watch for changes
npm run watch

# Development mode
npm run dev

🌐 Browser Support

  • ✅ Chrome 105+
  • ✅ Firefox 121+
  • ✅ Safari 16.4+
  • ✅ Edge 105+

Note: Requires :has() selector support. For older browsers, consider using the JavaScript fallback or a polyfill.