Buy me a coffee

Installation

Add distill-ui to a Vue 3 or Nuxt project. You don't need Tailwind.

With the CLI

1. Set up the tokens

Run this in your project's folder:

npx distill-ui init

It does three things:

  • copies the tokens into src/styles/distill-ui,
  • imports them at the top of src/main.ts (in Nuxt it prints the lines to add to nuxt.config.ts),
  • saves where things go in distill-ui.json.
distill-ui.json
{
	"framework": "vue",
	"components": "src/components/ui",
	"styles": "src/styles/distill-ui"
}

Change the folders in that file before adding components if you want them somewhere else.

In Nuxt the folders start with app/ (or with nothing, in projects without an app folder): app/components/ui and app/assets/styles/distill-ui.

2. Add components

npx distill-ui add button dialog

This copies each component into src/components/ui, along with any other component it uses (Dialog uses Button). It also installs reka-ui with your package manager when a component needs them. Run npx distill-ui list to see everything you can add, or npx distill-ui add --all to add it all.

The CLI never replaces a file you've changed. Pass --overwrite if you want the latest version back.

3. Use them

<script setup lang="ts">
import { Button } from '@/components/ui/button';
import * as Dialog from '@/components/ui/dialog';
</script>

<template>
	<Button>Click me</Button>
</template>

Projects made with npm create vue point @ at src. In Nuxt, import from ~/components/ui/button.

Manually

Everything the CLI does, you can do by copying files yourself.

  1. Copy the packages/tokens folder from the GitHub repo into src/styles/distill-ui: tokens.css and keyframes.css.
  2. Import the tokens once, in your app's entry file:
    src/main.ts
    import './styles/distill-ui/tokens.css';
    import { createApp } from 'vue';
    import App from './App.vue';
    
    createApp(App).mount('#app');
    
    In Nuxt, add them to nuxt.config.ts instead, and have Nuxt auto-import only the .vue files:
    nuxt.config.ts
    export default defineNuxtConfig({
    	css: ['~/assets/styles/distill-ui/tokens.css'],
    	// Each component folder has an index.ts; auto-import only the .vue files so they don't clash.
    	components: [{ path: '~/components', extensions: ['.vue'] }]
    });
    
  3. Install the packages that dialogs, menus and other interactive components use:
    npm install reka-ui
    
  4. Copy the files from each component's page, under Installation → Manual, into src/components/ui/<component>.

Next: Theming →