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 8284435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:06:06+00:00 2026-06-08T11:06:06+00:00

Assuming that I have a website that uses LESS and utilizes variables; I was

  • 0

Assuming that I have a website that uses LESS and utilizes variables; I was wondering if a library or anything exists to provide the end-user the ability to change the variable. For example, if the background color of a class is specified in a variable, I would want to be able to edit it in maybe a dropdown menu. I am going to implement something similar, so prior to doing so, was wondering of any existing solutions.

  • 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-08T11:06:07+00:00Added an answer on June 8, 2026 at 11:06 am

    I’ve come across this problem often lately and after trying many things my solution is to eventually ditch LESS and go with Stylus, which has a nice JavaScript API.

    In any case, this is what I have working right now to get LESS variables in JavaScript:

    var getLessVar = function (name, prop) {
      var value = $('<div class="' + name + '"></div>').hide().appendTo('body').css(prop)
      $('.' + name).remove()
      return /^\d+/.test(value) ? +value : value
    }
    

    It’s hacky but works. You create a class in LESS and assign the variable you want to get in JS to a property, let’s say width, but it can be any other property, depending of the type of data you’re sending (numbers, colors…)

    @myvar: 30px + @foo;
    .myvar { width: @myvar }
    

    Then in JS you grab the variable with that lil’ script like this:

    var myvar = getLessVar('myvar', 'width')
    

    This is not great for performance as it creates an invisible element to retrieve the data but it works.


    To set a variable from JS is more complicated, but you can always do some AJAX magic together with LessPHP and some basic parser to read your variables.less.

    But again, if you need more power just go with Stylus.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assuming that we have: http.HandleFunc(/smth, smthPage) http.HandleFunc(/, homePage) User sees a plain 404 page
I have a website that uses Basic Authentication (username/password). Why is the following code
Assuming that I have this: enum { A = 0x2E, B = 0x23, C
Assuming that I have a CronTriggerBean similar to <bean id=midMonthCronTrigger class=org.springframework.scheduling.quartz.CronTriggerBean> <property name=jobDetail ref=reminderJobDetail
Assuming that I have a typedef declared in my .h file as such: typedef
Assuming that I have such model COLORS= ( ('R', 'Red'), ('B', 'Yellow'), ('G', 'White'),
Is it possible to programmatically create VPN profile on Android (assuming that I have
In Android, assuming that I have files in /data/data/package.name/, without knowing the names or
How can I get the name of an app, assuming that I have the
Is there a cleaner way to do the following, assuming that I have a

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.