--- layout: layouts/page.njk title: Installation description: How to install and use Basecoat in your app. toc: - label: Install using the CDN id: install-cdn children: - label: Install all components id: install-cdn-all - label: Install specific components id: install-cdn-specific - label: Installing using NPM id: install-npm children: - label: "Step 1: Add Tailwind CSS" id: install-npm-tailwind - label: "Step 2: Add Basecoat" id: install-npm-basecoat - label: "Step 3: Import Basecoat" id: install-npm-import - label: "Step 4: Add JavaScript files" id: install-npm-js - label: "Step 5: Use components" id: install-npm-done - label: Components with JavaScript id: install-js --- {% from "macros/code_block.njk" import code_block %} {% from "tabs.njk" import tabs %}
Add the following to the <head> of your HTML file:
The default CDN stylesheet is the Basecoat backward-compatible default. To use a specific style, load the matching standalone stylesheet instead:
While the JavaScript file for all components is small (around 3kB gzipped), you can cherry-pick the components you need as instructed in the component's page (Dropdown Menu, Popover, Select, Sidebar, Tabs and Toast). For example, to add the Dropdown Menu component, add the following to the <head> of your HTML file:
Basecoat uses Tailwind CSS. You need to install it in your project.
Follow the Tailwind CSS installation instructions to get started.
Add Basecoat to your Tailwind CSS file.
Alternatively, you can directly copy the basecoat.css file into your project.
The default import is the Basecoat backward-compatible default. To use a specific style, import the standalone style bundle instead:
Some components need some JavaScript (e.g. the Tabs component). There are two ways to get it into your project:
If your project is ESM-aware you can directly import the scripts. To include all components:
Or cherry-pick specific components, for example:
Copy the pre-built files from node_modules into your public directory:
Then reference the script you need as well as the basecoat.min.js file (used to register and initialize components):
See each component page for the minimal script required.
You can now use any of the Basecoat classes in your project (e.g. btn, card, input, etc). Read the documentation about each component to get started (e.g. button, card, input, etc).
Some components (e.g. Select) require JavaScript code to work.
A handful of components require JavaScript code to work, specifically Dropdown Menu, Popover, Select, Sidebar, Tabs and Toast
If a component requires JavaScript, the documentation page will provide instructions. There are 2 options to add the JavaScript code to your project:
<head> of your HTML file, or just the file for the component you want to use as instructed on the component's page.all.min.js or all.js).