@lnear/marco - CSS Utilities Library
This is a lightweight CSS utilities library aimed at simplifying and standardizing common CSS patterns. It provides a utility function for generating CSS properties and values dynamically.
Installation
You can install this library via npm:
Usage
The marco
function can be used in a variety of ways. It can be used to generate CSS strings dynamically, or it can be used in template literals to generate inline styles.
will generate the following HTML:
marco
Function
The marco
function is the primary utility provided by this library. It dynamically replaces CSS patterns in strings using regular expressions and predefined patterns.
This will generate the following CSS string:
Custom Patterns
You can also pass custom patterns to the marco
function as follows:
This will generate the following CSS string:
Patterns
The below are the predefined patterns that can be used with the marco
function. It is not an exhaustive list and intutive patterns are implemented as needed.
For example, only “saturate-(0, 50, 100, 150, 200)” are documented here, but any value can be used with the “saturate” pattern. (saturate-x where x is a number will be replaced with “filter: saturate({x / 100});“)
drop-shadow
drop-shadow-sm
drop-shadow-md
drop-shadow-lg
drop-shadow-xl
drop-shadow-2xl
drop-shadow-none
backdrop-hue-rotate-0
backdrop-hue-rotate-15
backdrop-hue-rotate-16
backdrop-hue-rotate-30
backdrop-hue-rotate-60
backdrop-hue-rotate-90
backdrop-hue-rotate-180
hue-rotate-0
hue-rotate-15
hue-rotate-30
hue-rotate-60
hue-rotate-90
hue-rotate-180
grayscale-0
grayscale
invert-0
invert
sepia-0
sepia
backdrop-grayscale-0
backdrop-grayscale
saturate-0
saturate-50
saturate-100
saturate-150
saturate-200
backdrop-blur
backdrop-blur-none
backdrop-blur-sm
backdrop-blur-md
backdrop-blur-lg
backdrop-blur-xl
backdrop-blur-2xl
backdrop-blur-3xl
blur
blur-none
blur-sm
blur-md
blur-lg
blur-xl
blur-2xl
blur-3xl
backdrop-brightness-0
backdrop-brightness-50
backdrop-brightness-75
backdrop-brightness-90
backdrop-brightness-95
backdrop-brightness-100
backdrop-brightness-105
backdrop-brightness-110
backdrop-brightness-125
backdrop-brightness-150
backdrop-brightness-200
brightness-0
brightness-50
brightness-75
brightness-90
brightness-95
brightness-100
brightness-105
brightness-110
brightness-125
brightness-150
brightness-200
contrast-0
contrast-50
contrast-75
contrast-100
contrast-125
contrast-150
contrast-200
backdrop-contrast-0
backdrop-contrast-50
backdrop-contrast-75
backdrop-contrast-100
backdrop-contrast-125
backdrop-contrast-150
backdrop-contrast-200
ease-linear
ease-in
ease-out
ease-in-out
timing-linear
timing-in
timing-out
timing-in-out
transition-colors
transition-opacity
transition-all
transition-shadow
transition-none
float-start
float-end
float-right
float-left
float-none
clear-start
clear-end
clear-right
clear-left
clear-both
clear-none
inline-block
inline-flex
inline-table
block
inline
hidden
table
table-caption
table-cell
table-column
table-column-group
table-footer-group
table-header-group
table-row-group
table-row
flow-root
grid
inline-grid
contents
list-item
bg-inherit
bg-transparent
bg-auto
bg-cover
bg-contain
bg-fixed
bg-local
bg-scroll
bg-center
bg-top
bg-right-top
bg-right
bg-right-bottom
bg-bottom
bg-left-bottom
bg-left
bg-left-top
bg-repeat
bg-no-repeat
bg-repeat-x
bg-repeat-y
bg-round
bg-space
bg-none
pointer-events-none
pointer-events-auto
place-content-center
place-content-start
place-content-end
place-content-between
place-content-around
place-content-evenly
place-content-baseline
place-content-stretch
place-items-center
place-items-start
place-items-end
place-items-baseline
place-items-stretch
inset-auto
start-auto
end-auto
top-auto
right-auto
bottom-auto
left-auto
isolate
isolation-auto
z-auto
order-first
order-last
order-none
col-auto
col-span-full
col-start-auto
col-end-auto
row-auto
row-span-full
row-start-auto
row-end-auto
box-border
box-content
aspect-auto
aspect-square
aspect-video
flex-auto
flex-initial
flex-none
basis-auto
basis-full
table-auto
table-fixed
caption-top
caption-bottom
border-collapse
border-separate
origin-center
origin-top
origin-top-right
origin-right
origin-bottom-right
origin-bottom
origin-bottom-left
origin-left
origin-top-left
perspective-origin-center
perspective-origin-top
perspective-origin-top-right
perspective-origin-right
perspective-origin-bottom-right
perspective-origin-bottom
perspective-origin-bottom-left
perspective-origin-left
perspective-origin-top-left
perspective-none
translate-none
transform-none
transform-flat
transform-3d
transform-content
transform-border
transform-fill
transform-stroke
transform-view
backface-visible
backface-hidden
resize-none
resize-both
resize-x
resize-y
snap-none
snap-align-none
snap-start
snap-end
snap-center
snap-normal
snap-always
list-inside
list-outside
list-none
list-disc
list-decimal
list-image-none
appearance-none
appearance-auto
columns-auto
grid-flow-row
grid-flow-col
grid-flow-dense
grid-flow-row-dense
grid-flow-col-dense
auto-cols-auto
auto-cols-min
auto-cols-max
auto-cols-fr
auto-rows-auto
auto-rows-min
auto-rows-max
auto-rows-fr
grid-cols-none
grid-cols-subgrid
grid-rows-none
grid-rows-subgrid
flex-row
flex-row-reverse
flex-col
flex-col-reverse
flex-wrap
flex-nowrap
flex-wrap-reverse
content-normal
content-center
content-start
content-end
content-between
content-around
content-evenly
content-baseline
content-stretch
items-center
items-start
items-end
items-baseline
items-stretch
justify-normal
justify-center
justify-start
justify-end
justify-between
justify-around
justify-evenly
justify-baseline
justify-stretch
justify-items-normal
justify-items-center
justify-items-start
justify-items-end
justify-items-stretch
place-self-auto
place-self-start
place-self-end
place-self-center
place-self-stretch
self-auto
self-start
self-end
self-center
self-stretch
self-baseline
justify-self-auto
justify-self-start
justify-self-end
justify-self-center
justify-self-stretch
scroll-auto
scroll-smooth
text-ellipsis
text-clip
whitespace-normal
whitespace-nowrap
whitespace-pre
whitespace-pre-line
whitespace-pre-wrap
whitespace-break-spaces
text-wrap
text-nowrap
text-balance
text-pretty
break-words
break-all
break-keep
via-none
bg-clip-text
bg-clip-border
bg-clip-padding
bg-clip-content
bg-origin-border
bg-origin-padding
bg-origin-content
mix-blend-plus-darker
mix-blend-plus-lighter
stroke-none
object-contain
object-cover
object-fill
object-none
object-scale-down
object-bottom
object-center
object-left
object-left-bottom
object-left-top
object-right
object-right-bottom
object-right-top
object-top
text-left
text-center
text-right
text-justify
text-start
text-end
align-baseline
align-top
align-middle
align-bottom
align-text-top
align-text-bottom
align-sub
align-super
uppercase
lowercase
capitalize
normal-case
italic
not-italic
underline
overline
line-through
no-underline
font-stretch-normal
font-stretch-ultra-condensed
font-stretch-extra-condensed
font-stretch-condensed
font-stretch-semi-condensed
font-stretch-semi-expanded
font-stretch-expanded
font-stretch-extra-expanded
font-stretch-ultra-expanded
decoration-solid
decoration-double
decoration-dotted
decoration-dashed
decoration-wavy
decoration-auto
decoration-from-font
animate-none
will-change-auto
will-change-scroll
will-change-contents
will-change-transform
contain-none
contain-content
contain-strict
forced-color-adjust-none
forced-color-adjust-auto
normal-nums
underline-offset-auto
Contributing
Contributions are welcome! Please feel free to open issues or pull requests.
License
This project is licensed under the MIT License - see the LICENSE file for details.