You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
351 lines
11 KiB
351 lines
11 KiB
---
|
|
layout : 'default'
|
|
css : 'checkbox'
|
|
element : 'checkbox'
|
|
elementType : 'module'
|
|
|
|
title : 'Checkbox'
|
|
description : "A checkbox allows a user to select a value from a small set of options, often binary"
|
|
type : 'UI Module'
|
|
|
|
themes : ['Default']
|
|
---
|
|
<script src="/javascript/checkbox.js"></script>
|
|
<link rel="stylesheet/less" type="text/css" href="/build/less/definitions/modules/checkbox.less" />
|
|
|
|
<%- @partial('header', { tabs: 'module' }) %>
|
|
|
|
<div class="main container">
|
|
|
|
<div class="ui tab" data-tab="definition">
|
|
|
|
|
|
<h2 class="ui dividing header">Types</h2>
|
|
|
|
<div class="example">
|
|
<h4 class="ui header">Checkbox</h4>
|
|
<p>A standard checkbox</p>
|
|
<div class="ui checkbox">
|
|
<input type="checkbox" name="fun" />
|
|
<label>I enjoy having fun</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="example">
|
|
<h4 class="ui header">Slider</h4>
|
|
<p>A checkbox can be formatted to emphasize the current selection state</p>
|
|
<div class="ui slider checkbox">
|
|
<input type="checkbox" name="newsletter" />
|
|
<label>Receive weekly poodle newsletter</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="example">
|
|
<h4 class="ui header">Toggle</h4>
|
|
<p>A checkbox can be formatted to show an on or off choice</p>
|
|
<div class="ui toggle checkbox">
|
|
<input type="checkbox" name="public" />
|
|
<label>Make my dog's profile public</label>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="example">
|
|
<h4 class="ui header">Radio Box</h4>
|
|
<p>A checkbox can be formatted as a radio element. This means it is an exclusive option.</p>
|
|
<div class="ui form">
|
|
<div class="grouped inline fields">
|
|
<div class="field">
|
|
<div class="ui radio checkbox">
|
|
<input type="radio" name="fruit" checked="checked" />
|
|
<label>Apples</label>
|
|
</div>
|
|
</div>
|
|
<div class="field">
|
|
<div class="ui radio checkbox">
|
|
<input type="radio" name="fruit" />
|
|
<label>Oranges</label>
|
|
</div>
|
|
</div>
|
|
<div class="field">
|
|
<div class="ui radio checkbox">
|
|
<input type="radio" name="fruit" />
|
|
<label>Pears</label>
|
|
</div>
|
|
</div>
|
|
<div class="field">
|
|
<div class="ui radio checkbox">
|
|
<input type="radio" name="fruit" />
|
|
<label>Grapefruit</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<h2 class="ui dividing header">States</h2>
|
|
|
|
<div class="example">
|
|
<h4 class="ui header">Read-only</h4>
|
|
<p>A checkbox can be read-only and unable to change states</p>
|
|
<div class="ui read-only checkbox">
|
|
<input type="checkbox" />
|
|
<label>Read Only</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="example">
|
|
<h4 class="ui header">Disabled</h4>
|
|
<p>A checkbox can be read-only and unable to change states</p>
|
|
<div class="ui info message">
|
|
A checkbox can be disabled by either setting disabled on the hidden input, or class <code>disabled</code> on the <code>ui checkbox</code>
|
|
</div>
|
|
<div class="ui disabled checkbox">
|
|
<input type="checkbox" disabled="disabled" />
|
|
<label>Disabled</label>
|
|
</div>
|
|
<br>
|
|
<br>
|
|
<div class="ui toggle checkbox">
|
|
<input type="checkbox" disabled="disabled" />
|
|
<label>Disabled</label>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="ui tab" data-tab="usage">
|
|
|
|
<h3 class="ui header">Checkbox</h3>
|
|
<p>A checkbox can be initialized with javascript for increase programmatic control</p>
|
|
|
|
<div class="code">
|
|
$('.ui.checkbox')
|
|
.checkbox()
|
|
;
|
|
</div>
|
|
<div class="code" data-type="html">
|
|
<div class="ui checkbox">
|
|
<input type="checkbox">
|
|
<label>Poodle</label>
|
|
</div>
|
|
</div>
|
|
|
|
<h3 class="ui header">Basic Checkbox</h3>
|
|
<p>A checkbox can also be used without using javascript by matching the <code>id</code> attribute of the input field to the <code>for</code> attribute of the accompanying label</p>
|
|
<div class="code" data-type="html">
|
|
<div class="ui checkbox">
|
|
<input type="checkbox" id="unique-id" />
|
|
<label for="unique-id">Poodle</label>
|
|
</div>
|
|
</div>
|
|
|
|
<h2 class="ui dividing header">Behavior</h2>
|
|
<table class="ui definition celled table segment">
|
|
<tr>
|
|
<td>enable</td>
|
|
<td>A checkbox can change to show a user has selected it</td>
|
|
</tr>
|
|
<tr>
|
|
<td>disable</td>
|
|
<td>A checkbox can change to show a user has deselected it</td>
|
|
</tr>
|
|
<tr>
|
|
<td>toggle</td>
|
|
<td>A checkbox can toggle its current selection state</td>
|
|
</tr>
|
|
</table>
|
|
|
|
|
|
</div>
|
|
|
|
<div class="ui tab" data-tab="examples">
|
|
|
|
<h2>Examples</h2>
|
|
<div class="example">
|
|
<h4 class="ui header">Disabled / Read Only / Forced</h4>
|
|
<p>To disable a checkbox, add the property <code>disabled</code> to your input.</p>
|
|
<p>To make a checkbox read-only do not initialize it, or include the <code>read-only</code> class which will not allow events even if initialized.</p>
|
|
<p>To make a user able to check a box, but unable to uncheck it, use the <code>uncheckable</code> setting.</p>
|
|
<div class="evaluated code" data-type="javascript">
|
|
$('#demo3')
|
|
.checkbox({
|
|
uncheckable: true
|
|
})
|
|
;
|
|
</div>
|
|
<div class="ui form">
|
|
<div class="field">
|
|
<div class="ui checkbox" id="demo1">
|
|
<input type="checkbox" disabled="disabled" checked="checked" />
|
|
<label> Disabled</label>
|
|
</div>
|
|
</div>
|
|
<div class="field">
|
|
<div class="ui read-only checkbox" id="demo2">
|
|
<input type="checkbox" checked="checked" />
|
|
<label> Read Only</label>
|
|
</div>
|
|
</div>
|
|
<div class="field">
|
|
<div class="ui checkbox" id="demo3">
|
|
<input type="checkbox" />
|
|
<label> Cannot Be Unchecked</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="example">
|
|
<h4 class="ui header">Attaching Events to other Elements</h4>
|
|
<p>Checkbox can use the <code>attach events</code> behavior to attach events easily to other activating elements. This defaults to toggling, but other behaviors can be used as well.</p>
|
|
<div class="evaluated code">
|
|
$('.test.checkbox').checkbox('attach events', '.toggle.button');
|
|
$('.test.checkbox').checkbox('attach events', '.check.button', 'check');
|
|
$('.test.checkbox').checkbox('attach events', '.uncheck.button', 'uncheck');
|
|
</div>
|
|
<div class="ui toggle button">Toggle</div>
|
|
<div class="ui positive check button">Check</div>
|
|
<div class="ui negative uncheck button">Uncheck</div>
|
|
<br><br>
|
|
<div class="ui test slider checkbox">
|
|
<input type="checkbox" />
|
|
<div class="box"></div>
|
|
</div>
|
|
<div class="ui test slider checkbox">
|
|
<input type="checkbox" checked="checked" />
|
|
<div class="box"></div>
|
|
</div>
|
|
<div class="ui test slider checkbox">
|
|
<input type="checkbox" />
|
|
<div class="box"></div>
|
|
</div>
|
|
<div class="ui test slider checkbox">
|
|
<input type="checkbox" checked="checked" />
|
|
<div class="box"></div>
|
|
</div>
|
|
<div class="ui test slider checkbox">
|
|
<input type="checkbox" />
|
|
<div class="box"></div>
|
|
</div>
|
|
<div class="ui test slider checkbox">
|
|
<input type="checkbox" />
|
|
<div class="box"></div>
|
|
</div>
|
|
<div class="ui test slider checkbox">
|
|
<input type="checkbox" checked="checked" />
|
|
<div class="box"></div>
|
|
</div>
|
|
<div class="ui test slider checkbox">
|
|
<input type="checkbox" />
|
|
<div class="box"></div>
|
|
</div>
|
|
<div class="ui test slider checkbox">
|
|
<input type="checkbox" checked="checked" />
|
|
<div class="box"></div>
|
|
</div>
|
|
<div class="ui test slider checkbox">
|
|
<input type="checkbox" />
|
|
<div class="box"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="ui tab" data-tab="settings">
|
|
|
|
<h3 class="ui header">
|
|
Checkbox Settings
|
|
<div class="sub header">Checkbox settings modify its behavior</div>
|
|
</h3>
|
|
<table class="ui celled sortable definition table segment">
|
|
<thead>
|
|
<th>Setting</th>
|
|
<th class="four wide">Default</th>
|
|
<th>Description</th>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>required</td>
|
|
<td>auto</td>
|
|
<td>Setting to true/false will determine whether an input will allow no selection. Auto will set disallow this behavior only for radio boxes</td>
|
|
</tr>
|
|
<tr>
|
|
<td>context</td>
|
|
<td>false</td>
|
|
<td>A selector or jQuery object to use as a delegated event context</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<h3 class="ui header">
|
|
Callbacks
|
|
<div class="sub header">Callbacks specify a function to occur after a specific behavior.</div>
|
|
</h3>
|
|
|
|
<table class="ui celled sortable definition table segment">
|
|
<thead>
|
|
<th class="four wide">Setting</th>
|
|
<th>Context</th>
|
|
<th>Description</th>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>onChange</td>
|
|
<td>Checkbox</td>
|
|
<td>Callback after a checkbox is either disabled or enabled.</td>
|
|
</tr>
|
|
<tr>
|
|
<td>onEnable</td>
|
|
<td>Checkbox</td>
|
|
<td>Callback after a checkbox is enabled.</td>
|
|
</tr>
|
|
<tr>
|
|
<td>onDisable</td>
|
|
<td>Checkbox</td>
|
|
<td>Callback after a checkbox is disabled.</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<h3 class="ui header">DOM Settings
|
|
<div class="sub header">DOM settings specify how this module should interface with the DOM</div>
|
|
</h3>
|
|
<table class="ui celled sortable definition table segment">
|
|
<thead>
|
|
<th>Setting</th>
|
|
<th class="four wide">Default</th>
|
|
<th>Description</th>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>namespace</td>
|
|
<td>checkbox</td>
|
|
<td>Event namespace. Makes sure module teardown does not effect other events attached to an element.</td>
|
|
</tr>
|
|
<tr>
|
|
<td>selector</td>
|
|
<td colspan="2">
|
|
<div class="code">
|
|
selector : {
|
|
input : 'input',
|
|
label : 'label'
|
|
}
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>className</td>
|
|
<td colspan="2">
|
|
<div class="code">
|
|
className : {
|
|
radio : 'radio'
|
|
}
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
</div>
|