npm install vue-litewind
Vue-litewind uses Tailwindcss as CSS framework. To install Tailwindcss follow instruction in their offical documentation.
Install tailwindcss-forms plugin that provides a basic reset for form styles that makes form elements easy to override with utilities:
npm install -D @tailwindcss/forms
Step 1. Configure Tailwind.
Add following to tailwind.config.js
:
content
so tailwind can generate utility classes used by components internally,class
option,colors
definitions. You can chose any colors for primary, secondary etctailwindcss-forms
plugin to plugins array// tailwind.config.js
const colors = require('tailwindcss/colors')
module.exports = {
content: [
'node_modules/vue-litewind',
'./src/**/*.html',
'./src/**/*.vue',
'./src/**/*.js',
],
darkMode: 'class',
theme: {
extend: {
colors: {
primary: colors.violet,
secondary: colors.gray,
info: colors.blue,
warn: colors.yellow,
success: colors.green,
danger: colors.red,
dark: colors.neutral,
light: colors.white,
text: colors.gray,
}
},
},
plugins: [
require("@tailwindcss/forms")({
strategy: 'class',
}),
],
}
Step 2. Import styles files:
style.css
contains basic set of classes used by components. Import it directly from library distribution directory
// main.js
import "vue-litewind/vue-litewind.css"
The rest of the styles are set up in js
files as tailwind classes. You can import them directly or preferably copy from distribution directory (node_modules
) to your application for customization. Imported styles need to be provided to the components with the use of the provide
function. The best place to do it is the root component of the application (for example App.vue
)
<!-- App.vue -->
<script setup>
import { provide } from "vue";
import * as styles from "./styles/components";
provide("mods", styles);
</script>
Read about customizing styles here.
Step 3. Add vue-litewind plugin:
You can register single or all components in application entry file (for example main.js
). Registering single components will make build smaller.
// main.js
import { vueLitewind, components, grid, directives } from "vue-litewind";
let app = createApp(App);
app.use(vueLitewind, {
components,
grid,
directives,
});
Optional : while registering components you can set default values for the props globally in the second argument of the app.use
. If component has name
prop that name will be used instead of default name. The value for prop can also be function that takes base
argument (base
prop of component) and should return default value for the prop. If default props should only apply to selected components you can set defaults for those components by nesting them under their parent components.
Examples of default component props:
// main.js
import { vueLitewind } from "vue-litewind";
import { components} from "vue-litewind";
let app = createApp(App);
app.use(vueLitewind, {
components,
componentProps: {
input: {
inline: true,
singleLineMessage: true,
},
}
});