CSS-in-JS without CSS and JS
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Table of Contents
CSS-in-JS-in-HTML is a JavaScript library which permits you to apply CSS properties with also some useful features to design your dynamic HTML elements.
The followed prerequisites are the minimum requirements to use the library. The library may work with older browsers with the polyfills but it's not guaranteed (and recommended).
Modern browers
- Chrome 9+
- Edge 12+
- Firefox 6+
- Safari 5.1+
- Opera 12.1+
Browsers for mobile
- IOS Safari 5.1+
- UC Browser for Android 11
- Firefox for Android 49
Older browsers
- IE10+
-
Import
index.min.js
(orindex.js
) in your HTML file<script src="https://cdn.jsdelivr.net/gh/ulyssear/css-in-js-in-html@0.1.6/build/index.min.js"></script>
-
Add one line of CSS to hide the page while building (and permits to hide elements with hidden attribute)
html[aria-busy="true"], [hidden] { display: none!important; }
- Call
CSS_IN_JS_IN_HTML.init(document,null)
to start the library. The optimal use case is to call it in theDOMContentLoaded
event.
document.addEventListener('DOMContentLoaded', () => CSS_IN_JS_IN_HTML.init(document, null));
- Clone the repo
git clone https://github.com/ulyssear/css-in-js-in-html.git
- Import
index.min.js
(orindex.js
) in your HTML file<script src="path/to/css-in-js-in-html/build/index.min.js"></script>
Some polyfills are required to make the library work on older browsers (IE9 and above). You can add them by importing the following file in your HTML file.
<script type="text/javascript" src="path/to/css-in-js-in-html/build/polyfill.min.js"></script>
The polyfills permit to use the following features :
window.getComputedStyle
Array.isArray
Array.prototype.lastIndexOf
Array.prototype.reduce
addEventListener
window.matchMedia
document.querySelectorAll
document.querySelector
String.prototype.trim
It's recommended to not use the polyfills if you don't need to support old browsers.
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
Ulysse ARNAUD - ulysse@arnaud.tech
Project Link: https://github.com/ulyssear/css-in-js-in-html