CSS Radio Button Generator [2025]

Tool rating: 0 people found this tool terrific

Design and customize stylish CSS radio buttons with an interactive live preview. Control appearance, hover effects, and animations.

✓ Live Preview✓ Custom Styles (Classic, Filled, Outline)✓ Color & Size Controls✓ Hover Effects✓ Simple Animations✓ Instant CSS Code

Interact with the radio buttons above to see the checked state and animation.

20px
2px
50%
100%
250ms
/* CSS Radio Button Variables */
:root { /* Or apply to a specific container */
  --radio-size: 20px;
  --radio-border-width: 2px;
  --radio-dot-size: calc(var(--radio-size) * 0.5);

  /* Unchecked State */
  --radio-border-color-unchecked: #a1a1aa;
  --radio-bg-unchecked: #ffffff;

  /* Checked State */
  --radio-border-color-checked: #4f46e5;
  --radio-bg-checked: #4f46e5; /* Used for 'filled' */
  --radio-dot-color: #4f46e5; /* Used for 'classic', 'outline' */
  --radio-inset-shadow-color: #00005c; /* New */
  --radio-inset-shadow-size: calc(var(--radio-size) / 2 * 0.8); /* New */

  /* Gradient State */
  --radio-gradient: linear-gradient(135deg, #97f6d9, #627bf8);

  /* Hover State (Unchecked) */
  --radio-hover-border-color: #6366f1;
  --radio-hover-bg: #f4f4f5;
  --radio-hover-scale: 1;

  /* Focus State */
  --radio-focus-outline-color: -webkit-focus-ring-color;
  --radio-focus-outline-offset: 2px;

  /* Animation */
  --radio-animation-duration: 250ms;
  --radio-animation-timing: ease-in-out;
}

/* Core Radio Button Styles */
.hidden-radio {
  position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none;
}

.custom-radio {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--radio-size); height: var(--radio-size);
  border: var(--radio-border-width) solid var(--radio-border-color-unchecked);
  border-radius: 50%;
  background-color: var(--radio-bg-unchecked);
  cursor: pointer; position: relative; flex-shrink: 0;
  vertical-align: middle; overflow: hidden; /* Needed for gradient reveal */
  /* Base transitions */
  transition: background-color 0.15s var(--radio-animation-timing),
              border-color 0.15s var(--radio-animation-timing),
              transform 0.15s var(--radio-animation-timing),
              box-shadow var(--radio-animation-duration) var(--radio-animation-timing); /* Add box-shadow transition */
  transform: scale(1);
  box-shadow: none; /* Default no inset shadow */
}

/* Inner Dot Element (::after) - Used for classic/outline */
.custom-radio::after {
  content: "";
  display: block;
  width: var(--radio-dot-size);
  height: var(--radio-dot-size);
  border-radius: 50%;
  background-color: var(--radio-dot-color);
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0); /* Initially hidden */
  opacity: 0;
  transition: transform var(--radio-animation-duration) var(--radio-animation-timing), opacity var(--radio-animation-duration) var(--radio-animation-timing);
}

/* Cover Element (::before) - Used for gradient-reveal */
.custom-radio::before {
  content: '';
  position: absolute;
  inset: calc(-1 * var(--radio-border-width)); /* Cover border */
  background: var(--radio-bg-unchecked); /* Match unchecked background */
  border-radius: 50%;
  transform: scale(1.1); /* Start slightly larger */
  opacity: 1;
  transition: transform var(--radio-animation-duration) var(--radio-animation-timing), opacity var(--radio-animation-duration) var(--radio-animation-timing);
  z-index: 1; /* Above potential background gradient */
  pointer-events: none; /* Allow clicks through */
}
/* Hide cover by default unless gradient-reveal animation is active */
.custom-radio:not(.anim-gradient-reveal)::before {
    display: none;
}
/* Ensure cover is visible when gradient-reveal is active and unchecked */
.hidden-radio:not(:checked) + .custom-radio.anim-gradient-reveal::before {
    display: block;
    transform: scale(1.1);
    opacity: 1;
}


/* Hover State (Unchecked) */
.hidden-radio:not(:checked) + .custom-radio:hover {
  border-color: var(--radio-hover-border-color);
  background-color: var(--radio-hover-bg);
  transform: scale(var(--radio-hover-scale));
}
/* Hover state for cover in gradient reveal */
.hidden-radio:not(:checked) + .custom-radio.anim-gradient-reveal:hover::before {
    background-color: var(--radio-hover-bg);
}


/* Active State */
.custom-radio:active {
  transform: scale(calc(var(--radio-hover-scale) * 0.95));
}

/* Focus State */
.hidden-radio:focus-visible + .custom-radio {
  outline: 2px solid var(--radio-focus-outline-color);
  outline-offset: var(--radio-focus-outline-offset);
}

/* --- Checked State --- */
.hidden-radio:checked + .custom-radio {
  border-color: var(--radio-border-color-checked);
  background-color: var(--radio-bg-unchecked);
}
/* Show dot for classic style */
.hidden-radio:checked + .custom-radio::after {
  transform: translate(-50%, -50%) scale(1); opacity: 1;
  background-color: var(--radio-dot-color);
}
/* Optional: Style label text */
.radio-label-text {
  margin-left: 8px;
  cursor: pointer;
  vertical-align: middle;
  user-select: none;
}

