Chuyển đến nội dung chính

CSS-only Tailwind CSS radio buttons with primary, secondary, accent, and semantic color variants. Sizes xs–xl. WCAG AA accessible, works with Django, HTMX, Laravel, React, and any stack.

Các thành phần nút radio cho phép người dùng chọn chính xác một tùy chọn từ một tập hợp các lựa chọn loại trừ lẫn nhau. Được xây dựng bằng các phần tử đầu vào HTML gốc và được cải tiến bằng CSS Tailwind, các nút radio hỗ trợ nhiều kích thước, màu sắc và trạng thái. Bộ đàm có thể truy cập và điều hướng bằng bàn phím là lựa chọn lý tưởng cho các câu hỏi về lựa chọn ưu tiên, lọc và biểu mẫu một lựa chọn.

Chỉ CSS, không cần JavaScript. WCAG AA có thể truy cập và không phụ thuộc vào khung — hoạt động với Django, HTMX, Laravel, React và bất kỳ ngăn xếp nào.

Lớp học Kiểu Sự miêu tả
radioCăn cứĐầu vào nút radio được tạo kiểu
radio-circlePhong cáchĐài phát thanh tròn hoàn toàn (mặc định)
radio-roundedPhong cáchĐài phát thanh tròn vừa phải
radio-squarePhong cáchĐài vuông không tròn
radio-disabledCông cụ sửa đổiDisabled appearance for non-input elements
radio-xsKích cỡCực nhỏ
radio-smKích cỡBé nhỏ
radio-mdKích cỡTrung bình (mặc định)
radio-lgKích cỡLớn
radio-xlKích cỡCực lớn
radio-2xlKích cỡ2× extra large
radio-primaryMàu sắcMàu chủ đề chính
radio-secondaryMàu sắcMàu chủ đề phụ
radio-accentMàu sắcMàu chủ đề nhấn mạnh
radio-neutralMàu sắcMàu chủ đề trung tính
radio-infoMàu sắcMàu sắc ngữ nghĩa thông tin
radio-successMàu sắcMàu ngữ nghĩa thành công
radio-warningMàu sắcMàu ngữ nghĩa cảnh báo
radio-errorMàu sắcLỗi ngữ nghĩa màu sắc

Cách sử dụng cơ bản

1
2
<input type="radio" name="radio-1" class="radio" checked="checked">
<input type="radio" name="radio-1" class="radio">
1
2
<input type="radio" name="radio-1" className="radio" checked="checked">
<input type="radio" name="radio-1" className="radio">

Kích thước đài

html
1
2
3
4
5
<input type="radio" name="radio-sizes" class="radio radio-xs" checked="checked">
<input type="radio" name="radio-sizes" class="radio radio-sm" checked="checked">
<input type="radio" name="radio-sizes" class="radio radio-md" checked="checked">
<input type="radio" name="radio-sizes" class="radio radio-lg" checked="checked">
<input type="radio" name="radio-sizes" class="radio radio-xl" checked="checked">

Màu sắc đài phát thanh

html
1
2
3
4
5
6
7
8
9
<input type="radio" name="radio-colors" class="radio" checked="checked">
<input type="radio" name="radio-colors" class="radio radio-primary" checked="checked">
<input type="radio" name="radio-colors" class="radio radio-secondary" checked="checked">
<input type="radio" name="radio-colors" class="radio radio-accent" checked="checked">
<input type="radio" name="radio-colors" class="radio radio-info" checked="checked">
<input type="radio" name="radio-colors" class="radio radio-success" checked="checked">
<input type="radio" name="radio-colors" class="radio radio-warning" checked="checked">
<input type="radio" name="radio-colors" class="radio radio-error" checked="checked">
<input type="radio" name="radio-colors" class="radio radio-neutral" checked="checked">

đài bị vô hiệu hóa

html
1
2
<input type="radio" class="radio" disabled="">
<input type="radio" class="radio" disabled="" checked="checked">

Hình dạng đài phát thanh

Square Radio

html
<input type="radio" name="shape-demo" class="radio radio-square" checked="checked">

Rounded or Circle Radio

html
1
2
<input type="radio" name="shape-demo2" class="radio radio-circle" checked="checked">
<input type="radio" name="shape-demo2" class="radio radio-rounded" checked="checked">

Radio with label

html
1
2
3
4
5
6
7
8
<input type="radio" class="radio radio-circle radio-neutral radio-sm" id="size-small" name="size" value="small">
<label for="size-small">Small</label>

<input type="radio" class="radio radio-circle radio-neutral radio-sm" id="size-medium" name="size" value="medium">
<label for="size-medium">Medium</label>

<input type="radio" class="radio radio-circle radio-neutral radio-sm" id="size-large" name="size" value="large">
<label for="size-large">Large</label>