metro4
Version:
The front-end framework for Build responsive, mobile-first projects on the web with the first front-end component library in Metro Style
280 lines (250 loc) • 13.4 kB
HTML
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="twitter:site" content="@metroui">
<meta name="twitter:creator" content="@pimenov_sergey">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Metro 4 Components Library">
<meta name="twitter:description" content="Metro 4 is an open source toolkit for developing with HTML, CSS, and JS. Quickly prototype your ideas or build your entire app with responsive grid system, extensive prebuilt components, and powerful plugins built on jQuery.">
<meta name="twitter:image" content="https://metroui.org.ua/images/m4-logo-social.png">
<meta property="og:url" content="https://metroui.org.ua/v4/index.html">
<meta property="og:title" content="Metro 4 Components Library">
<meta property="og:description" content="Metro 4 is an open source toolkit for developing with HTML, CSS, and JS. Quickly prototype your ideas or build your entire app with responsive grid system, extensive prebuilt components, and powerful plugins built on jQuery.">
<meta property="og:type" content="website">
<meta property="og:image" content="https://metroui.org.ua/images/m4-logo-social.png">
<meta property="og:image:secure_url" content="https://metroui.org.ua/images/m4-logo-social.png">
<meta property="og:image:type" content="image/png">
<meta property="og:image:width" content="968">
<meta property="og:image:height" content="504">
<meta name="author" content="Sergey Pimenov">
<meta name="description" content="Enhancement for standard HTML checkbox control. Excellent to create the element for pin enter. The most popular HTML, CSS, and JS library in Metro style.">
<meta name="keywords" content="HTML, CSS, JS, Metro, CSS3, Javascript, HTML5, UI, Library, Web, Development, Framework">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link href="metro/css/metro-all.css?ver=@@b-version" rel="stylesheet">
<link href="highlight/styles/github.css" rel="stylesheet">
<link href="docsearch/docsearch.min.css" rel="stylesheet">
<link href="css/site.css" rel="stylesheet">
<title>Checkbox - Metro 4 :: Popular HTML, CSS and JS library</title>
</head>
<body class="m4-cloak" data-role="htmlcontainer" data-html-source="header.html" data-insert-mode="prepend">
<div class="container-fluid">
<div class="row flex-xl-nowrap">
<div class="cell-md-3 cell-xl-2 pr-0 border-right bd-light" id="sidenav" data-role="htmlcontainer" data-html-source="sidenav.html" data-insert-mode="replace" data-on-load="initDocSearchEngine()"></div>
<div class="d-none d-block-xl cell-xl-2 order-2 border-left bd-light toc-wrapper">
<h5>Table of contents</h5>
<hr/>
<ul class="toc-nav">
<li class="toc-entry"><a href="#">Checkbox</a></li>
<li class="toc-entry"><a href="#_checkbox_about">About</a></li>
<li class="toc-entry"><a href="#_checkbox_style">Checkbox style</a></li>
<li class="toc-entry"><a href="#_checkbox_caption">Caption</a></li>
<li class="toc-entry"><a href="#_checkbox_events">Events</a></li>
<li class="toc-entry"><a href="#_checkbox_methods">Methods</a></li>
<li class="toc-entry"><a href="#_checkbox_customize">Customize</a></li>
</ul>
</div>
<main class="cell-md-9 cell-xl-8 order-1 pr-1-sx pl-1-sx pr-5-md pl-5-md">
<div class="place-right d-none d-block-lg" style="width: 200px;">
<img src="images/logo.png" class="w-100">
</div>
<h1>Checkbox</h1>
<p class="text-leader">
Create a customizable checkbox with support for highly used options.
</p>
<!-- ads-html -->
<h3 id="_checkbox_about">About</h3>
<p>
In Metro 4, you can create styled <code>checkbox</code>.
To define it, add attribute <code>data-role="checkbox"</code> to HTML checkbox element.
</p>
<div class="example">
<input type="checkbox" data-role="checkbox" >
<input type="checkbox" data-role="checkbox" checked>
<input type="checkbox" data-role="checkbox" disabled>
<input type="checkbox" data-role="checkbox" disabled checked>
</div>
<pre><code>
<input type="checkbox" data-role="checkbox" >
<input type="checkbox" data-role="checkbox" checked>
<input type="checkbox" data-role="checkbox" disabled>
<input type="checkbox" data-role="checkbox" disabled checked>
</code></pre>
<h3 id="_checkbox_style">Checkbox style</h3>
<p>
You can use two styles for checkbox. To define style, add attribute <code>data-style="1|2"</code>.
</p>
<div class="example">
<input type="checkbox" data-role="checkbox" checked data-caption="Style 1">
<input type="checkbox" data-role="checkbox" data-style="2" checked data-caption="Style 2">
</div>
<pre><code>
<input type="checkbox" data-role="checkbox">
<input type="checkbox" data-role="checkbox" data-style="2">
</code></pre>
<h3 id="_checkbox_caption">Checkbox caption</h3>
<p>
You can set your one value for button with attribute <code>data-caption="..."</code>.
By default caption placed on the right o checkbox. To place on the left, use attribute <code>data-caption-position="left"</code>
</p>
<div class="example">
<input type="checkbox" data-role="checkbox" data-caption="Checkbox">
<input type="checkbox" data-role="checkbox" data-caption="Checkbox" data-caption-position="left">
</div>
<pre><code>
<input type="checkbox" data-role="checkbox" data-caption="Checkbox">
<input type="checkbox" data-role="checkbox" data-caption="Checkbox" data-caption-position="left">
</code></pre>
<h3 id="_checkbox_indeterminate">Indeterminate state</h3>
<p>
You can set <code>checkbox</code> to <code>indeterminate state</code> with attribute <code>data-indeterminate="true"</code>.
</p>
<div class="example">
<input type="checkbox" data-role="checkbox" data-caption="Indeterminate" data-indeterminate="true">
<input type="checkbox" data-role="checkbox" data-caption="Indeterminate" data-indeterminate="true" data-style="2">
</div>
<pre><code>
<input type="checkbox" data-role="checkbox"
data-caption="Indeterminate" data-indeterminate="true">
<input type="checkbox" data-role="checkbox"
data-caption="Indeterminate" data-indeterminate="true" data-style="2">
</code></pre>
<!-- ads-html -->
<h3 id="_checkbox_options">Options</h3>
<table class="table cell-border table-border options-table mt-4">
<thead>
<tr>
<th>Option</th>
<th>Data-*</th>
<th>Default</th>
<th>Desc</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>style</code></td>
<td><code>data-style</code></td>
<td>1</td>
<td>Checkbox style. Must be 1 or 2</td>
</tr>
<tr>
<td><code>caption</code></td>
<td><code>data-caption</code></td>
<td></td>
<td>Checkbox caption</td>
</tr>
<tr>
<td><code>captionPosition</code></td>
<td><code>data-caption-position</code></td>
<td>right</td>
<td>Checkbox caption position: left or right (default)</td>
</tr>
<tr>
<td><code>indeterminate</code></td>
<td><code>data-indeterminate</code></td>
<td>false</td>
<td>Set checkbox to indeterminate state</td>
</tr>
</tbody>
</table>
<h3 id="_checkbox_events">Events</h3>
<table class="table cell-border table-border options-table mt-4">
<thead>
<tr>
<th>Event</th>
<th>Data-*</th>
<th>Context</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>onCheckboxCreate(el)</code></td>
<td><code>data-on-checkbox-create</code></td>
<td>checkbox</td>
</tr>
</tbody>
</table>
<h3 id="_checkbox_methods">Methods</h3>
<p>
You can use methods to interact with input component:
<code>indeterminate()</code>,
<code>disable()</code>,
<code>enable()</code>,
<code>toggleState()</code>.
</p>
<pre><code>
var checkbox = $(el).data('checkbox');
checkbox.toggleState();
</code></pre>
<h3 id="_checkbox_customize">Customize</h3>
<p>
You can customize your input with special attributes:
</p>
<table class="table cell-border table-border options-table mt-4">
<thead>
<tr>
<th>Option</th>
<th>Data-*</th>
<th>Desc</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>clsCheckbox</code></td>
<td><code>data-cls-checkbox</code></td>
<td>Additional classes for control.</td>
</tr>
<tr>
<td><code>clsCaption</code></td>
<td><code>data-cls-caption</code></td>
<td>Additional classes for caption control.</td>
</tr>
<tr>
<td><code>clsCheck</code></td>
<td><code>data-cls-check</code></td>
<td>Additional classes check.</td>
</tr>
</tbody>
</table>
<div class="example">
<style>
.myCheck::before{
border-color: #0b98da ;
}
</style>
<input type="checkbox" checked
data-role="checkbox"
data-style="2"
data-caption="Checkbox"
data-cls-caption="fg-cyan text-bold"
data-cls-check="bd-cyan myCheck">
</div>
<pre><code>
<style>
.myCheck::before{
border-color: #0b98da!important;
}
</style>
<input type="checkbox" checked
data-role="checkbox"
data-style="2"
data-caption="Checkbox"
data-cls-caption="fg-cyan text-bold"
data-cls-check="bd-cyan myCheck">
</code></pre>
</main>
</div>
</div>
<script src="docsearch/docsearch.min.js"></script>
<script src="js/jquery-3.3.1.min.js"></script>
<script src="metro/js/metro.js?ver=@@b-version"></script>
<script src="highlight/highlight.pack.js"></script>
<script src="js/clipboard.min.js"></script>
<script src="js/site.js"></script>
<!-- ads-script -->
<!-- ga-script -->
<!-- hit-ua -->
</body>
</html>