Apply CSS globally or scoped. Use the HTML structure: <input type="radio" class="hidden-radio"> followed by <label class="custom-radio"> and optionally <label class="radio-label-text"> .

What Are Custom CSS Radio Buttons?

Standard HTML radio buttons have limited styling options across different browsers. Custom CSS radio buttons involve hiding the default input element and creating a visually appealing replacement using CSS, often with pseudo-elements (`::before`, `::after`) or extra `span` elements within a `label`.

This technique allows for complete control over the appearance (size, color, border, inner dot) and behavior (hover effects, animations) to match your website's design system. The state of the hidden radio button (`:checked`) is used to trigger the visual changes in the custom element via CSS selectors (like the adjacent sibling combinator `+`).

This generator simplifies the process by providing interactive controls and generating the necessary HTML structure and CSS code for you.

How to Use This Generator

  1. Customize: Use the controls on the right to adjust the radio button's size, colors, border, style (Classic, Filled, Outline), hover effects, and animation.
  2. Preview: Interact with the radio buttons in the live preview area on the left to see your changes in real-time, including the checked state and animations.
  3. Copy CSS: Click the "Copy" button in the "Generated CSS" section. This copies both the CSS variables and the rules.
  4. Implement HTML: In your HTML, use the following structure for each radio button:
    <input type="radio" id="your-radio-id" name="your-group-name" value="your-value" class="hidden-radio">
    <label for="your-radio-id" class="custom-radio"></label>
    <label for="your-radio-id" class="radio-label-text">Your Label Text</label>
    Replace `your-radio-id`, `your-group-name`, `your-value`, and `Your Label Text` accordingly. Ensure all radio buttons within the same group share the same `name` attribute.
  5. Apply CSS: Paste the copied CSS into your project's stylesheet. The styles will automatically apply to the HTML structure created in the previous step.

Comments

Please sign in to leave a comment

No comments yet

Be the first to share your thoughts! Your feedback helps us improve our tools and inspires other users.

More Code Tools

AVRO to JSON Converter

Convert AVRO to JSON

AVRO to Protobuf Converter

Convert AVRO to Protobuf

AVRO to XML Converter

Convert AVRO to XML code

Base64 to JSON Converter

Convert Base64 encode to JSON format

Base64 to XML Converter

Convert Base64 encode to XML format

Base64 to YAML Converter

Convert Base64 encode to YAML format

BBCode to HTML Converter

Convert Bulletin Board code to HTML

BSON to JSON Converter

Convert BSON to JSON

BSON to XML Converter

Convert BSON to XML

Code Difference Checker

Visually compare two blocks of code or text

Comment Remover

Remove comments from your codebase

CSON to JSON Converter

Convert CSON to JSON

CSS Animation Generator

Create CSS animations visually with presets and controls

CSS Arrow Generator

Create pure CSS arrows (triangles) using borders

CSS Background Generator

Generate pure CSS background patterns with customization

CSS Border Generator

Visually create CSS borders and border-radius styles

CSS Box Shadow Generator

Create adjustable box shadows using CSS

CSS Button Generator

Style buttons in different ways

CSS Checkbox Generator

Generate stylish custom CSS checkboxes with interactive controls

CSS Clip Path Generator

Create custom CSS clip-path shapes visually with presets

CSS Easing Generator

Visually create cubic-bezier easing functions with an interactive graph.

CSS Filter Generator

Visually create CSS filter effects like blur, contrast, sepia, etc.

CSS Flexbox Generator

Visually create CSS Flexbox layouts and configure item properties

CSS Glassmorphism Generator

An interactive glassmorphism CSS generator with live element previews

CSS Gradient Generator

Visually create linear and radial CSS gradients

CSS Grid Generator

Interactive CSS Grid Generator with visual previews

CSS Hover Animation Generator

Create interactive CSS hover effects with presets and controls

CSS Loader Generator

Generate pure CSS loading animations with customization

CSS Minifier

Minify CSS code for production

CSS Prettifier

Format and beautify CSS code

CSS Scrollbar Generator

Visually style browser scrollbars (WebKit) with custom CSS

CSS Skew Generator

Visually create CSS skew (slant) transformations

CSS Sprite Generator

Combine images into optimized CSS sprites

CSS Stylesheet Generator

Visually build complete CSS rulesets for elements

CSS Text Shadow Generator

Generate CSS text shadow code

CSS to Tailwind Converter

Convert basic CSS rules to Tailwind utility classes

CSS Toggle Switch Generator

Browse and generate pure CSS toggle switch styles and animations

CSS Transform Generator

Visually create 2D/3D transforms (translate, rotate, scale, skew)

CSS Triangle Generator

Generate CSS code foor arrows and triangle shapes

CSS Typography Generator

Visually configure font styles, spacing, color, and generate CSS

.gitignore Generator

