0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Vuetify2.xのカスタムSASS変数を定義してコンポーネント内で使う方法

Last updated at Posted at 2023-03-27

Vuetifyの公式ドキュメントを含めてカスタムSASS変数を定義してコンポーネント内で使う方法、どこにも書いてなかったんだな・・・適当な記事ばっかり

Step 1.

assets/variables.scssにカスタム変数を追加

$my-title-color: #6d7793 !default;

Step 2.

nuxt.config.jsを修正

nuxt.config.js
vuetify: {
    customVariables: ['~/assets/variables.scss'],
    treeShake: true,

Step 3.

コンポーネント内で使う

<style lang="scss" scoped>

.my-title {
  color: $my-title-color;
}

</style>

Step3で使えないよ?

~/assets/variables.scssが読み込まれてない!!って人へ。
package.jsonにあるnode-sassとかsass-loaderとかを消したらうまくいくかも。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?