Skip to content

Utils

A collection of helpful utility classes for controlling element behavior, overflow, interactions, and more across different screen sizes.

ClassDescription
.transitionAdds a smooth transition effect to all properties with 0.3s linear timing
<div class="transition">
This element will smoothly transition all property changes
</div>
ClassDescription
.inherit-colorsForces element to inherit both background color and text color from parent
.inherit-backgroundForces element to inherit only background color from parent
.inherit-colorForces element to inherit only text color from parent
<div style="background-color: red; color: white;">
<div class="inherit-colors">
This will have red background and white text
</div>
</div>

Float utilities in Metro UI provide a straightforward way to control the floating behavior of elements, with responsive variants for different screen sizes.

Control the CSS float property of elements:

ClassAliasesDescription
.float-left.place-leftFloats element to the left
.float-right.place-rightFloats element to the right
.float-none.place-none, .no-floatRemoves float (sets float: none)
<div class="float-left">Floated to left</div>
<div class="float-right">Floated to right</div>
<div class="float-none">Not floated</div>

To prevent layout issues with floated elements, use the clearing class:

ClassDescription
.clear-floatClears floats (using clearfix method)
<div>
<div class="float-left">Floated left</div>
<div class="float-right">Floated right</div>
<div class="clear-float"></div>
<!-- Content after floats will start on a new line -->
</div>

All float classes have responsive variants that apply at specific breakpoints and above:

SuffixScreen Width
-xs≥ 0px (Extra small screens)
-sm≥ 576px (Small screens)
-md≥ 768px (Medium screens)
-lg≥ 992px (Large screens)
-xl≥ 1200px (Extra large screens)
-xxl≥ 1452px (Extra extra large screens)

Examples:

  • .float-left-md - Element floats left on medium screens and above
  • .float-right-lg - Element floats right on large screens and above
  • .float-none-xl - Element doesn’t float on extra large screens and above
<!-- Float left on mobile, right on desktop -->
<div class="float-left float-right-lg">
This content floats left on small screens and right on large screens
</div>
<!-- Float only on desktop -->
<div class="float-none float-left-md">
This content doesn't float on mobile but floats left on medium screens and above
</div>
<img src="image.jpg" class="float-left" style="margin-right: 10px;">
<p>Text flows around the image that's floated to the left...</p>
<div class="clear-float"></div>
<div class="dialog-actions">
<button class="button float-right">Submit</button>
<button class="button float-left">Cancel</button>
<div class="clear-float"></div>
</div>
<!-- On mobile: stacked, On desktop: side-by-side -->
<div>
<div class="float-none float-left-md" style="width: 30%;">
Sidebar content
</div>
<div class="float-none float-right-md" style="width: 65%;">
Main content
</div>
<div class="clear-float"></div>
</div>
ClassDescription
.clear, .clear-fix, .clearfixClears floats within an element
ClassDescription
.overflowSets overflow to auto (adds scrollbars when needed)
.no-overflowHides overflow content
.scrollAlways shows scrollbars on both axes
.scroll-xAdds horizontal scrolling when needed
.scroll-yAdds vertical scrolling when needed
.no-scrollHides overflow on both axes
.no-scroll-xHides horizontal overflow
.no-scroll-yHides vertical overflow
<div class="scroll-y" style="height: 200px;">
Content that will scroll vertically when it exceeds the height
</div>
ClassDescription
.wrapForces text to wrap normally
.no-wrapPrevents text from wrapping
ClassDescription
.no-user-selectPrevents text selection
.no-appearanceRemoves default browser styling from form elements
.disabled, .-disabledDisables all pointer events for an element
.stop-pointerPrevents pointer events and text selection
<div class="no-user-select">
This text cannot be selected
</div>
ClassDescription
.collapseCollapses element (sets height to 0)
.expandExpands element to its natural height
ClassDescription
.selectedApplies a selection style with check mark in the corner
<div class="selected" style="position: relative; padding: 20px; border: 1px solid #ccc;">
This element appears selected with a checkmark
</div>

All overflow, scroll, wrapping, collapse, and expand classes have responsive variants:

SuffixScreen Width
-xs≥ 0px (Extra small screens)
-sm≥ 576px (Small screens)
-md≥ 768px (Medium screens)
-lg≥ 992px (Large screens)
-xl≥ 1200px (Extra large screens)
-xxl≥ 1452px (Extra extra large screens)

Examples:

  • .overflow-md - Content overflows with auto scrollbars on medium screens and above
  • .no-wrap-lg - Text doesn’t wrap on large screens and above
  • .collapse-sm - Element collapses on small screens and above
<!-- Element scrolls horizontally on mobile, but not on desktop -->
<div class="scroll-x scroll-x-lg-none">
Wide content that scrolls on mobile
</div>
VariableDescription
--selected-colorColor used for the selected state highlight

You can customize the selection appearance:

:root {
--selected-color: #0078d7;
}