@djthoms/pretty-checkbox

中文文档
3.1.0发布于 2020/09/10MIT零依赖近 30 天下载 9748

A pure css library to beautify checkbox and radio buttons.

原始使用文档
文档目录22 节
  1. Features
  2. Installation
  3. From CLI
  4. From CDN
  5. Manual download
  6. SCSS
  7. Usage
  8. Basic checkbox
  9. Switch checkbox
  10. Custom Font icons
  11. SVG
  12. Image
  13. Colors
  14. RTL Support
  15. More
  16. Browser support
  17. Font Icon libraries
  18. SVG
  19. Libraries
  20. Inspiration
  21. Contributions
  22. License


Pretty checkbox

pretty-checkbox.css

A pure CSS library to beautify checkbox and radio buttons.

Github Release Licence Downloads


Demo and documentation
Pretty checkbox preview

Features

  • Basic
    • Shapes - Square, Curve, Round
    • Variants - Default, Fill, Thick
    • Colors - Primary, Success, Info, Warning, Danger
    • Color types - Solid, Outline
    • Animations - Smooth, Tada, Jelly, Pulse, Rotate
  • Switch - iOS style - Outline, Fill, Slim
  • Responsive
  • No JavaScript
  • Custom Font Icons
  • SVG Icons
  • Image support
  • Toggle between icons / SVG's / images
  • Lock
  • State - Focus, Hover, Indeterminate
  • Supports frameworks - Bootstrap, Foundation, Sematic UI, Bulma, ...
  • SCSS customization
  • Supports all modern browsers, including mobile devices
  • Print friendly
  • and more... ( I am kidding, that's all! )

Installation

From CLI

Install using npm or yarn:

npm install @djthoms/pretty-checkbox # or
yarn add @djthoms/pretty-checkbox

Add pretty-checkbox.min.css in your html:

From CDN

<link
    rel="stylesheet"
    href="https://unpkg.com/@djthoms/pretty-checkbox/dist/pretty-checkbox.min.css"
/>

Manual download

Download the source from Github.

<link rel="stylesheet" href="<PATH>/pretty-checkbox/dist/pretty-checkbox.min.css" />

<PATH> is where the library is downloaded.

SCSS

You can also import pretty-checkbox.scss in your main scss file.

@import '~@djthoms/pretty-checkbox/src/pretty-checkbox.scss';

Please refer the document for SCSS settings.

Usage

Pretty checkbox comes with many styles,

Class nameDescription
p-defaultBasic style
p-switchiOS like toggle style
p-iconCustom font icons
p-svgCustom SVG files, markup
p-imageTiny images

And three shapes p-round p-curve p-square (default)

Basic checkbox

<div class="pretty p-default">
    <input type="checkbox" />
    <div class="state">
        <label>Check me</label>
    </div>
</div>

Basic checkbox has three variants p-fill p-thick p-outline (default)

You can combine them.

<div class="pretty p-default p-curve p-fill">
    <input type="checkbox" />
    <div class="state">
        <label>Fill</label>
    </div>
</div>

Switch checkbox

Switch has three variants p-outline p-fill p-slim

<div class="pretty p-switch p-fill">
    <input type="checkbox" />
    <div class="state">
        <label>On</label>
    </div>
</div>

Custom Font icons

<div class="pretty p-icon">
    <input type="checkbox" />
    <div class="state">
        <i class="icon fa fa-check"></i>
        <label>Check me</label>
    </div>
</div>
Note: class `icon` should be added along with icon class names
Note: For icons to work, you need to add appropriate font icons library. In above example , we used font awesome icon. So, FontAwesome should be included separately.

SVG

Supports SVG file in tag, markup (<svg> ... </svg>) and sprites

<div class="pretty p-svg">
    <input type="checkbox" />
    <div class="state">
        <img class="svg" src="file.svg" />
        <label>Check me</label>
    </div>
</div>
Note: class `svg` to be added in img tag or svg tag.

Image

Supports any type of valid image format.

<div class="pretty p-image">
    <input type="checkbox" />
    <div class="state">
        <img class="image" src="/check.png" />
        <label>Block</label>
    </div>
</div>
Note: class `image` to be added in img tag.

Colors

There are five solid colors p-primary p-success p-warning p-info p-danger

And five outline colors p-primary-o p-success-o p-warning-o p-info-o p-danger-o

<div class="pretty p-default p-curve p-thick">
    <input type="checkbox" />
    <div class="state p-warning">
        <label>Warning</label>
    </div>
</div>
Note: Color class must be added in state class. Solid colors and Ouline colors have distinct role in font icons and toggle feature.

RTL Support

Include rtl.css in your source file :smile:

More

There are more features like Radio buttons , Toggle , States , Animations , Border less , Lock , Scale, SCSS Settings.

Please refer the documentation to know about them.

Browser support

Works in all modern browsers.

Chrome >= 26 Firefox >= 16 Safari >= 6.1 Opera >= 15 IE >= 9

Font Icon libraries

SVG

Libraries

Inspiration

Contributions

Thanks to all those good people who spend their valuable time and helped to improve this library. Any Contributions are welcome!

License

This project is licensed under the MIT License

❤

版本与发布记录

@djthoms/pretty-checkbox 共发布 2 个版本,首次发布于 2020/08/18;过去 12 个月发布了 0 个版本。

版本发布日期距今
3.1.0latest2020/09/106 年前
3.0.42020/08/186 年前

关于 @djthoms/pretty-checkbox 的常见问题

@djthoms/pretty-checkbox 是什么?

A pure css library to beautify checkbox and radio buttons.

如何安装 @djthoms/pretty-checkbox?

在项目目录运行 npm install @djthoms/pretty-checkbox,或使用 pnpm add / yarn add / bun add。

@djthoms/pretty-checkbox 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/djthoms__pretty-checkbox 是否存在。

@djthoms/pretty-checkbox 可以商用吗?

@djthoms/pretty-checkbox 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@djthoms/pretty-checkbox 的下载量有多少?

根据 npm 官方下载统计,@djthoms/pretty-checkbox 在 2026/10/13 – 2026/11/11 这 30 天内被下载 9,748 次,日均约 325 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@djthoms/pretty-checkbox 还在维护吗?

最新版本 3.1.0 发布于 2020/09/10(6 年前);至今共发布 2 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/08/18。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。