reylimjr
reylimjr

Reputation: 381

How do I add Vuetify 3 to Laravel 8 Jetsteam + inertia

Im trying to install vuetify 3 to Laravel 8 with JetStream + inertia. I manage to install the Vuetify plugin successfully, but I am not sure how to include the plugin to the app.js.

Here's my app.js

require('./bootstrap');

import { createApp, h } from 'vue';
import { createInertiaApp } from '@inertiajs/inertia-vue3';
import { InertiaProgress } from '@inertiajs/progress';

import 'vuetify/styles';
import { createVuetify } from 'vuetify';

const appName = window.document.getElementsByTagName('title')[0]?.innerText || 'Laravel';
const vuetify = createVuetify();

createInertiaApp({
    title: (title) => `${title} - ${appName}`,
    resolve: (name) => require(`./Pages/${name}.vue`),
    setup({ el, app, props, plugin }) {
        return createApp({ render: () => h(app, props) })
            .use(plugin)
            .mixin({ methods: { route } })
            .mount(el);
    },
});


InertiaProgress.init({ color: '#4B5563' });

Upvotes: 3

Views: 2898

Answers (2)

Squadz
Squadz

Reputation: 81

You might need to import the components and directives.

Example with Laravel 8, Vue 3 and InertiaJS :

require('./bootstrap');

import { createApp, h } from 'vue';
import { createInertiaApp } from '@inertiajs/inertia-vue3';
import { InertiaProgress } from '@inertiajs/progress';
import { createVuetify } from 'vuetify'
import * as components from 'vuetify/components';
import * as directives from 'vuetify/directives';


const appName = window.document.getElementsByTagName('title')[0]?.innerText || 'Laravel';

createInertiaApp({
    title: (title) => `${title} - ${appName}`,
    resolve: (name) => require(`./Pages/${name}.vue`),
    setup({ el, app, props, plugin }) {
        const vuetify = createVuetify({ components, directives });

        return createApp({ render: () => h(app, props) })
            .use(plugin)
            .use(vuetify)
            .mixin({ methods: { route } })
            .mount(el);
    },
});

InertiaProgress.init({ color: '#4B5563' });

Upvotes: 8

Matheus Dal'Pizzol
Matheus Dal'Pizzol

Reputation: 6105

import { createApp, h } from 'vue'
import { createInertiaApp } from '@inertiajs/inertia-vue3'
import { createVuetify } from 'vuetify'

createInertiaApp({
  resolve: name => require(`./Pages/${name}`),
  setup({ el, App, props, plugin }) {
    const vuetify = createVuetify(...)
    
    createApp({ render: () => h(App, props) })
      .use(plugin)
      .use(vuetify)
      .mount(el)
  },
})

Upvotes: 6

Related Questions