Skip to content

How to use css variable on typescript (using :export) #17858

Discussion options

You must be logged in to vote

I use it like this. Maybe you can try it.

Maybe it's because my file name is module. scss.

~/assets/styles/variables.module.scss

$header-top-height: 24px;
$header-height: 80px;
$footer-height: 90px;
$default-bg-color: #ffffff;
$default-color: #3366ff;

:export {
  headerTopHeight: $header-top-height;
  headerHeight: $header-height;
  footerHeight: $footer-height;
  defaultColor: $default-color;
  defaultBgColor: $default-bg-color;
}

~/layouts/default.vue

import variables from '~/assets/styles/variables.module.scss'
console.log(variables)
{
  headerTopHeight: '24px',
  headerHeight: '80px',
  footerHeight: '90px',
  defaultColor: '#3366ff',
  defaultBgColor: '#ffffff'
}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ShuntaNakajima
Comment options

@mhornbacher
Comment options

Answer selected by ShuntaNakajima
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 participants