Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8390059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:53:16+00:00 2026-06-09T18:53:16+00:00

How stylus deals with variables scope ? — 1- Are all variables global? $foo

  • 0

How stylus deals with variables scope?

—

1- Are all variables global?

$foo = red // is $foo global?

2- Similarly to the commonJS module, is there any exports/require equivalent?

$foo = @import 'foo'

body { color: $foo }

3- What about variables declared in a CSS block, maybe with mixins:

$foo = green

bar()
  $foo = yellow // is it the same $foo ?
  $baz = blue.  // local or implied global?

ul {

  background: $foo // green or yellow? red?

  $foo = red

  li {

    $foo = pink 

  }

  color: $foo // pink?

  bar() // what about $foo now?

}

—

Would appreciate any clarification or documentation about this…

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T18:53:17+00:00Added an answer on June 9, 2026 at 6:53 pm

    If you slightly reword part #3 of your question:

    $foo = green                                                                
    p('global: $foo is ' $foo)                                                  
    
    bar()                                                                       
      $foo = yellow                                                             
      p('In bar(): $foo is ' $foo)                                              
      $baz = blue                                                               
    
    p('$baz outside of bar() is ' $baz)                                         
    
    ul {                                                                        
    
      background: $foo                                                          
      p('In ul: $foo is ' $foo)                                                 
    
      $foo = red                                                                
      p('In ul: now $foo is ' $foo)                                             
    
      li {                                                                      
    
        $foo = pink                                                             
        p('In ul li: $foo is ' $foo)                                            
    
      }                                                                         
    
      color: $foo // pink?                                                      
      p('Back in ul: now $foo is ' $foo)                                        
    
      bar()                                                                     
      p('what about $foo now? ' $foo)                                           
    }
    

    Then stylus will answer it:

    $ stylus test.styl 
    inspect: 'global: $foo is ' (#008000)
    inspect: '$baz outside of bar() is ' $baz
    inspect: 'In ul: $foo is ' (#008000)
    inspect: 'In ul: now $foo is ' (#f00)
    inspect: 'In ul li: $foo is ' (#ffc0cb)
    inspect: 'Back in ul: now $foo is ' (#f00)
    inspect: 'In bar(): $foo is ' (#ff0)
    inspect: 'what about $foo now? ' (#f00)
      compiled test.css
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I liked using the Stylus for compressing my CSS stylesheets. Are there any modules,
Is there a way to allow a user to draw with their stylus (a
Is there any way in CSS to put a limit on how far something
No, not literally . Rather, do you have any red tape horror stories of
Is there a guide or document that deals specifically with migrating CSS and style
Is there a parser/library for css stylus available for php? If not please suggest
UPDATE: After updating to stylus 0.7.4 and express 2.3.12 I can no longer reproduce
I am adding font styles like (small caps,all caps,no caps and normal)to the curved
There are many ways we can deal with CSS browser compatibility issue. Such as
Hi all, I have the following styles in my CSS: .on_focus { background-color:yellow; }

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.