Installation
CSS
Add Chi CSS by copying and pasting the stylesheet below into the header of your project. Chi's stylesheet is hosted on Lumen's Assets Server which is a highly available and performant option for loading assets into your Lumen project.
<link rel="stylesheet" href="https://lib.lumen.com/chi/6.13.0/chi.css" integrity="sha256-dTZULQ5pWZi5LGK6y6Qyl+S8pjnl7aaXl9Y8FVFHrvU=" crossorigin="anonymous">
<link rel="stylesheet" href="https://lib.lumen.com/chi/6.13.0/chi-centurylink.css" integrity="sha256-/PkBojMNcSeomO9GGqWa/c4ZkIP1WStkej8Qe70/gZM=" crossorigin="anonymous">
<link rel="stylesheet" href="https://lib.lumen.com/chi/6.13.0/chi-portal.css" integrity="sha256-6SYQp1ACG6mBpzJHDS1EdpNzkYSsxYRCPNFPGrMsL64=" crossorigin="anonymous">
Next, add the chi
CSS class to the <html>
tag of your document to properly scope the styles.
This allows Chi to override any existing styles that have been defined by legacy markup.
<html class="chi">
...
</html>
At this point you can now start using Chi. The documentation includes a wealth of templates and code samples to get you started.
Favicon
A favicon is a small icon associated with a webpage that is typically displayed in a browser's
address bar, bookmarks, and tabs. To add a Lumen favicon to your project, insert the following
code before the closing <head>
tag.
<link rel="icon" type="image/svg+xml" href="https://lib.lumen.com/chi/6.13.0/assets/themes/lumen/images/favicon.svg" integrity="sha256-s8cfYbPxhcrLj+FL/OxALhZoDmlCwvX2/K3I0hq1PAs=" crossorigin="anonymous"><link rel="alternate icon" href="https://lib.lumen.com/chi/6.13.0/assets/themes/lumen/images/favicon.ico" integrity="sha256-EkKmbH+i/VIQAtUl7NF4bPVaaJZCeBc5xWx8LTcMJp0=" crossorigin="anonymous">
<link rel="icon" type="image/svg+xml" href="https://lib.lumen.com/chi/6.13.0/assets/themes/centurylink/images/favicon.svg" integrity="sha256-5RkYwEB1kGRtp6mggDQTuEY/wsmVdIG+AYurQhglosI=" crossorigin="anonymous"><link rel="alternate icon" href="https://lib.lumen.com/chi/6.13.0/assets/themes/centurylink/images/favicon.ico" integrity="sha256-CT3YteLQVYlkdxGsjd628GvTzCD9ViZWmJ3zheSnl3w=" crossorigin="anonymous">
JavaScript
Although Chi can be used as a pure HTML and CSS library with only the stylesheet above, many advanced components like tabs, drop downs, date pickers, and others require JavaScript to function. In most cases the need is minimal. You may write your own JavaScript to integrate Chi's CSS and blueprints into your project, or use Chi's JavaScript library which was written to provide a complete solution.
Chi's JavaScript library depends on Popper.js for positioning components like Popovers and Dropdown menus, and Day.js for calculating dates in the Datepicker component. For the rest, the library is entirely independent.
Chi's JavaScript library is developed as an ES6 component, but with the help of Webpack, it is available in several flavors. Choose the method that best fits your project.
To use the old method of including Chi in your project, include the ES5, browser prepared, JavaScript file from the Lumen Assets Server. In this solution Popper.js and Day.js are bundled into the file.
<script src="https://lib.lumen.com/chi/6.13.0/js/chi.js" integrity="sha256-EVoPuMqk72qbdw1lZZ1eA8cNZoxY8BkI0l2XJlj/BTg=" crossorigin="anonymous"></script>
If you use RequireJS or any other AMD compatible module loader in your project, you will find the AMD compatible
version in the amd
folder. Then, you will have to update your require configuration:
'chi': {
path: [CHI_PATH, 'amd', 'chi'].join('/'),
shim: {
deps: ['Popper'],
exports: 'chi'
}
}
Web Components
Chi Web Components are Custom Elements designed to Lumen's specifications and built according to the HTML Living Standard. They are written in vanilla Javascript for compatibility with major frameworks including AngularJS, ReactJS, VueJS, or no framework at all.
Add Chi Web Components by copying and pasting the JavaScript files below into the header of your web application. Placing the files in the header is important as it will load any Polyfill if the browser doesn't support Web Components.
<script type="module" src="https://lib.lumen.com/chi/6.13.0/js/ce/ux-chi-ce/ux-chi-ce.esm.js" integrity="sha256-cFlx2jk7T8458V4TXVcEbJb+/KQO0w6EBGt1l4R/D+s=" crossorigin="anonymous"></script><script nomodule="" src="https://lib.lumen.com/chi/6.13.0/js/ce/ux-chi-ce/ux-chi-ce.js" integrity="sha256-1itrK6TGDHz2K/JnFHB1HgU8Wm04zfoTca0Q/28IoGo=" crossorigin="anonymous"></script>
After placing the files in your header, you are now ready to use the Web Components described in this documentation.
Chi Web Components can be used in several different ways. The most common are the HTML attributes
and the DOM properties. In most cases, we keep them synchronized. For example, the chi-button
element has
a size
attribute that can be accessed and modified in two ways.
Modifying the HTML attribute
<chi-button id="close-btn" size="md">Close</chi-button>
<script>
document.getElementById("close-btn").setAttribute("size", "xl");
</script>
Setting the DOM property
<chi-button id="close-btn" size="md">Close</chi-button>
<script>
document.getElementById("close-btn").size="xl";
</script>
Some Chi components have boolean attributes which function the same way as the well known disabled
attribute. Boolean attributes are true
when the HTML element has the attribute and false
when not.
Boolean attributes can be set to true this way:
<input type="text" disabled />
<chi-drawer id="drawer" active />
<script>
document.getElementById("drawer").active = true;
document.getElementById("drawer").setAttribute("active", "active");
</script>
And set to false this way:
<input type="text" />
<chi-drawer id="drawer" />
<script>
document.getElementById("drawer").active = false;
document.getElementById("drawer").removeAttribute("active");
</script>
Some components, like chi-drawer
, have helper methods in order to change the state of commonly modified attributes:
<chi-drawer id="drawer" />
<script>
document.getElementById("drawer").show(); // This sets the active property to true
document.getElementById("drawer").hide(); // This sets the active property to false
document.getElementById("drawer").toggle(); // This toggles the state of the active property
</script>
Chi Vue
Chi supports a set of native Vue components. Chi Vue can be installed via Github npm registry or included from CDN as a UMD library.
registry=https://registry.npmjs.org
@centurylink:registry=https://npm.pkg.github.com/centurylink
//npm.pkg.github.com/:_authToken=${GH_TOKEN}
"@centurylink/chi-vue": "3.9.0"
"pinia": "^2.1.4"
import { createApp } from 'vue';
import { ChiVue, ChiSearchInput } from "@centurylink/chi-vue";
import App from './App.vue';
const app = createApp(App);
app.use(ChiVue, {});
app.component("ChiSearchInput", ChiSearchInput);
app.mount('#app');
Chi Vue plugin is optional to be installed with the use function to set up the default configuration
import { createApp } from 'vue';
import { ChiVue } from "@centurylink/chi-vue";
const app = createApp(App);
app.use(ChiVue, {});
It is not necessary to pass any options to the plugin to install all Chi dependencies (CSS, JS and Web Components) as it uses the portal theme and the latest available version of Chi by default. If you want to pass a specific theme or version, the plugin accepts a configuration object:
{
chiOptions: {
theme: 'lumen' | 'portal' | 'centuryLink',
forceVersion: string;
}
}
Here you can see an example installation with a theme and a customized version:
import { createApp } from 'vue';
import { ChiVue } from "@centurylink/chi-vue";
const app = createApp(App);
app.use(ChiVue, {
chiOptions: {
theme: 'centurylink',
forceVersion: '5.78.0'
}
});
<!-- UMD asset -->
<script src="https://cdn.jsdelivr.net/npm/vue-demi@0.14.6"></script>
<script src="https://cdn.jsdelivr.net/npm/pinia@2.1.4"></script>
<script src="https://lib.lumen.com/chi/6.13.0/chi-vue/umd/index.umd.js"></script>
<!-- Vue component example -->
const exampleVueComponent = Vue.createApp({
data() {
return {
// Your data
}
},
methods: {
// Your methods
}
});
exampleVueComponent.component('ChiVuePagination', window["chi-vue"].library.components.ChiPagination);
exampleVueComponent.mount('#example');
<!-- Vue template example -->
<chi-vue-pagination :pages="5" :current-page="currentPage"></chi-vue-pagination>