Generate .gitignore files using templates and AI suggestions

Go Struct to JSON Converter

Convert Go Struct to JSON

GraphQL Minifier

Minify GraphQL code for production

HTML Escape

Escape HTML special characters

HTML Form Generator

Visually build and style custom HTML forms with generated code

HTML Iframe Generator

Generate HTML iframe code with customizable attributes

HTML Minifier

Minify HTML code for production

HTML Prettifier

Format and beautify HTML code

HTML Table Generator

Create HTML table code

HTML to BBCode Converter

Convert HTML to Bulletin Board code

HTML Unescape

Unescape HTML special characters

INI to JSON Converter

Convert INI to JSON

INI to XML Converter

Convert INI to XML

INI Validator

Check INI files for syntax errors

INI to YAML Converter

Convert INI to YAML

JavaScript Minifier

Minify JavaScript code for production

JavaScript Obfuscator

Obfuscate JavaScript code

JavaScript Prettifier

Format and beautify JavaScript code

JavaScript to JSON Converter

Convert JavaScript Objects to JSON

JSON Compare

Check the difference between two JSON files

JSON Escape

Escape JSON content

JSON Formatter

Format and validate JSON data

JSON Minifier

Minify JSON content for production

JSON Prettifier

Format and beautify JSON content

JSON Schema Validator

Validate JSON data against a JSON Schema

JSON to AVRO Converter

Convert JSON to Apache's AVRO format

JSON to Base64 Converter

Convert JSON to Base64 encoding

JSON to BSON Converter

Convert JSON code to binary JSON

JSON to C# Classes Converter

Convert JSON to C# Classes

JSON to Dart Converter

Convert JSON code to Dart

JSON to Go Struct Converter

Convert JSON code to Go Struct

JSON to INI Converter

Convert JSON code to INI format

JSON to JSDOC Converter

Convert JSON code to JSDOC format

JSON to JSON Schema Converter

Convert JSON to a JSON schema

JSON to Kotlin Class Converter

Convert JSON code to Kotlin Data Classes

JSON to Mongoose Schema Converter

Convert JSON to a Mongoose schema

JSON to NDJSON Converter

Convert JSON code to NDJSON format

JSON to Protobuf Converter

Convert JSON to Protobuf

JSON to Query String Converter

Convert JSON to a query string

JSON to Rust Structs Converter

Convert JSON code to Rust Serde Structs

JSON to Swift Structs Converter

Convert JSON code to Swift Structs

JSON to TOML Converter

Convert JSON to TOML

JSON to TypeScript Converter

Convert JSON to TypeScript

JSON to XML Converter

Convert JSON code to XML format

JSON to YAML Converter

Convert JSON code to YAML format

JSON to Zod Schema Converter

Convert JSON code to Zod schema

JSON Unescape

Unescape JSON content

Lua Minifier

Minify Lua code for production

Lua to JSON Converter

Convert Lua code to JSON

Lua to TypeScript Converter

Convert Lua code to TypeScript types and more

PHP Minifier

Minify PHP code for production

Protobuf to JSON Converter

Convert Protobuf to JSON

Protobuf to XML Converter

Convert Protobuf to XML

Protobuf to YAML Converter

Convert Protobuf to YAML

Pixels to REM Converter

Convert Pixels (PX) to REM

Python Minifier

Minify Python code for production

Query String to JSON Converter

Convert Query Strings to JSON format

Regex Generator (AI)

Generate regular expressions with the help of AI

REM to Pixels Converter

Convert REM to Pixels (PX)

SQL Prettifier

Format and beautify SQL queries

TOML to JSON Converter

Convert TOML to JSON

TOML to XML Converter

Convert TOML to XML

TOML to YAML Converter

Convert TOML to YAML

TOML Validator

Check TOML files for syntax errors

TypeScript Formatter

Format and beautify TypeScript files

TypeScript to JSON Schema Converter

Convert TypeScript types to JSON Schema

TypeScript to Lua Converter

Convert TypeScript code to Lua

XML Compare

Find the differences between two XML codebases

XML Formatter

Format and validate XML documents

XML to AVRO Converter

Convert XML code to AVRO format

XML to Base64 Converter

Convert XML code to Base64 encoding

XML to C# Class Converter

Convert XML code to C# Classes

XML to Go Struct Converter

Convert XML code to Go Struct

XML to JSON Converter

Convert XML code to JSON format

XML to Protobuf Converter

Convert XML to Protobuf

XML to TOML Converter

Convert XML code to TOML format

XML to TypeScript Converter

Convert XML code to TypeScript interfaces

XML to XSD Converter

Convert XML code to XSD format

XML to YAML Converter

Convert XML code to YAML format

XML Validator

Check XML documents for well-formedness errors

YAML Formatter

Format and beautify YAML files

YAML to Go Struct Converter

Convert YAML to Go Structs

YAML to INI Converter

Convert YAML code to INI format

YAML to JSON Converter

Convert YAML to JSON format

YAML to TOML Converter

Convert YAML code to TOML format

YAML to XML Converter

Convert YAML to XML format

YAML Validator

Check YAML files for syntax errors