177 lines
8.7 KiB
Plaintext
177 lines
8.7 KiB
Plaintext
---
|
||
description: Tom Select is a versatile and dynamic "<select> UI control. With autocomplete and native-feeling keyboard navigation, it's useful for tagging, contact lists, country selectors, and so on
|
||
---
|
||
|
||
{% from "demo.njk" import demo_mini %}
|
||
|
||
<div class="text-center">
|
||
<h1 class="display-2 mt-5">Tom Select</h1>
|
||
|
||
<a href="https://github.com/orchidjs/tom-select" class="m-1 d-inline-block"><img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/orchidjs/tom-select?label=GitHub%20stars&color=007ec6"></a>
|
||
<a href="https://www.jsdelivr.com/package/npm/tom-select" class="m-1 d-inline-block"><img alt="jsDelivr hits (npm)" src="https://img.shields.io/jsdelivr/npm/hm/tom-select?label=jsDelivr%20hits&color=007ec6"></a>
|
||
<a href="https://www.npmjs.com/package/tom-select" class="m-1 d-inline-block"><img alt="npmjs.org" src="https://img.shields.io/npm/v/tom-select.svg?color=007ec6"></a>
|
||
<a href="https://travis-ci.com/orchidjs/tom-select" class="m-1 d-inline-block"><img alt="travis-ci.com" src="https://img.shields.io/travis/com/orchidjs/tom-select?color=4c1"></a>
|
||
<a href="https://coveralls.io/github/orchidjs/tom-select" class="m-1 d-inline-block"><img alt="Coveralls Coverage" src="https://img.shields.io/coveralls/github/orchidjs/tom-select?color=4c1"></a>
|
||
<a href="https://github.com/orchidjs/tom-select/issues" class="m-1 d-inline-block"><img alt="GitHub Issues" src="https://img.shields.io/github/issues/orchidjs/tom-select"></a>
|
||
{# <a href="https://automate.browserstack.com/public-build/QXZ2Z2JUaUlSV2REcHRZYzIzQThxemRnNXNQZ0c3Lzh3d01FWE4vSk1oMD0tLVFFTGlUdmxaMWNIL3hCTUJXZk1qanc9PQ==--f7c82c941ca5c14a22f826b97bc02da17c071d5e"><img alt="Browserstack Status" src="https://automate.browserstack.com/badge.svg?badge_key=QXZ2Z2JUaUlSV2REcHRZYzIzQThxemRnNXNQZ0c3Lzh3d01FWE4vSk1oMD0tLVFFTGlUdmxaMWNIL3hCTUJXZk1qanc9PQ==--f7c82c941ca5c14a22f826b97bc02da17c071d5e"/></a> #}
|
||
</div>
|
||
|
||
|
||
<div class="row py-5">
|
||
<div class="col-600 mx-auto">
|
||
|
||
{% set html %}
|
||
<select id="select-tags" multiple placeholder="Best movies and TV shows">
|
||
<optgroup label="TV Shows">
|
||
<option value="Blue Bloods" data-date="2010-2021">Blue Bloods (2010-2021)</option>
|
||
<option value="Magnum P.I." data-date="1980-1988" selected>Magnum P.I. (1980-1988)</option>
|
||
</optgroup>
|
||
<optgroup label="Movies">
|
||
<option value="An Innocent Man" data-date="1989">An Innocent Man (1989)</option>
|
||
<option value="In & Out" data-date="1997">In & Out (1997)</option>
|
||
<option value="Lassiter" data-date="1984">Lassiter (1984)</option>
|
||
<option value="Mr. Baseball" data-date="1992">Mr. Baseball (1992)</option>
|
||
<option value="Quigley Down Under" data-date="1990">Quigley Down Under (1990)</option>
|
||
<option value="Three Men and a Baby" data-date="1987">Three Men and a Baby (1987)</option>
|
||
</optgroup>
|
||
</select>
|
||
{% endset %}
|
||
|
||
<script>
|
||
{% set script %}
|
||
new TomSelect("#select-tags",{
|
||
plugins: ['remove_button'],
|
||
create: true,
|
||
onItemAdd:function(){
|
||
this.setTextboxValue('');
|
||
this.refreshOptions();
|
||
},
|
||
render:{
|
||
option:function(data,escape){
|
||
return '<div class="d-flex"><span>' + escape(data.value) + '</span><span class="ms-auto text-muted">' + escape(data.date) + '</span></div>';
|
||
},
|
||
item:function(data,escape){
|
||
return '<div>' + escape(data.value) + '</div>';
|
||
}
|
||
}
|
||
});
|
||
{% endset %}
|
||
</script>
|
||
|
||
{{ demo_mini( 'Example', html, script) }}
|
||
</div>
|
||
</div>
|
||
|
||
<div class="lead my-5">
|
||
Tom Select is a versatile and dynamic <select> UI control.
|
||
With autocomplete and native-feeling keyboard navigation, it's useful for tagging, contact lists, country selectors, and so on.
|
||
Tom Select was forked from <a href="/docs/selectize.js/">selectize.js</a> with four main objectives: modernizing the code base, decoupling from jQuery, expanding functionality, and addressing issue backlogs.
|
||
</div>
|
||
|
||
|
||
|
||
|
||
<h2>Features</h2>
|
||
<ul>
|
||
<li><strong>Smart Option Searching / Ranking</strong><br>Options are efficiently scored and sorted on-the-fly (using <a href="https://github.com/orchidjs/sifter.js">sifter</a>). Want to search an item's title <i>and</i> description? No problem.</li>
|
||
<li><strong>Caret between items</strong><br>Order matters sometimes. Use the <kbd>←</kbd> and <kbd>→</kbd> arrow keys to move between selected items.</li>
|
||
<li><strong>Select & delete multiple items at once</strong><br>Hold down <kbd>command</kbd> on Mac or <kbd>ctrl</kbd> on Windows to select more than one item to delete.</li>
|
||
<li><strong>Díåcritîçs supported</strong><br>Great for international environments.</li>
|
||
<li><strong>Item creation</strong><br>Allow users to create items on the fly (async saving is supported; the control locks until the callback is fired).</li>
|
||
<li><strong>Remote data loading</strong><br>For when you have thousands of options and want them provided by the server as the user types.</li>
|
||
<li><strong>Extensible</strong><br> <a href="docs/plugins">Plugin API</a> for developing custom features (uses <a href="https://github.com/brianreavis/microplugin.js">microplugin</a>).
|
||
<li><strong>Accessible</strong>, <strong>Touch Support</strong>, <strong>Clean API</strong> ... </li>
|
||
</ul>
|
||
|
||
<h2>Usage</h2>
|
||
|
||
{% highlight "html" %}
|
||
<input id="tom-select-it" />
|
||
<link rel="stylesheet" href="/css/tom-select.default.css">
|
||
<script src="/js/tom-select.complete.js"></script>
|
||
<script>
|
||
var config = {};
|
||
new TomSelect('#tom-select-it',config);
|
||
</script>
|
||
{% endhighlight %}
|
||
|
||
<p>Available configuration settings are <a href="/docs">documented here</a></p>
|
||
|
||
|
||
<h2>Installation</h2>
|
||
|
||
<p>All pre-built files needed to use Tom Select can be found in the "dist" folder from each of these sources:</p>
|
||
|
||
<div class="row row-cols-1 row-cols-md-3 g-4">
|
||
<div class="col">
|
||
<div class="card h-100">
|
||
<a class="card-header h4 mt-0" href="https://www.npmjs.com/package/tom-select">npm</a>
|
||
<div class="card-body">
|
||
<div>{% highlight "shell" %}npm i tom-select{% endhighlight %}</div>
|
||
<div><a href="/docs/contribute">Additional CLI usage</a></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="col">
|
||
<div class="card h-100">
|
||
<a class="card-header h4 mt-0" href="https://www.jsdelivr.com/package/npm/tom-select?path=dist">jsDelivr</a>
|
||
<div class="card-body">
|
||
The fastest way to add Tom Select into your project is to just include the js and css from jsDelivr.
|
||
{% highlight "html" %}
|
||
<link href="https://cdn.jsdelivr.net/npm/tom-select@//@@version/dist/css/tom-select.css" rel="stylesheet">
|
||
<script src="https://cdn.jsdelivr.net/npm/tom-select@//@@version/dist/js/tom-select.complete.min.js"></script>
|
||
{% endhighlight %}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="col">
|
||
<div class="card h-100">
|
||
<a class="card-header h4 mt-0" href="https://github.com/orchidjs/tom-select/">GitHub</a>
|
||
<div class="card-body">
|
||
<a href="https://github.com/orchidjs/tom-select/">Clone the full repo from GitHub</a> to create custom builds.
|
||
Use <code>npm run build</code> <a href="/docs/contribute">and other commands</a> to build from source, test and start the doc server.
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
|
||
|
||
|
||
<h2>Files</h2>
|
||
<ul>
|
||
<li><a href="https://cdn.jsdelivr.net/npm/tom-select@//@@version/dist/js/tom-select.complete.js">tom-select.complete.js</a> — Includes dependencies and plugins</li>
|
||
<li><a href="https://cdn.jsdelivr.net/npm/tom-select@//@@version/dist/js/tom-select.base.js">tom-select.base.js</a> — Does not include any plugins</li>
|
||
<li><a href="https://cdn.jsdelivr.net/npm/tom-select@//@@version/dist/css">CSS</a> — Compiled themes</li>
|
||
<li><a href="https://cdn.jsdelivr.net/npm/tom-select@//@@version/dist/scss">SCSS</a> — Uncompiled theme sources</li>
|
||
</ul>
|
||
|
||
|
||
|
||
<h2>Platinum Sponsors</h2>
|
||
<p>
|
||
Many thanks to all our sponsors who help make development possible. <a href="https://opencollective.com/tom-select">Become a sponsor</a>.
|
||
</p>
|
||
<br>
|
||
<p>
|
||
<a href="http://www.peopleforce.io"><img src="https://raw.githubusercontent.com/orchidjs/tom-select/master/doc_src/img/peopleforce.png"></a>
|
||
</p>
|
||
<br>
|
||
|
||
|
||
<h2>Sponsors</h2>
|
||
<br>
|
||
<p>
|
||
<a href="https://opencollective.com/tom-select/sponsor/0/website"><img src="https://opencollective.com/tom-select/sponsor/0/avatar.svg" alt="Trust My Paper Logo"></a>
|
||
</p>
|
||
<br>
|
||
|
||
<h2>License</h2>
|
||
|
||
<p>Copyright © 2013–{{ helpers.currentYear() }} <a href="https://github.com/orchidjs/tom-select/graphs/contributors">Contributors</a></p>
|
||
|
||
<p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a></p>
|
||
|
||
<p>Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.</p>
|