├── LICENSE.md ├── README.md ├── bower.json ├── package.json ├── screenshot.png ├── typeaheadjs.css └── typeaheadjs.scss /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Bass Jobsen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Typeahead.js and Bootstrap 4 2 | ============================ 3 | 4 | For Bootstrap 3 try [typeaheadjs.css](https://github.com/bassjobsen/typeahead.js-bootstrap-css/) 5 | 6 | typeahead.js 7 | ------------ 8 | The [typeahead.js](https://github.com/twitter/typeahead.js) library consists of 2 components: the suggestion engine, Bloodhound, and the UI view, Typeahead. The suggestion engine is responsible for computing suggestions for a given query. The UI view is responsible for rendering suggestions and handling DOM interactions. Both components can be used separately, but when used together, they can provided a rich typeahead experience. 9 | 10 | Bootstrap 4 11 | ----------- 12 | Bootstrap is a sleek, intuitive, and powerful front-end framework for faster and easier web development, created by [Mark Otto](http://twitter.com/mdo) and [Jacob Thornton](http://twitter.com/fat), and maintained by the [core team](https://github.com/twbs?tab=members) with the massive support and involvement of the community. 13 | 14 | To get started, check out ! 15 | 16 | History 17 | ------- 18 | With Twitter Bootstrap 3 the typeahead plugin had been dropped. [@mdo](http://twitter.com/mdo) says: "in favor of folks using [Twitter's typeahead](https://github.com/twitter/typeahead.js). Twitter's typeahead has more features than the old bootstrap-typeahead.js and less bugs." Twitter's typeahead don't work direct with Bootstrap 4. The DOM structure of the dropdown menu used by `typeahead.js` differs from the DOM structure of the Bootstrap dropdown menu. You'll need to load some additional CSS in order to get the `typeahead.js` dropdown menu to fit the default Bootstrap theme. You can download the basic CSS here, or use the SCSS file to integrate it into your project. CSS and SCSS are build with the latest SCSS code of Bootstrap 4 (alpha). Code does not introduce new mixins and only extends Bootstrap's SCSS. 19 | 20 | Note also the [orginal typeahead plugin](https://github.com/bassjobsen/Bootstrap-3-Typeahead) still works with Bootstrap 4. 21 | 22 | Download 23 | ======== 24 | 25 | - Download the latest [typeaheadjs.css](https://github.com/bassjobsen/typeahead.js-bootstrap4-css/blob/master/typeaheadjs.css) or [typeaheadjs.scss](https://github.com/bassjobsen/typeahead.js-bootstrap4-css/blob/master/typeaheadjs.scss). 26 | 27 | How to use 28 | ========== 29 | 30 | CSS 31 | --- 32 | Include the CSS file after Bootstrap's CSS in your HTML: 33 | 34 | ```html 35 | 36 | 37 | ``` 38 | 39 | Sass 40 | ---- 41 | 1. Copy typeaheadjs.scss into your Bootstrap's SCSS folder 42 | 2. Import this file at the end of bootstrap.scss: `@import "typeaheadjs.scss";` 43 | 3. Recompile Bootstrap 44 | 45 | Example 46 | ------- 47 | ![ScreenShot](https://raw.github.com/bassjobsen/typeahead.js-bootstrap4-css/master/screenshot.png) 48 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "typeahead.js-bootstrap4.scss", 3 | "version": "1.0.0", 4 | "main": [ 5 | "typeaheadjs.css", 6 | "typeaheadjs.scss" 7 | ], 8 | "dependencies": { 9 | "bootstrap": "4.0", 10 | "typeahead.js": "~0.11.0" 11 | }, 12 | "ignore":[ 13 | ".gitignore", 14 | ".gitmodules", 15 | ".travis.yml", 16 | "package.json" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "typeahead.js-bootstrap4-css", 3 | "description": "Bootstrap4 style for typeahead.js using Bootstrap 4 mixins and variables", 4 | "version": "1.0.0", 5 | "keywords": [ 6 | "sass", 7 | "scss", 8 | "bootstrap", 9 | "typeahead.js" 10 | ], 11 | "homepage": "https://github.com/bassjobsen/typeahead.js-bootstrap4-css/", 12 | "author": "Bass Jobsen", 13 | "repository": { 14 | "type": "git", 15 | "url": "https://github.com/bassjobsen/typeahead.js-bootstrap4-css/" 16 | }, 17 | "bugs": { 18 | "url": "https://github.com/bassjobsen/typeahead.js-bootstrap4-css/issues" 19 | }, 20 | "licenses": [ 21 | { 22 | "type": "MIT", 23 | "url": "http://www.opensource.org/licenses/MIT" 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bassjobsen/typeahead.js-bootstrap4-css/f589b59adc5cbe3aed11bbdae7906a56b432cf92/screenshot.png -------------------------------------------------------------------------------- /typeaheadjs.css: -------------------------------------------------------------------------------- 1 | span.twitter-typeahead .tt-menu { 2 | cursor: pointer; 3 | } 4 | 5 | .dropdown-menu, span.twitter-typeahead .tt-menu { 6 | position: absolute; 7 | top: 100%; 8 | left: 0; 9 | z-index: 1000; 10 | display: none; 11 | float: left; 12 | min-width: 160px; 13 | padding: 5px 0; 14 | margin: 2px 0 0; 15 | font-size: 1rem; 16 | color: #373a3c; 17 | text-align: left; 18 | list-style: none; 19 | background-color: #fff; 20 | background-clip: padding-box; 21 | border: 1px solid rgba(0, 0, 0, 0.15); 22 | border-radius: 0.25rem; } 23 | 24 | span.twitter-typeahead .tt-suggestion { 25 | display: block; 26 | width: 100%; 27 | padding: 3px 20px; 28 | clear: both; 29 | font-weight: normal; 30 | line-height: 1.5; 31 | color: #373a3c; 32 | text-align: inherit; 33 | white-space: nowrap; 34 | background: none; 35 | border: 0; } 36 | span.twitter-typeahead .tt-suggestion:focus, .dropdown-item:hover, span.twitter-typeahead .tt-suggestion:hover { 37 | color: #2b2d2f; 38 | text-decoration: none; 39 | background-color: #f5f5f5; } 40 | span.twitter-typeahead .active.tt-suggestion, span.twitter-typeahead .tt-suggestion.tt-cursor, span.twitter-typeahead .active.tt-suggestion:focus, span.twitter-typeahead .tt-suggestion.tt-cursor:focus, span.twitter-typeahead .active.tt-suggestion:hover, span.twitter-typeahead .tt-suggestion.tt-cursor:hover { 41 | color: #fff; 42 | text-decoration: none; 43 | background-color: #0275d8; 44 | outline: 0; } 45 | span.twitter-typeahead .disabled.tt-suggestion, span.twitter-typeahead .disabled.tt-suggestion:focus, span.twitter-typeahead .disabled.tt-suggestion:hover { 46 | color: #818a91; } 47 | span.twitter-typeahead .disabled.tt-suggestion:focus, span.twitter-typeahead .disabled.tt-suggestion:hover { 48 | text-decoration: none; 49 | cursor: not-allowed; 50 | background-color: transparent; 51 | background-image: none; 52 | filter: "progid:DXImageTransform.Microsoft.gradient(enabled = false)"; } 53 | span.twitter-typeahead { 54 | width: 100%; } 55 | .input-group span.twitter-typeahead { 56 | display: block !important; } 57 | .input-group span.twitter-typeahead .tt-menu { 58 | top: 2.375rem !important; } 59 | -------------------------------------------------------------------------------- /typeaheadjs.scss: -------------------------------------------------------------------------------- 1 | span.twitter-typeahead { 2 | 3 | .tt-menu { 4 | @extend .dropdown-menu; 5 | } 6 | 7 | .tt-suggestion { 8 | @extend .dropdown-item; 9 | } 10 | 11 | .tt-suggestion.tt-cursor { 12 | @extend .dropdown-item.active; 13 | } 14 | 15 | .input-group & { 16 | display: flex !important; 17 | align-items: center; 18 | position: relative; 19 | flex: 1 1 auto; 20 | width: 1%; 21 | 22 | .tt-menu, .tt-hint, .tt-input { 23 | width: 100%; 24 | } 25 | } 26 | } 27 | --------------------------------------------------------------------------------