Pseudo-Class Variants
Using utilities to add CSS pseudo-class to style an element:
- responsive
- dark-mode, light-mode
- reduce-motion
- selection-hover
- expand
- first-of-type, last-of-type
- first-letter,
- portrait, landscape
- hover, group-hover
- focus, group-focus, focus-visible, focus-within
- active
- visited
- checked
- disabled
Responsive
Add the one of these prefixes (xs)
, (sm)
, (md)
, (lg)
, (1k)
, (2k)
, (4k)
, (8k)
to a utility to enable responsive response to different screen sizes.
<!-- Example -->
<div class="(xs)text-lg (2k)text-xl-4">
...
</div>
.example {
@extend
.\(xs\)text-lg,
.\(2k\)text-xl-4;
}
Hover
Add the (hover)
prefix to a utility to enable on-hover.
<!-- Example -->
<div class="text-shade-granite-1 (hover)text-white bg-white (hover)bg-tint-granite-5">
...
</div>
.example {
@extend
.text-shade-granite-1,
.\(hover\)text-white,
.bg-white,
.\(hover\)bg-tint-granite-5;
}
Focus
Add the (focus)
prefix to a utility to enable on-focus.
<!-- Example -->
<input class="bg-tint-granite-2 (focus)bg-tint-granite-5 border-transparent (focus)border-tint-granite-5" placeholder="Focus me!">
.example {
@extend
.bg-tint-granite-2,
.\(focus\)bg-tint-granite-5,
.border-transparent,
.\(focus\)border-tint-granite-5;
}
Focus-Within
Add the (focus-within)
prefix to a utility to enable on-focused for child element.
<!-- Example -->
<div class="(focus-within)text-shade-lava-1 (focus-within)bg-tint-lava-5">
Title: <input placeholder="Focus me!">
</div>
.example {
@extend
.\(focus-within\)text-shade-lava-1,
.\(focus-within\)bg-tint-lava-5;
}
Focus-Visible
Add the (focus-visible)
prefix to a utility to enable on-focused for child element.
<!-- Example -->
<div class="bg-tint-granite-5 (focus-visible)bg-tint-granite-2">
...
</div>
.example {
@extend
.bg-tint-granite-5,
.\(focus-visible\)bg-tint-granite-2;
}
Active
Add the (active)
prefix to a utility to enable on-active.
<!-- Example -->
<button class="bg-tint-granite-5 (active)bg-tint-granite-2 text-white">
...
</button>
.example {
@extend
.bg-tint-granite-5,
.\(active\)bg-tint-granite-2,
.text-white;
}
Visited
Add the (visited)
prefix to a utility to enable on-visited.
<!-- Example -->
<a class="text-shade-granite-1 (visited)text-shade-lava-1 (visited)text-underline"
href="...">
...
</a>
.example {
@extend
.text-shade-granite-1,
.\(visited\)text-shade-lava-1,
.\(visited\)text-underline;
}
Checked
Add the (checked)
prefix to a utility to enable on-checked.
<!-- Example -->
<button class="(checked)text-white (checked)bg-tint-granite-5 (checked)text-underline">
...
</button>
.example {
@extend
.\(checked\)text-white,
.\(checked\)bg-tint-granite-5,
.\(checked\)text-underline;
}
Disabled
Add the (disabled)
prefix to a utility to enable on-disabled.
<!-- Example -->
<button class="(disabled)text-shade-granite-1 (disabled)bg-tint-granite-5">
...
</button>
.example {
@extend
.\(disabled\)text-shade-granite-1,
.\(disabled\)bg-tint-granite-5;
}
Group
Group-Hover
Add (group)
class to the parent element and add the (group-hover)
prefix to a utility on the child element to enable group-hover.
<!-- Example -->
<div class="(group) bg-tint-granite-5 (hover)bg-tint-granite-1">
<div class="(group-hover)text-white">
...
</div>
</div>
.example {
@extend
.\(group\),
.bg-tint-granite-5,
.\(hover\)bg-tint-granite-1;
}
Group-Focus
Add (group)
class to the parent element and add the (group-focus)
prefix to a utility on the child element to enable group-focus.
<!-- Example -->
<div class="(group) bg-tint-granite-5 (focus)bg-tint-granite-1">
<div class="(group-focus)text-white">
...
</div>
</div>
.example {
@extend
.\(group\),
.bg-tint-granite-5.
.\(focus\)bg-tint-granite-1;
}
Selection-Hover
Add (selection-hover)
prefix to filter
utilities with set up parent and child elements. Deselected elements are affected by the filter
configurations.
<!-- Example -->
<!-- parent -->
<div class="(selection-hover)filter saturate-0 blur-10 ... smooth-200">
<!-- child -->
<div>
<div>
...
</div>
</div>
<!-- child -->
<div>
<div>
...
</div>
</div>
</div>
.example {
@extend
.\(selection-hover\)filter,
.saturate-0,
.blur-10,
.smooth-200;
}
Default selected Filters utilities for (selection-hover)
variant.
Expand
Add (expand)
prefix to a utility in a parent element, the utility will take effect to all child elements.
<!-- Example -->
<!-- parent -->
<div class="(expand)margin-2 (expand)padding-4">
<!-- child -->
<div>...</div>
<div>...</div>
...
</div>
.example {
@extend
.\(expand\)margin-2,
.\(expand\)padding-4;
}
Default selected few utilities for (expand)
variant.
- Borders: Border Radius
- Effects: Box Shadow
- Layout: Overflow
- Sizing: Height, Width
- Spacing: Margin, Padding
First-last
Add (first)
or (last)
prefix to a utility in a parent element, the utility will take effect to first child or last child elements.
<!-- Example -->
<!-- parent -->
<div class="(first)text-xl-2 (last)text-xs">
<!-- child -->
<div>...</div>
<div>...</div>
...
</div>
.example {
@extend
.\(first\)text-xl-2,
.\(last\)text-xs;
}
First Letter
Add (first-letter)
prefix to a utility in a parent element, the utility will take effect on the child element containing text and apply the effect to the first letter of the text.
<!-- Example -->
<!-- parent -->
<div class="(first-letter)text-xl-2 (first-letter)text-tint-lava-2 (first-letter)font-semibold">
<!-- child -->
<div>...</div>
<div>...</div>
...
</div>
.example {
@extend
.\(first-letter\)text-xl-2,
.\(first-letter\)text-tint-lava-2,
.\(first-letter\)font-semibold;
}
Theme
Dark Mode
Add the (dark)
prefix to a utility when dark theme settings enabled.
<!-- Example -->
<div class="text-shade-granite-1 (dark)text-tint-granite-5">
...
</div>
.example {
@extend
.text-shade-granite-1,
.\(dark\)text-tint-granite-5;
}
Light Mode
Add the (light)
prefix to a utility when light theme settings enabled.
<!-- Example -->
<div class="text-shade-granite-1 (light)text-shade-granite-5">
...
</div>
.example {
@extend
.text-shade-granite-1,
.\(light\)text-shade-granite-5;
}
Reduce-Motion
Add the (reduce-motion)
prefix to a utility reduce animation motion for readers with vestibular motion disorders.
<!-- Example -->
<div class="(reduce-motion)transition duration-300 ease-in-out border-4 border-tint-granite-5 (hover)border-tint-granite-1 (hover)shadow-lg ... width-32 height-24">
...
</div>
.example {
@extend
.\(reduce-motion\)transition,
.duration-300,
.ease-in-out,
.border-4,
.border-tint-granite-5,
.\(hover\)border-tint-granite-1,
.\(hover\)shadow-lg,
.width-32,
.height-24;
}
Orientation
Portrait
Add the (portrait)
prefix to a utility when portrait settings enabled.
<!-- Example -->
<div class="flex (portrait)flex-column">
...
</div>
.example {
@extend
.flex,
.\(portrait\)flex-column;
}
Landscape
Add the (landscape)
prefix to a utility when landscape settings enabled.
<!-- Example -->
<div class="flex (landscape)flex-column">
...
</div>
.example {
@extend
.flex,
.\(landscape\)flex-column;
}