mirror of
https://github.com/tabler/tabler.git
synced 2026-08-30 22:01:28 +04:00
113 lines
3.1 KiB
Plaintext
113 lines
3.1 KiB
Plaintext
---
|
|
title: Vue
|
|
order: 4
|
|
summary: Set up Tabler in Vue and build a first working page.
|
|
description: Install Tabler in Vue - import the CSS and JS from the @tabler/core package and render a minimal single-file component with a Tabler card.
|
|
icon: brand-vue
|
|
seoDescription: Install `@tabler/core`, import CSS and JS in Vue, and render a minimal page layout with a Tabler card.
|
|
---
|
|
|
|
import TabsPackage from '@components/TabsPackage.astro'
|
|
import CdnImportPackage from '@components/CdnImportPackage.astro'
|
|
import Steps from '@components/Steps.astro'
|
|
|
|
Vue single-file components render standard HTML templates, so Tabler classes work directly in your markup while `@tabler/core` supplies the styling. JavaScript is only needed for interactive components such as dropdowns, modals, and tooltips.
|
|
|
|
This guide uses a standard Vite-based Vue setup. You will install `@tabler/core`, import its CSS and JS in `src/main.js`, and render a first page with a Tabler card.
|
|
|
|
## Setup
|
|
|
|
<Steps>
|
|
|
|
### Install Tabler package
|
|
|
|
Install `@tabler/core` with your preferred package manager:
|
|
|
|
<TabsPackage name="@tabler/core" />
|
|
|
|
You can also use CDN files when you need a quick setup:
|
|
|
|
<CdnImportPackage />
|
|
|
|
### Import styles
|
|
|
|
Import Tabler CSS once in your Vue entry file (`src/main.js`):
|
|
|
|
```js
|
|
import '@tabler/core/dist/css/tabler.min.css'
|
|
```
|
|
|
|
For full theme customization, import SCSS sources instead:
|
|
|
|
```scss
|
|
@import '@tabler/core/scss/tabler';
|
|
```
|
|
|
|
### Import and initialize JavaScript
|
|
|
|
Tabler JavaScript is required for interactive components such as dropdowns, modals, and tooltips. Import it once in `src/main.js`:
|
|
|
|
```js
|
|
import '@tabler/core/dist/js/tabler.min.js'
|
|
```
|
|
|
|
Vue-specific note: initialize DOM-based behavior after mount, not during render. Use `onMounted` in components that need manual initialization:
|
|
|
|
```js
|
|
import { onMounted } from 'vue'
|
|
import { Tooltip } from '@tabler/core'
|
|
|
|
onMounted(() => {
|
|
const elements = document.querySelectorAll('[data-bs-toggle="tooltip"]')
|
|
elements.forEach((element) => new Tooltip(element))
|
|
})
|
|
```
|
|
|
|
### Minimal working example
|
|
|
|
Create a simple `src/main.js` that loads Tabler assets and mounts the app:
|
|
|
|
```js
|
|
import { createApp } from 'vue'
|
|
import App from './App.vue'
|
|
import '@tabler/core/dist/css/tabler.min.css'
|
|
import '@tabler/core/dist/js/tabler.min.js'
|
|
|
|
createApp(App).mount('#app')
|
|
```
|
|
|
|
Then create `src/App.vue` with a minimal Tabler layout and one card:
|
|
|
|
```vue
|
|
<template>
|
|
<div class="page">
|
|
<div class="page-wrapper">
|
|
<div class="container-xl py-4">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<h3 class="card-title">Vue + Tabler</h3>
|
|
<p class="text-secondary mb-0">Your Tabler setup is working.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
```
|
|
|
|
Run the app:
|
|
|
|
```shell
|
|
npm run dev
|
|
```
|
|
|
|
Open the local Vite URL and confirm the card is styled with Tabler.
|
|
|
|
### Next steps
|
|
|
|
- Continue with [Customize](/ui/getting-started/customize) to adjust styles and build setup.
|
|
- Explore [Layout](/ui/layout) to choose page structures.
|
|
- Browse [Components](/ui/components) to add UI building blocks.
|
|
|
|
</Steps>
|