flatlogic/awesome-bootstrap-checkbox
关于
使用 CSS 美化原生复选框和单选按钮。兼容 Bootstrap 3、4、5,也可用于独立表单。
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- +2
- 15天
- 0
- 1个月
- 0
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文Awesome Bootstrap Checkbox
Style native checkboxes and radio buttons with a single stylesheet. Use it with Bootstrap 3, 4 or 5, or drop it into a standalone form. Keyboard controls, form submission and browser validation use the native HTML inputs.
Try the playground · Download the stylesheet · Changelog
Quick start
Download the stylesheet above and place it after your Bootstrap CSS, if you use Bootstrap.
<link rel="stylesheet" href="./awesome-bootstrap-checkbox.css">
<div class="abc-checkbox">
<input type="checkbox" id="updates" name="updates" checked>
<label for="updates">Product updates</label>
</div>
For a bundled application, install the npm package from the GitHub release and import the stylesheet in your entry file.
npm install https://github.com/flatlogic/awesome-bootstrap-checkbox/releases/download/v3.0.0/awesome-bootstrap-checkbox-3.0.0.tgz
import 'awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css';
Radios and mixed selections
Give related radios the same name and wrap the group in a fieldset. Arrow keys move between choices. Space toggles a focused checkbox.
<fieldset>
<legend>Delivery</legend>
<div class="abc-radio">
<input type="radio" id="standard" name="delivery" value="standard" checked>
<label for="standard">Standard</label>
</div>
<div class="abc-radio">
<input type="radio" id="express" name="delivery" value="express">
<label for="express">Express</label>
</div>
</fieldset>
Use the native disabled attribute to disable a control or an entire fieldset. Set the DOM property input.indeterminate = true on a checkbox to show a partial selection. The playground includes a working “All files” example. For an input without visible label text, supply an accessible name with aria-label or aria-labelledby.
Appearance
| To get | Add to the wrapper |
|---|---|
| A round checkbox | abc-checkbox-circle |
| Inline controls | abc-checkbox-inline or abc-radio-inline |
| Bootstrap color variants | abc-checkbox-success, abc-radio-danger, or the corresponding primary, info and warning variants |
CSS custom properties can be scoped to one form.
.preferences {
--abc-accent: #21644e;
--abc-focus: #2456c3;
--abc-size: 1.25em;
--abc-radius: 0.3em;
}
The default checkmark is drawn in CSS. The controls respect reduced-motion preferences and use system control rendering in forced-colors mode.
Upgrading an existing project
- Bootstrap 3 wrappers
.checkboxand.radioand Bootstrap 4/5 wrappers.abc-checkboxand.abc-radioremain supported. Existing.form-check-inputand.form-check-labelclasses can stay in place. - The CSS, Sass and Less entry filenames are unchanged. Custom themes can continue configuring
$check-iconand$font-family-iconin Sass, or@check-iconand@font-family-iconin Less. Supply the corresponding font when using a custom glyph. - Version 3 draws the control on the native input. Themes that previously positioned
label::beforeorlabel::aftershould use the wrapper properties above. Direct file copies of the Sass or Less source also need the accompanyingstyles/controls.css. - The browser target is current Chromium, Firefox and Safari. The controls were tested with Bootstrap CSS 3.3.2, 3.4.1, 4.6.2 and 5.3.9.
Development
Use Node.js 22 or 24. From a clean checkout, run:
npm ci
npm run build
npx playwright install chromium
npm test
Open demo/index.html to try the examples offline. The demo includes its fonts and styles. Its JavaScript handles the accent picker, tabs, clipboard and mixed-selection example. The library itself has no JavaScript or runtime package dependencies.
License
MIT. Originally inspired by Bootstrap and Font Awesome. The demo fonts include their Open Font Licenses.
探索相关项目
加载中…
