Nuxt Uikit 3
Nuxt compatibility: ^3.0.0
UIkit 3 version 3.16.15
nuxt-uikit3 Nuxt module.
Features
- Injects UIkit 3 into Nuxt ✅
- Load UIkit 3 default css or disable it and load your own ✅
- Use all UIKit 3 JS components without writing any JS ✅
On version 1.0.0
release todos
- Enable/Disable Uikit 3 default icons
- Import only specific JS components []
- Enable/Disable Uikit 3 default icons []
- Tests jest?? or vitest??
- Docs []
- Examples []
- Contribution guid []
- Licence []
- PR template []
- Nuxt 2 support?? maybe!!
Quick Setup
Add @samk_dev/nuxt-uikit3
dependency to your project
pnpm add -D @samk_dev/nuxt-uikit3 uikit
pnpm add -D @samk_dev/nuxt-uikit3 uikit @types/uikit
yarn add --dev @samk_dev/nuxt-uikit3 uikit
yarn add --dev @samk_dev/nuxt-uikit3 uikit @types/uikit
npm install --save-dev @samk_dev/nuxt-uikit3 uikit
npm install --save-dev @samk_dev/nuxt-uikit3 uikit @types/uikit
Add @samk_dev/nuxt-uikit3
to the modules
section of nuxt.config.ts
export default defineNuxtConfig({
modules: ['@samk_dev/nuxt-uikit3']
});
That's it! You can now use Nuxt Uikit 3 in your Nuxt app ✨
Module Options
By default Nuxt UIkit 3 Module loads UIkit 3 core css && core theme css, but you can select what css components to import or disable this behaviour && load your own custom css.
Default UIkit 3 core css && default theme css
export default defineNuxtConfig({
modules: ['@samk_dev/nuxt-uikit3'],
uikit3: {
css: {
coreCss: boolean,
coreTheme: boolean
}
}
});
CSS
You can use any css class from UIkit 3 as you would normally do.
CSS Example
<section class="uk-section uk-section-default">
<div class="uk-container">
<h1 class="uk-heading-medium">Are You Nuxt!</h1>
<button type="button" class="uk-button uk-button-primary">Click me!</button>
</div>
</section>
Javascript
You can use UIkit 3 JS components by adding the data-uk-<component-name>
|| by calling $uikit
inside <script></script>
tag
To work with javascript components from UIkit 3, you have to add data-uk-<component-name>
Please refer to UIkit 3 documentation as they mentioned there
From UIkit 3 Docs
UIkit and reactive JavaScript frameworks. UIkit is listening for DOM manipulations and will automatically initialize, connect and disconnect components as they are inserted or removed from the DOM. That way it can easily be used with JavaScript frameworks like Vue.js and React. You can use UIkit components by adding uk-* or data-uk-* attributes to your HTML elements without writing a single line of JavaScript. This is UIkit's best practice of using its components and should always be considered first.
<div uk-sticky="offset: 50;"></div>
<div data-uk-sticky="offset: 50;"></div>
Usage Example
Acordion Component
Using the data-uk-<component-name>
method:
<template>
<ul data-uk-accordion>
<li class="uk-open">
<a class="uk-accordion-title" href="#">Item 1</a>
<div class="uk-accordion-content">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
</div>
</li>
<li>
<a class="uk-accordion-title" href="#">Item 2</a>
<div class="uk-accordion-content">
<p>
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
reprehenderit.
</p>
</div>
</li>
<li>
<a class="uk-accordion-title" href="#">Item 3</a>
<div class="uk-accordion-content">
<p>
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum
dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
proident.
</p>
</div>
</li>
</ul>
</template>
Inside <script></script>
tag
<script setup lang="ts">
const { $uikit } = useNuxtApp();
function showModal() {
$uikit.modal.confirm('UIkit confirm!').then(
function () {
console.log('Confirmed.');
},
function () {
console.log('Rejected.');
}
);
}
</script>
<template>
<div>
<button @click="showModal">show alert</button>
</div>
</template>
Development
npm install
npm run dev:prepare
npm run dev
npm run dev:build
npm run lint
npm run test
npm run test:watch
npm run release