what should be made into a variable?
Hey, what properties should be stored in variables? I'm aware of things such as colours, things regarding fonts (family, sizes, weights etc) , spacing, and i occasionally store border radius, leading and kerning values if i have a few different sizes with hierarchical naming conventions e.g. x-sm, x-md etc. Is there anything that shouldn't be a variable? Perhaps a rule of thumb or something? Thanks in advance.
17 Replies
in general, things that are used in multiple places and would need to be updated in multiple places if you have to change it
ah makes sense, thank you. Is there anything that isn't necessary in any case to be a variable?
just the inverse of the other thing, really
stuff that's in one spot and doesn't need changing
also to add to this, things that may not ever need to change but is used in a lot of places. Things like brand colors for example
ah okay good stuff, really understand that now, thanks.
In addition to values that are used in multiple places, variables are also useful when you want to use the same code with different values in multiple places. In some cases, it's simpler to replace the value and use the same code.
ah so things like this?
rather than this?
Yes.
alright cool, appreciate the insight.
there's other things you can do
oh nice, what might those be if you don't mind sharing?
for example, if you want to change font sizes dynamically, for different resolutions, you can use variables
that's like this right?
you can use that too
ah yeah i've seen that method before
or do like this, as the font size is always the same (which may or may not be what you need)
you can use this for spacings as well
for example, if you have a gap of 16px but you want 8px for phones, you can use the same structure
ah got it, thank you
paddings work as well
margins
things like that
you're welcome