Skip to content

CSS: checkbox

.instui-checkbox — خانة اختيار أصلية وتسميتها، أو مفتاح تبديل عبر -variant-toggle.

اضبط el.indeterminate = true في JavaScript لإظهار الشرطة في الحالة المختلطة؛ علامة الصح المتحققة تتباين تلقائيًا مع التعبئة — بيضاء على تعبئة داكنة، وأسود قريب من الأسود على التعبئة الفاتحة. كما يحدد gap الخاص به بين عنصر التحكم وتسميته؛ ربط مُعدّل تباعد -gap-* يتجاوز تلك القيمة المدمجة.

Source: checkbox.css

سهولة الوصول

<input type="checkbox"> الأصلي يتحكم في :checked و:indeterminate و:disabled; اضبط el.indeterminate = true في JavaScript للحالة المختلطة، وعلِم أن -readonly للتنسيق فقط لأن خانات الاختيار لا تملك سمة readonly أصلية.

الاستخدام

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

أمثلة

html
<label class="instui-checkbox --display-block --mb-sm">
  <input type="checkbox" checked>Checkbox
</label>
<label class="instui-checkbox -variant-toggle">
  <input type="checkbox">Toggle
</label>

المعدّلات

معدّلالوصف
.-invalidحالة غير صالحة (خطأ).
.-label-placement-endضع الوسم بعد عنصر التحكم.
.-label-placement-startضع الوسم قبل عنصر التحكم.
.-label-placement-topضع الوسم فوق عنصر التحكم.
.-readonlyحالة للقراءة فقط.
.-requiredأظهر نجمة الحقل الإلزامي بجانب الوسم.
.-size-largeكبير. اسم مستعار طويل لـ -size-lg.
.-size-lgكبير.
.-size-smصغير.
.-size-smallصغير. اسم مستعار طويل لـ -size-sm.
.-variant-toggleعرض كمفتاح تبديل بدلاً من مربع.

الأجزاء

جزءالوصف
.asteriskنجمة الحقل الإلزامي.

عناصر زائفة

عنصر زائفالوصف
::afterعلى -variant-toggle، رمز الحالة على المقبض: X عند الإيقاف، وعلامة صح عند التشغيل.
::beforeعلامة الصح أو الشرطة المُقنعة المركزية داخل المربع؛ على -variant-toggle تصبح بدلاً من ذلك المقبض المنزلق.

الحالات

حالةالوصف
:checked
:disabled
:indeterminate

خصائص مخصّصة

خاصيةنوعافتراضيالوصف
--pantoken-cb-glyph<url>رمز القناع للمربع: علامة صح عند التحقق، وشرطة عند الحالة غير المحددة.
--pantoken-toggle-bw<length>عرض حد التبديل.
--pantoken-toggle-h<length>ارتفاع مفتاح التبديل.
--pantoken-toggle-handle<length>قطر المقبض المحسوب.
--pantoken-toggle-inset<length>المسافة البادئة للمقبض من كل حافة المسار.
--pantoken-toggle-w<length>عرض مسار التبديل.

الرموز المستهلكة

Tokenنوعقيمة
--instui-border-width-sm<length>0.0625rem
--instui-color-background-muted<color>LightDarklight-dark(#F2F4F5, #273540)
--instui-color-stroke-base<color>LightDarklight-dark(#8D959F, #6A7883)
--instui-color-text-muted<color>LightDarklight-dark(#576773, #AAB0B5)
--instui-component-checkbox-asterisk-color<color>LightDarklight-dark(#CF1F24, #FA917F)
--instui-component-checkbox-background-checked-color<color>LightDarklight-dark(#273540, #ffffff)
--instui-component-checkbox-background-color<color>LightDarklight-dark(#ffffff, #171B21)
--instui-component-checkbox-background-disabled-color<color>LightDarklight-dark(#E8EAEC, #334450)
--instui-component-checkbox-background-hover-color<color>LightDarklight-dark(#ffffff, #171B21)
--instui-component-checkbox-background-readonly-color<color>LightDarklight-dark(#C7CACD, #6A7883)
--instui-component-checkbox-border-checked-color<color>LightDarklight-dark(#273540, #ffffff)
--instui-component-checkbox-border-color<color>LightDarklight-dark(#7E8792, #5F6E7A)
--instui-component-checkbox-border-disabled-color<color>LightDarklight-dark(#C7CACD, #4A5B68)
--instui-component-checkbox-border-hover-color<color>LightDarklight-dark(#334450, #7E8792)
--instui-component-checkbox-border-radius<length>0.25rem
--instui-component-checkbox-border-readonly-color<color>#8D959F
--instui-component-checkbox-border-width<length>0.0625rem
--instui-component-checkbox-control-size-lg<length>1.5rem
--instui-component-checkbox-control-size-md<length>1.5rem
--instui-component-checkbox-control-size-sm<length>1.5rem
--instui-component-checkbox-control-vertical-margin<length>0rem
--instui-component-checkbox-error-border-color<color>LightDarklight-dark(#CF1F24, #F56050)
--instui-component-checkbox-error-border-hover-color<color>LightDarklight-dark(#CF1F24, #FE7D6A)
--instui-component-checkbox-font-family[ <font-family-name> | <generic-font-family> ]#Atkinson Hyperlegible Next, "Helvetica Neue", Helvetica, Arial, sans-serif
--instui-component-checkbox-font-size-lg<length>1.25rem
--instui-component-checkbox-font-size-md<length>1rem
--instui-component-checkbox-font-size-sm<length>0.875rem
--instui-component-checkbox-font-weight<integer>400
--instui-component-checkbox-gap<length>0.5rem
--instui-component-checkbox-label-base-color<color>LightDarklight-dark(#273540, #ffffff)
--instui-component-checkbox-label-disabled-color<color>LightDarklight-dark(#8D959F, #576773)
--instui-component-checkbox-label-hover-color<color>LightDarklight-dark(#273540, #ffffff)
--instui-component-checkbox-label-readonly-color<color>LightDarklight-dark(#273540, #ffffff)
--instui-component-checkbox-line-height<percentage>125%
--instui-component-radio-input-toggle-background-success<color>#03893D
--instui-component-radio-input-toggle-handle-text<color>#ffffff
--instui-component-radio-input-toggle-medium-height<length>2.5rem
--instui-icon-check<image>url('data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22currentColor%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M20%206%209%2017l-5-5%22%2F%3E%3C%2Fsvg%3E')
--instui-icon-minus<image>url('data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22currentColor%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M5%2012h14%22%2F%3E%3C%2Fsvg%3E')
--instui-icon-x<image>url('data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22currentColor%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M18%206%206%2018%22%2F%3E%3Cpath%20d%3D%22m6%206%2012%2012%22%2F%3E%3C%2Fsvg%3E')
--instui-size-choice-control-height-md<length>1.5rem

ذات صلة

  • radio — النظير للاختيار المفرد.