CSS Utilities
Use CSS utility classes to customize and extend Spark components.
Table of Contents
Single-Property Utilities
These utilities change only one CSS property. Use one or more to override an element's default style.
All Single-Property Utilities override default styles with
!important
property.
Display and Visibility
These utilities change how elements render on the page, and can also affect screen reader output.
Class | Description |
---|---|
.sprk-u-JavaScript, .sprk-u-HideWhenJs | Turns off the display of an element so that it has no effect on layout. |
.sprk-u-Display--none | Turns off the display of an element so that it has no effect on layout. |
.sprk-u-Display--block | The element generates a block element box. |
.sprk-u-Display--inline | The element generates one or more inline element boxes. |
.sprk-u-Display--inline-block | The element generates a block element box that will be flowed with surrounding content as if it were a single inline box. |
.sprk-u-Visibility--hidden | The element box is invisible, but still affects layout as normal. Screen readers will still announce this element. |
.sprk-u-Visibility--visible | The element is visible. |
Floats, Position, and Alignment
These utilities change an element's position context as well as document flow.
Class | Description |
---|---|
.sprk-u-Float--none | The element is not floated. |
.sprk-u-Float--left | Floats an element to the left. |
.sprk-u-Float--right | Floats an element to the right. |
.sprk-u-Position--relative | The element is positioned according to the normal flow of the document, and then offset relative to itself. |
.sprk-u-Position--absolute | The element is removed from the normal document flow, and no space is created for the element in the page layout. It is positioned relative to its closest positioned ancestor. |
.sprk-u-Position--fixed | The element is removed from the normal document flow, and no space is created for the element in the page layout. It is positioned relative to the initial containing block established by the viewport. |
.sprk-u-Position--static | The element is positioned according to the normal flow of the document. |
.sprk-u-Top--zero | Resets an element's top offset back to zero. |
.sprk-u-Bottom--zero | Resets an element's bottom offset back to zero. |
.sprk-u-Left--zero | Resets an element's left offset back to zero. |
.sprk-u-Right--zero | Resets an element's right offset back to zero. |
.sprk-u-TextAlign--left | Aligns text to the left of the container. |
.sprk-u-TextAlign--right | Aligns text to the right of the container. |
.sprk-u-TextAlign--center | Aligns text in the horizontal center of the container. |
.sprk-u-VerticalAlign--top | Aligns the contents of a box to the top if it's display property is `inline` or `table-cell`. |
.sprk-u-VerticalAlign--middle | Aligns the contents of a box to the vertical middle if it's display property is `inline` or `table-cell`. |
.sprk-u-VerticalAlign--bottom | Aligns the contents of a box to the bottom if it's display property is `inline` or `table-cell`. |
.sprk-u-VerticalAlign--baseline | Aligns the contents of a box to the baseline if it's display property is `inline` or `table-cell`. |
Typography
These utilities change text style and flow.
Class | Description |
---|---|
.sprk-u-FontWeight--bold | Sets the font weight to bold. |
.sprk-u-FontWeight--normal | Sets the font weight to normal. |
.sprk-u-FontStyle--italic | Sets the font style to italic. |
.sprk-u-FontStyle--normal | Sets the font style to normal. |
.sprk-u-TextDecoration--underline | Sets the text decoration to underline. |
.sprk-u-TextDecoration--none | Sets the text decoration to none. |
.sprk-u-TextTransform--uppercase | Transforms text to uppercase. |
.sprk-u-TextTransform--none | Removes text transformation for text. |
.sprk-u-WordWrap--break-word | Sets `word-wrap` to `break-word`. |
.sprk-u-WhiteSpace--nowrap | Sets `white-space` to `nowrap`. |
.sprk-u-Measure | Sets a `max-width`, intended for text. Default value is `40 rem`. |
.sprk-u-Measure--narrow | Sets a narrow `max-width`, intended for text. Default value is `25 rem`. |
Overflow
These utilities control how content renders when an element is too large for its container.
Class | Description |
---|---|
.sprk-u-Overflow--visible | Content is not clipped and may be rendered outside the padding box. |
.sprk-u-Overflow--hidden | Content is clipped if necessary to fit the padding box. No scrollbars are provided. |
.sprk-u-Overflow--scroll | Content is clipped if necessary to fit the padding box. Browsers display scrollbars whether or not any content is actually clipped. |
.sprk-u-Overflow--auto | If content fits inside the padding box, it looks the same as visible, but still establishes a new block-formatting context. |
Width
These utilities affect the width of an element.
In increments of 5, the number at the end of each utility class can be between 5 and 100.
This table shows examples of a few possible widths.
Class | Description |
---|---|
.sprk-u-MaxWidth--100 | Changes the max-width of the element to 100 percent. |
.sprk-u-Width--auto | Changes the width of the element to `auto`. |
.sprk-u-Width-5 | Changes the width of the element to 5 percent. |
.sprk-u-Width-25 | Changes the width of the element to 25 percent. |
.sprk-u-Width-50 | Changes the width of the element to 50 percent. |
Spacing
These utilities override the padding and margin on an element. The class name
format is .sprk-u-<type><location><size>
Options
- type:
p
orm
(padding or margin) - location: which side(s) of the element to apply the class to.
a
(all)t
(top)r
(right)b
(bottom)l
(left)h
(horizontal)v
(vertical)
- size: The size of the spacing added.
s
- small (8px)m
- medium (16px)l
- large (32px)h
- huge (64px)n
- none (0px)
Examples
Class | Description |
---|---|
.sprk-u-mah | Sets the margin on all sides to `64px` |
.sprk-u-phm | Sets the left and right padding to `16px` |
.sprk-u-mbn | Sets the bottom margin to `0px` |
Miscellaneous Spacing
These utilities override the padding and margin on an element and are
supplemental spacing sizes. The class name format is .sprk-u-<Type><Location>--<size>
Options
- type:
Padding
orMargin
- location:
All
,Top
,Right
,Bottom
,Left
,Horizontal
, orVertical
- size:
a
=$sprk-space-misc-a
(24px)b
=$sprk-space-misc-b
(40px)c
=$sprk-space-misc-c
(48px)d
=$sprk-space-misc-d
(80px)
Examples
Class | Description |
---|---|
sprk-u-PaddingHorizontal--b | Sets the padding on the left and right (horizontal) to `$sprk-space-misc-b` (`40px`). |
sprk-u-MarginAll--d | Sets the margin on all sides to the current value of `$sprk-space-misc-d` (`80px`). |
sprk-u-MarginBottom--a | Sets the bottom margin to the current value of `$sprk-space-misc-a` (`24px`). |
Color
These utilities change color and background color.
Class | Description |
---|---|
.sprk-u-Color--red | Sets the font color to red. |
.sprk-u-Color--deep-red | Sets the font color to deep red. |
.sprk-u-Color--mid-red | Sets the font color to mid red. |
.sprk-u-Color--purple | Sets the font color to purple. |
.sprk-u-Color--purple-dark | Sets the font color to purple dark. |
.sprk-u-Color--purple-deep | Sets the font color to purple deep. |
.sprk-u-Color--purple-light | Sets the font color to purple light. |
.sprk-u-Color--purple-lightest | Sets the font color to purple lightest. |
.sprk-u-Color--green | Sets the font color to green. |
.sprk-u-Color--blue | Sets the font color to blue. |
.sprk-u-Color--orange | Sets the font color to orange. |
.sprk-u-Color--pink | Sets the font color to pink. |
.sprk-u-Color--yellow | Sets the font color to yellow. |
.sprk-u-Color--white | Sets the font color to white. |
.sprk-u-Color--gray | Sets the font color to gray. |
.sprk-u-Color--black | Sets the font color to black. |
.sprk-u-Color--purple-navy | Sets the font color to Purple Navy. |
.sprk-u-Color--lavender | Sets the font color to Lavender. |
.sprk-u-Color--wisteria | Sets the font color to Wisteria. |
.sprk-u-Color--magnolia | Sets the font color to Magnolia. |
.sprk-u-BackgroundColor--red | Sets the background color to red. |
.sprk-u-BackgroundColor--deep-red | Sets the background color to deep red. |
.sprk-u-BackgroundColor--mid-red | Sets the background color to mid red. |
.sprk-u-BackgroundColor--purple | Sets the background color to purple. |
.sprk-u-BackgroundColor--purple-dark | Sets the background color to purple dark. |
.sprk-u-BackgroundColor--purple-deep | Sets the background color to purple deep. |
.sprk-u-BackgroundColor--purple-light | Sets the background color to purple light. |
.sprk-u-BackgroundColor--purple-lightest | Sets the background color to purple lightest. |
.sprk-u-BackgroundColor--green | Sets the background color to green. |
.sprk-u-BackgroundColor--blue | Sets the background color to blue. |
.sprk-u-BackgroundColor--orange | Sets the background color to orange. |
.sprk-u-BackgroundColor--pink | Sets the background color to pink. |
.sprk-u-BackgroundColor--yellow | Sets the background color to yellow. |
.sprk-u-BackgroundColor--white | Sets the background color to white. |
.sprk-u-BackgroundColor--black | Sets the background color to black. |
.sprk-u-BackgroundColor--black-tint-90 | Sets the background color to black tinted at 90%. |
.sprk-u-BackgroundColor--black-tint-80 | Sets the background color to black tinted at 80%. |
.sprk-u-BackgroundColor--black-tint-70 | Sets the background color to black tinted at 70%. |
.sprk-u-BackgroundColor--black-tint-60 | Sets the background color to black tinted at 60%. |
.sprk-u-BackgroundColor--black-tint-50 | Sets the background color to black tinted at 50%. |
.sprk-u-BackgroundColor--black-tint-40 | Sets the background color to black tinted at 40%. |
.sprk-u-BackgroundColor--black-tint-30 | Sets the background color to black tinted at 30%. |
.sprk-u-BackgroundColor--black-tint-20 | Sets the background color to black tinted at 20%. |
.sprk-u-BackgroundColor--black-tint-10 | Sets the background color to black tinted at 10%. |
.sprk-u-BackgroundColor--gray | Sets the background color to gray. |
.sprk-u-BackgroundColor--purple-navy | Sets the background color to Purple Navy. |
.sprk-u-BackgroundColor--lavender | Sets the background color to Lavender. |
.sprk-u-BackgroundColor--wisteria | Sets the background color to Wisteria. |
.sprk-u-BackgroundColor--magnolia | Sets the background color to Magnolia. |
Height
This utility sets the height of an element to a percentage value.
Class | Description |
---|---|
.sprk-u-Height--100 | Changes the height of the element to 100 percent. |
Multi-Property Utilities
Multi-Property Utilities combine several CSS properties and values to perform common actions. These aid in accessibility and layout, and are not meant to override default styles.
Accessibility
These utilities extend element behavior for better accessibility performance.
Class | Description |
---|---|
.sprk-u-ScreenReaderText | Makes content invisible while still being read by a screen reader. |
.sprk-u-ShowOnFocus:focus | When combined with `.sprk-u-ScreenReaderText` the element will become visible on focus. |
Layout
These utilities affect layout, and positioning.
Class | Description |
---|---|
ClearFix | Clearfix is a method of float containment. When applied to a container with floated children it forces the container to span the entire vertical extent of the children as if they weren't pulled out of the document flow by the floats. Elements that come after the Clearfixed element will no longer wrap around the floated children. The primary way to use `Clearfix` in Spark is by extending the placeholder in your Sass (e.g. `@extend %ClearFix;`). It can also be used by applying the class directly to the parent element, typically only used for debugging. |
.sprk-u-AbsoluteCenter | When placed on a container, its children will align in the absolute center (vertically and horizontally) of the box. |
.sprk-u-FullWidth | When placed on a container, it will cause it to fill the viewport, even if it's inside a limiting container (such as `sprk-o-CenteredColumn`). |
Text
These utilities are related to text and flow.
Class | Description |
---|---|
.sprk-u-TextCrop--none | When placed on an element that contains text or any of the typography classes, it will remove the text cropping and the negative margins applied by the crop. |
.sprk-u-Truncate | When placed on an element that contains text, it will limit the text to one line and adds an ellipsis when it overflows. |