Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS frameworks in Vue.js

I would like to integrate Bulma into my Vue.js project.

I have previously included included the CDN script tag into my <head>.

However after that, I followed these official instructions for including Sass pre-processor, as Bulma requires it in a Node project.

npm install sass-loader node-sass --save-dev 

<style lang="sass">   
/*write sass here */ 
</style>

Now, the script tag in <head> is being commented out, and I can't figure out how to load Bulma properly into my application.

I have imported Bulma in my root component style tags as suggested by @BillCriswell below, as follows:

<style lang="scss" src="bulma"></style>

<style lang="scss">
  body {
    text-align:center;
    background-color:blue;
  }
</style>

And the stylesheet is properly loaded, however if I add another style tag as further suggested, the styles don't load.

How do I load Bulma into my Vue.js project, and what is the recommended approach for integrating a CSS framework into Vue.js?

like image 956
softcode Avatar asked Jan 31 '17 20:01

softcode


People also ask

Does Vue.js use CSS?

With Vue directives, you can manage class and style binding within the template. You can also use inline styling within components, or use an external CSS file to keep our application organized. In this article, we will explore different ways of styling Vue components with CSS by building a simple web page.

How do I use style CSS in Vue?

Adding CSS classes in Vue We should apply the button CSS classes to the <button> in our ToDoForm component. Since Vue templates are valid HTML, this is done in the same way to how you might do it in plain HTML — by adding a class="" attribute to the element.

Does Vue use HTML and CSS?

Vue (pronounced /vjuː/, like view) is a JavaScript framework for building user interfaces. It builds on top of standard HTML, CSS and JavaScript, and provides a declarative and component-based programming model that helps you efficiently develop user interfaces, be it simple or complex.


1 Answers

You should be able to do this since bulba's main entry in package.json points to bulma.sass.

<style lang="sass" src="bulma"></style>
<style>
  /* Your css for this file... */
</style>

or you can do

<style lang="sass">
  @import "bulma"
  /* Your css for this file... */
</style>

There's no need to do import bulma from 'bulma' in your <script>.

If you can't just use the style tag it would depend on your webpack config. If you're using the vue-cli webpack template I believe you should be good.

like image 161
Bill Criswell Avatar answered Oct 04 '22 01:10

Bill Criswell