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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:13:38+00:00 2026-06-13T14:13:38+00:00

I want to add a conditional !important string to a definition without having to

  • 0

I want to add a conditional !important string to a definition without having to duplicate the lines… The closest I’ve come so far is this:

fontSize(size, isImportant = false)
  importantString=""
  if isImportant
    importantString = !important

  font-size unit(size, 'px') importantString
  font-size unit(size / 10, 'rem') importantString

which doesn’t work because importantString="" actually inserts "", and removing the assignment actually prints importantString if it isn’t defined.

The best way would be something like:

font-size unit(size, 'px') if isImportant !important

But I guess that’s not possible.

  • 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-13T14:13:39+00:00Added an answer on June 13, 2026 at 2:13 pm

    Answering your question — you can just use unquote() around the quotes for importantString, so it would output to nothing if there is no important.

    That would look like this:

    fontSize(size, isImportant = false)
      importantString = isImportant ? !important : unquote("")
    
      font-size unit(size, 'px') importantString
      font-size unit(size / 10, 'rem') importantString
    

    However! if you’d ask me, I’d recommend to make something different — make a transparent mixin for font-size like this:

    font-size(size, args...)
      $rem_ratio = 10 if not $rem_ratio is defined
      if unit(size) == 'rem'
        font-size unit(size * $rem_ratio, 'px') args
        font-size size args
      else if unit(size) == ''
        font-size unit(size, 'px') args
        font-size unit(size / $rem_ratio, 'rem') args
      else
        font-size arguments
    

    That mixin could be used transparently as you could use the generic font-size. Even more, there are two ways to use it:

    .foo
      font-size 1rem
    
    .bar
      font-size 10
    

    You can use rem unit there, that would be translated to pixels in a fallback, or use unitless number, that would be translated as you wanted it to be in your question. And the importance would be preserved and you’d even have a way to declare how much pixels are there in one rem using $rem_ratio variable.

    Enjoy!

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

Sidebar

Related Questions

I want add new Feed item on entity persist and update. I write this
I want add my custom sidebar next right column all page. Please check this
I have a list of string values that I want add to a hashtable
Suppose I want to add a runtime conditional to a Makefile generated by Automake.
I want to conditionally add an attribute using jQuery: var $this = this .append(...)
I want to add conditional logic functionality to cforms plugin. The existing contact form
I want to add conditional formatting on a range depending on some condition. I
i want to add a conditional statement to my layout that tests: the controller
I've got a query below. I want to add a condition that if the
Hi I want to add image in table cell according to condition in table.

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.