1.0.2 • Published 2 years ago

@ryanmorr/util.css v1.0.2

Weekly downloads
-
License
Unlicense
Repository
github
Last release
2 years ago

util.css

Version Badge License Build Status

A collection of unopinionated and modular CSS utility classes.

Install

Download util.css directly or install via NPM:

npm install @ryanmorr/util.css

Features

The library is composed of dozens of utility classes written in raw CSS (not a preprocessor such as Sass or Less). Unlike Atomic CSS, util.css does not contain (with a few exceptions) single-purpose units of styles, such as .text-center {text-align: center}. Instead, it focuses on common helpers and fixes that add functionality beyond simple shortcuts. Theses classes are unopinionated and modular declarations, making them applicable to and easily adopted into any project.

The following is a complete list of all the classes available, grouped into categories. Note: For class names, the word "center" refers to horizontal alignment and the word "middle" refers to vertical alignment.

Layout

ClassDescription
clearfixAllows an element to stretch to accommodate floating elements
border-boxMake the box model of an element and its descendants include the padding and border within the defined width and height of an element
content-boxMake the box model of an element and its descendants add the padding and border to the defined width and height of an element
responsive-widthSets a maximum width relative to the parent and auto scales the height
responsive-heightSets a maximum height relative to the parent and auto scales the width (parent element must have a fixed height)
flex-middle-centerShould align children in the middle-center of the element using flexbox
grid-middle-centerShould align children in the middle-center of the element using grid
flex-inline-middle-centerShould align children in the middle-center of the element using inline flexbox
flex-horizontal-stackShould stack children horizontally using flexbox
flex-vertical-stackShould stack children vertically using flexbox

Visibility

ClassDescription
hiddenHide an element visually and from screen readers
invisibleHide an element visually and from screen readers, but maintain layout
transparentHide an element visually, but still allow it to be accessible to screen readers, maintain layout, and allow pointer events
offscreenHide an element visually, but maintain its layout offscreen so that its width and height and still be accurately measured
hidden-accessibleHide an element visually, but still allow it to be accessible to screen readers
hidden-accessible-focusableLike hidden-accessible, but will be visible when it or a child element receives focus
hidden-scrollbarsHide scrollbars on an element, while still allowing it to be scrollable
hidden-touchMake an element hidden on touch devices
hidden-non-touchMake an element hidden on non-touch devices

Alignment

ClassDescription
align-leftFloat an element left
align-rightFloat an element right
align-centerCenter an element horizontally
align-middleCenter an element vertically
align-middle-centerCenter an element horizontally and vertically
align-abs-top-leftAlign an absolutely positioned element to the top-left of its container
align-abs-top-centerAlign an absolutely positioned element to the top-center of its container
align-abs-top-rightAlign an absolutely positioned element to the top-right of its container
align-abs-middle-leftAlign an absolutely positioned element to the middle-left of its container
align-abs-middle-centerAlign an absolutely positioned element to the middle-center of its container
align-abs-middle-rightAlign an absolutely positioned element to the middle-right of its container
align-abs-bottom-leftAlign an absolutely positioned element to the bottom-left of its container
align-abs-bottom-centerAlign an absolutely positioned element to the bottom-center of its container
align-abs-bottom-rightAlign an absolutely positioned element to the bottom-right of its container
align-self-top-leftAlign an element to the top-left within a flexbox or grid container
align-self-top-centerAlign an element to the top-center within a flexbox or grid container
align-self-top-rightAlign an element to the top-right within a flexbox or grid container
align-self-middle-leftAlign an element to the middle-left within a flexbox or grid container
align-self-middle-centerAlign an element to the middle-center within a flexbox or grid container
align-self-middle-rightAlign an element to the middle-right within a flexbox or grid container
align-self-bottom-leftAlign an element to the bottom-left within a flexbox or grid container
align-self-bottom-centerAlign an element to the bottom-center within a flexbox or grid container
align-self-bottom-rightAlign an element to the bottom-right within a flexbox or grid container

Typography

ClassDescription
antialiasedRender text using grayscale antialiasing
subpixel-antialiasedRender text using subpixel antialiasing
text-truncatePrevent text from wrapping and truncate with an ellipsis
text-clipPrevent text from wrapping and truncate with a hard clip
text-breakBreak words when their length exceeds the width of their container

Media

ClassDescription
hide-textImage replacement to provide a caption to an image that is only available to web crawlers and screen readers
image-responsiveMake an image responsive while maintaining aspect ratio
image-containFit the image within the container while preserving its aspect ratio
image-coverFill the container with the image while preserving its aspect ratio

User Experience

ClassDescription
unselectablePrevent text selection
disabledPrevent user interaction of any kind
scroll-horizontalMake an element display only horizontal scrollbars
scroll-verticalMake an element display only vertical scrollbars

License

This project is dedicated to the public domain as described by the Unlicense.

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago