Logo

dev-resources.site

for different kinds of informations.

Using Quasar with Vue3 & Storybook

Published at
4/7/2022
Categories
quasar
vue
storybook
beginners
Author
allanjeremy
Categories
4 categories in total
quasar
open
vue
open
storybook
open
beginners
open
Author
11 person written this
allanjeremy
open
Using Quasar with Vue3 & Storybook

This is a draft article and may be polished later

Create a new quasar project. Install the quasar cli if you haven't already. Using the Vite option for this example.

Select Vue 3 and Vite instead of Webpack to follow along with this example.

$ yarn global add @quasar/cli
$ yarn create quasar

# or:

$ npm i -g @quasar/cli
$ npm init quasar
Enter fullscreen mode Exit fullscreen mode

Initialize storybook

  • cd into the directory of your created project

Run npx sb init to initialize storybook in your project.

Update package.json

Replace whatever version of autoprefixer you have in your package.json in order for Storybook to work. The version of PostCSS being used by Storybook will not work with later versions of autoprefixer. More details on why that is can be found here.

Use this:

 "autoprefixer": "^9.0.0",
Enter fullscreen mode Exit fullscreen mode

Update your Storybook settings

In order for storybook to load and display quasar components correctly, we need to update our .storybook/preview.js file with the following:

import '@quasar/extras/roboto-font/roboto-font.css';
// These are optional
import '@quasar/extras/material-icons/material-icons.css';
import '@quasar/extras/animate/fadeInUp.css';
import '@quasar/extras/animate/fadeOutDown.css';
import '@quasar/extras/animate/fadeInRight.css';
import '@quasar/extras/animate/fadeOutRight.css';

// Loads the quasar styles and registers quasar functionality with storybook
import 'quasar/dist/quasar.css';
import { app } from '@storybook/vue3';
import { Quasar } from 'quasar';

// This is also where you would setup things such as pinia for storybook

app.use(Quasar, {});

export const parameters = {
  actions: { argTypesRegex: '^on[A-Z].*' },
  controls: {
    matchers: {
      color: /(background|color)$/i,
      date: /Date$/,
    },
  },
};

Enter fullscreen mode Exit fullscreen mode

Run storybook

Use yarn storybook to run storybook. It should open your browser at localhost:6006/ by default.

Test Quasar Components

Replace the code in your src/stories/Button.vue with

<template>
  <q-btn color="primary">Something</q-btn>
</template>
Enter fullscreen mode Exit fullscreen mode

You should now see your quasar button in storybook.

Quasar button in storybook screenshot

Conclusion

That's it! You can now begin to use storybook with Vue3 + Vite + Quasar

quasar Article's
30 articles in total
Favicon
HMR refreshes browser with every change
Favicon
How to create a pronunciation assessment App (Part 2)
Favicon
QRow and QCol not available
Favicon
All Online Tools in β€œOne Box”
Favicon
Quasar Q-Table Row Spanning
Favicon
Quasar Prime Admin Template (Quasar 2/Vue 3 - Typescript & Javascript both versions)
Favicon
Quasar checkbox issue
Favicon
Mithril JS + Quasar CSS + mithril stream + UI (pages) -> real app
Favicon
Getting started with Supabase and Quasar v2
Favicon
Quasar Minimalist Design
Favicon
Quasar: Send email with custom data from web app without backend
Favicon
Quasar 2 with Nuxt3 (Starter Template)
Favicon
Need help building podcast app
Favicon
Open source templates using Quasar framework/Vue.js
Favicon
How to Build a Quasar QR Code Scanner with Capacitor
Favicon
KeywordFinder
Favicon
Mithril JS + Quasar CSS? Here is the proof.
Favicon
Part 6: Styling the chat widget
Favicon
Part 2:Unified SVG icons with Vite, Vue 3, Quasar and Pinia
Favicon
Using Quasar with Vue3 & Storybook
Favicon
Part 1:Unified SVG icons with Vite, Vue 3, Quasar and Pinia
Favicon
Vue 3 + Vite + TypeScript + Quasar issue
Favicon
Vue3 + Quasar 2.1 + TypeScript Sample CRUD Application Project
Favicon
Quasar's QTable: The ULTIMATE Component (5/6) - Styling EVERYTHING!!!
Favicon
Quasar's QTable: The ULTIMATE Component (4/6) - ALL The Slots!
Favicon
Quasar's QTable: The ULTIMATE Component (3/6) - Loading State, Pagination, and Sorting
Favicon
Quasar's QTable: The ULTIMATE Component (2/6) - Expandable Rows and Selectable Rows
Favicon
Quasar's QTable: The ULTIMATE Component (1/6) - Setup, Data and Columns!
Favicon
How to apply auto routes like Nuxt.js on Quasar v2
Favicon
Episode 1 Of "The Quasar Show" goes live on Thursday

Featured ones: