--- layout: layouts/page.njk title: Installation description: How to install and use Basecoat in your app. toc: - label: Installing the CSS id: install-css children: - label: Add Tailwind CSS id: install-css - label: Add Basecoat id: install-css-basecoat - label: Import basecoat in your CSS id: install-css-import - label: That's it id: install-css-done - label: Components with Javascript id: install-js - label: Use the CLI id: install-cli - label: Use Nunjucks or Jinja macros id: install-macros - label: Theming id: install-theming --- {% from "macros/code_block.njk" import code_block %}

Install the CSS

{% lucide "circle-alert" %}

If you don't want to use npm, you can follow the manual installation instructions.

  1. Add Tailwind CSS

    Basecoat uses Tailwind CSS. You need to install it in your project.

    Follow the Tailwind CSS installation instructions to get started.

  2. Add Basecoat

    Add Basecoat to your Tailwind CSS file.

    {% set code %}npm install hunvreus/basecoat{% endset %} {{ code_block(code, "bash") }}

    Alternatively, you can directly copy the basecoat.css file into your project.

  3. Import basecoat in your CSS

    {% set code %}@import "tailwindcss"; @import "basecoat";{% endset %} {{ code_block(code, "css") }}
  4. That's it

    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.

Components with Javascript

Some components require Javascript code to work.

The documentation provides Alpine.js code snippets to cover that. Make sure to install Alpine.js if you decide to use them.

For simple components like Accordion or Slider, you will notice some inline Alpine.js code that you can just copy along with the rest of the HTML.

For more complex components (Dialog, Dropdown Menu, Popover, Select, Tabs and Toast), you have one of 2 options:

You are also welcome to write your own Javascript.

All of the components try and implement WAI-ARIA standards to make them accessible.

Use the CLI

If you're using Nunjucks or Jinja, you can use the CLI to install the CSS and macros for any of the complex components(e.g. Dialog). It will copy the JS and `.html.jinja or .njk macros into your code.

For example, to add the Dialog component, run:

{% set code %}npx basecoatui add dialog{% endset %} {{ code_block(code, "bash") }}

You will be asked to confirm the template engine and destination directory for the Javascript and macros.

Use Nunjucks or Jinja macros

For more complex components, you can use Nunjucks or Jinja macros to help you generate the HTML and Javascript code.

To install them, either copy them directly from the GitHub repository or use the CLI to do the work for you.

For example, here's how you could use the select() macro to generate the HTML and Javascript code for a Select component:

{% set code %}{% raw %}{% call select() %}
Fruits
Apple
Banana
Blueberry
Grapes
Pineapple
{% endcall %}{% endraw %}{% endset %} {{ code_block(code, "jinja") }}

Make sure to include the Javascript code before Alpine.js core JS file:

{% set code %} {% endset %} {{ code_block(code, "jinja") }}

Theming

You can import any shadcn/ui compatible theme (e.g. tweakcn). For example:

Read more about theming on the shadcn/ui website.