Skip to content

CSS: radio ​

.instui-radio — Một nút radio gốc và nhãn của nó.

Đặt gap riêng giữa điều khiển và nhãn; xâu một bộ sửa đổi tiện ích khoảng cách -gap-* sẽ ghi đè giá trị tích hợp đó.

Source: radio.css

Sử dụng ​

css
@import "@pantoken/components/components.css";
@import "@pantoken/components/radio.css";

Các ví dụ ​

html
<label class="instui-radio"><input type="radio" name="r" checked> Tùy chọn A</label>

Bộ sửa ​

Bộ sửaMô tả
.-context-dangerMàu bối cảnh nguy hiểm (biến thể công tắc).
.-context-offMàu bối cảnh tắt/trung tính (biến thể công tắc).
.-context-successMàu bối cảnh thành công (biến thể công tắc).
.-context-warningMàu bối cảnh cảnh báo (biến thể công tắc).
.-readonlyTrạng thái chỉ đọc.
.-size-largeLớn. Bút danh dài của -size-lg.
.-size-lgLớn.
.-size-smNhỏ.
.-size-smallNhỏ. Bút danh dài của -size-sm.
.-toggleAlias — maps to .-variant-toggle.
.-variant-toggleKết xuất dưới dạng nút chuyển phân đoạn.

Phần tử giả ​

Phần tử giảMô tả
::beforeChấm bên trong được tô khi được chọn; trên -variant-toggle đó là vòng tiêu điểm được vẽ ngay bên ngoài viên.

Trạng thái ​

Trạng tháiMô tả
:checked—
:disabled—

Thuộc tính tuỳ chỉnh ​

Thuộc tínhKiểuMặc địnhMô tả
--pantoken-rt-fill<color>—Màu nền khi được chọn của công tắc; các bộ sửa đổi -context-* thiết lập nó.

Điều kiện ​

KiểuTruy vấnMô tả
media(prefers-reduced-motion: no-preference)—
media(forced-colors: active)—
media(prefers-reduced-transparency: reduce)—

Khả năng truy cập ​

Một <input type="radio"> gốc điều khiển :checked và :disabled; -readonly chỉ dành cho kiểu dáng, vì các radio không có thuộc tính readonly gốc.

Quy tắc (axe-core)Đổi thương hiệu (sáng)Đổi thương hiệu (tối)CanvasCanvas tương phản cao
color-contrastWCAG 2.2 1.4.3FailPassPassPass

Đổi thương hiệu (sáng): Các phần tử phải đáp ứng ngưỡng tỷ lệ tương phản màu tối thiểu

  • .-context-warning
  • .-context-danger
Điều kiệnĐổi thương hiệu (sáng)Đổi thương hiệu (tối)CanvasCanvas tương phản cao
forced-colors-focus-visibleWCAG 2.2 1.4.11, 2.4.7PassPassPassPass
less-contrast-stays-readableWCAG 2.2 1.4.3FailFailFailCần xem xét

Đổi thương hiệu (sáng): Với prefers-contrast: less, sáu đoạn văn bản có độ tương phản thấp hơn mức tối thiểu. Mức thấp nhất là "Cảnh báo đã chọn" ở 1.67:1 (cần 4.5:1). Độ tương phản thấp hơn chỉ phù hợp khi văn bản vẫn dễ đọc.

Đổi thương hiệu (tối): Với prefers-contrast: less, bốn đoạn văn bản có độ tương phản thấp hơn mức tối thiểu. Mức thấp nhất là "Đã tắt, chưa chọn" ở 3.15:1 (cần 4.5:1). Độ tương phản thấp hơn chỉ phù hợp khi văn bản vẫn dễ đọc.

Canvas: Với prefers-contrast: less, bốn đoạn văn bản có độ tương phản thấp hơn mức tối thiểu. Mức thấp nhất là "Đã tắt, chưa chọn" ở 3.02:1 (cần 4.5:1). Độ tương phản thấp hơn chỉ phù hợp khi văn bản vẫn dễ đọc.

Độ tương phản cao của Canvas: Cả 31 đoạn văn bản được đo đều đạt mức tối thiểu. hai mục khác không thể giảm xuống còn một màu. Không thể đo "Đã tắt, chưa chọn" vì phần tử phía sau nó có độ trong suốt một phần.

more-contrast-respectedWCAG 2.2 1.4.3, 1.4.6FailFailFailCần xem xét

Đổi thương hiệu (sáng): Với prefers-contrast: more, sáu đoạn văn bản có độ tương phản thấp hơn mức tối thiểu. Mức thấp nhất là "Cảnh báo đã chọn" ở 1.67:1 (cần 4.5:1).

Đổi thương hiệu (tối): Với prefers-contrast: more, bốn đoạn văn bản có độ tương phản thấp hơn mức tối thiểu. Mức thấp nhất là "Đã tắt, chưa chọn" ở 3.15:1 (cần 4.5:1).

Canvas: Với prefers-contrast: more, bốn đoạn văn bản có độ tương phản thấp hơn mức tối thiểu. Mức thấp nhất là "Đã tắt, chưa chọn" ở 3.02:1 (cần 4.5:1).

Độ tương phản cao của Canvas: Cả 31 đoạn văn bản được đo đều đạt yêu cầu với độ tương phản cao hơn. hai mục khác không thể giảm xuống còn một màu. Không thể đo "Đã tắt, chưa chọn" vì phần tử phía sau nó có độ trong suốt một phần.

reflow-at-320pxWCAG 2.2 1.4.10PassPassPassPass
text-spacing-no-clippingWCAG 2.2 1.4.12PassPassPassPass
Trình đọc màn hình (mô phỏng)Đổi thương hiệu (sáng)Đổi thương hiệu (tối)CanvasCanvas tương phản cao
AnnouncementsPassPassPassPass

Các kết quả tự động này không chứng minh rằng trang đáp ứng WCAG; vẫn cần đánh giá thủ công.

Token tiêu thụ ​

TokenKiểuGiá trị
--instui-component-radio-input-background-color<color>LightDarklight-dark(#ffffff, #171B21)
--instui-component-radio-input-background-disabled-color<color>LightDarklight-dark(#E8EAEC, #334450)
--instui-component-radio-input-background-hover-color<color>LightDarklight-dark(#ffffff, #171B21)
--instui-component-radio-input-background-readonly-color<color>LightDarklight-dark(#C7CACD, #6A7883)
--instui-component-radio-input-border-color<color>LightDarklight-dark(#7E8792, #5F6E7A)
--instui-component-radio-input-border-disabled-color<color>LightDarklight-dark(#C7CACD, #4A5B68)
--instui-component-radio-input-border-hover-color<color>LightDarklight-dark(#273540, #ffffff)
--instui-component-radio-input-border-readonly-color<color>#8D959F
--instui-component-radio-input-border-selected-color<color>LightDarklight-dark(#1C222B, #ffffff)
--instui-component-radio-input-border-width<length>0.0625rem
--instui-component-radio-input-checked-inset-lg<length>0.375rem
--instui-component-radio-input-checked-inset-md<length>0.375rem
--instui-component-radio-input-checked-inset-sm<length>0.375rem
--instui-component-radio-input-control-size-lg<length>1.5rem
--instui-component-radio-input-control-size-md<length>1.5rem
--instui-component-radio-input-control-size-sm<length>1.5rem
--instui-component-radio-input-control-vertical-margin<length>0rem
--instui-component-radio-input-font-family[ <font-family-name> | <generic-font-family> ]#Atkinson Hyperlegible Next, "Helvetica Neue", Helvetica, Arial, sans-serif
--instui-component-radio-input-font-size-lg<length>1.25rem
--instui-component-radio-input-font-size-md<length>1rem
--instui-component-radio-input-font-size-sm<length>0.875rem
--instui-component-radio-input-font-weight<integer>400
--instui-component-radio-input-gap<length>0.5rem
--instui-component-radio-input-label-base-color<color>LightDarklight-dark(#273540, #ffffff)
--instui-component-radio-input-label-disabled-color<color>LightDarklight-dark(#8D959F, #576773)
--instui-component-radio-input-label-hover-color<color>LightDarklight-dark(#273540, #ffffff)
--instui-component-radio-input-label-readonly-color<color>LightDarklight-dark(#273540, #F2F4F5)
--instui-component-radio-input-line-height-lg<length>1.5rem
--instui-component-radio-input-line-height-md<length>1.5rem
--instui-component-radio-input-line-height-sm<length>1.25rem
--instui-component-radio-input-toggle-background-danger<color>LightDarklight-dark(#F0C16C, #8C6400)
--instui-component-radio-input-toggle-background-off<color>#03893D
--instui-component-radio-input-toggle-background-success<color>#03893D
--instui-component-radio-input-toggle-background-warning<color>LightDarklight-dark(#F0C16C, #8C6400)
--instui-component-radio-input-toggle-border-radius<length>0.25rem
--instui-component-radio-input-toggle-handle-text<color>#ffffff
--instui-component-radio-input-toggle-large-font-size<length>1rem
--instui-component-radio-input-toggle-large-height<length>3rem
--instui-component-radio-input-toggle-medium-font-size<length>0.875rem
--instui-component-radio-input-toggle-medium-height<length>2.5rem
--instui-component-radio-input-toggle-small-font-size<length>0.75rem
--instui-component-radio-input-toggle-small-height<length>2rem
--instui-elevation-depth1none | <shadow>#—
--instui-focus-outline-colorauto | <color>—
--instui-focus-outline-styleauto | <outline-line-style>—
--instui-focus-outline-width<line-width>—

Liên quan ​

  • checkbox — Đối tác đa chọn tương ứng với radio chọn một.
  • radio-input-group — Gom các radio vào một fieldset chọn một.