caret-color

Class Description

caret

Sets caret-color (the text cursor color inside inputs) via --caret.

CSS Rules

.caret {
  caret-color: var(--caret);
}

Usage

The .caret class is flagged as a value-driven selector. The variable --caret is required.
<element class="caret" style="--caret: /* value */;" />

Responsive & Dark Mode

Prefix .caret utility with a breakpoint variant (e.g., md:) to apply styles at specific screen sizes (Supported breakpoints are xm through 2xl). If dark mode is applied, the dark: prefix always comes first.

<element class="md:caret" style="--md-caret: /* value */;" />

<element class="dark:sm:caret" style="--dark-sm-caret: /* value */;" />

States

States are generated dynamically at runtime and always come last. Append a state like :hover or :focus to the end of the class. This works in conjunction with breakpoints and dark mode.

Supported pseudo-classes: :hover, :active, :focus, :focus-visible, :focus-within, :target, :checked, :disabled, and :group-hover.

<element class="caret:hover" style="--caret-hover: /* value */;" />

<element class="dark:sm:caret:hover" style="--dark-sm-caret-hover: /* value */;" />

Group Hover Example

The :group-hover state applies styles when a parent element with the .group class is hovered.

<element class="group">
  <element class="caret:group-hover">...</element>
</element>

Pseudo-Elements

The ::before and ::after utility classes are supported too. Granted that you add the mandatory content-before or content-after class in order for them to work.

<element class="content-before caret::before" style="--caret-before: /* value */;" />

<element class="content-after caret::after" style="--caret-after: /* value */;" />

Shorthand

Value-driven classes support a shorthand syntax like bg=pink or p=4. The runtime processes this for you. Unlike :hover that is generating CSS on the fly, shorthand only splits it and appends the corresponding style.

<!-- Input -->
<element class="caret=value" />

<!-- Output -->
<element class="caret" style="--caret: value;" />

CLS Alert

This feature may cause CLS (Cumulative Layout Shift). Make sure to include a z-not-ready class in your <head> tag.

.caret Sets caret-color (the text cursor color inside inputs) via --caret.

caret/o

Sets caret color + opacity independently via --caret and --caret-o. Controls text cursor transparency.

CSS Rules

.caret\/o {
  caret-color: color-mix(in oklab, var(--caret) var(--caret-o, 100%), transparent);
}

Usage

The .caret/o class is flagged as a value-driven selector. The variables --caret and --caret-o are required.
<element
  class="caret/o"
  style="
    --caret: /* value */;
    --caret-o: /* value */;
  "
></element>

Responsive & Dark Mode

Prefix .caret/o utility with a breakpoint variant (e.g., md:) to apply styles at specific screen sizes (Supported breakpoints are xm through 2xl). If dark mode is applied, the dark: prefix always comes first.

<element
  class="md:caret/o"
  style="
    --md-caret: /* value */;
    --md-caret-o: /* value */;
  "
></element>

<element
  class="dark:sm:caret/o"
  style="
    --dark-sm-caret: /* value */;
    --dark-sm-caret-o: /* value */;
  "
></element>

States

States are generated dynamically at runtime and always come last. Append a state like :hover or :focus to the end of the class. This works in conjunction with breakpoints and dark mode.

Supported pseudo-classes: :hover, :active, :focus, :focus-visible, :focus-within, :target, :checked, :disabled, and :group-hover.

<element
  class="caret/o:hover"
  style="
    --caret-hover: /* value */;
    --caret-o-hover: /* value */;
  "
></element>

<element
  class="dark:sm:caret/o:hover"
  style="
    --dark-sm-caret-hover: /* value */;
    --dark-sm-caret-o-hover: /* value */;
  "
></element>

Group Hover Example

The :group-hover state applies styles when a parent element with the .group class is hovered.

<element class="group">
  <element class="caret/o:group-hover">...</element>
</element>

Pseudo-Elements

The ::before and ::after utility classes are supported too. Granted that you add the mandatory content-before or content-after class in order for them to work.

<element
  class="content-before caret/o::before"
  style="
    --caret-before: /* value */;
    --caret-o-before: /* value */;
  "
></element>

<element
  class="content-after caret/o::after"
  style="
    --caret-after: /* value */;
    --caret-o-after: /* value */;
  "
></element>

Shorthand

Value-driven classes support a shorthand syntax like bg=pink or p=4. The runtime processes this for you. Unlike :hover that is generating CSS on the fly, shorthand only splits it and appends the corresponding style.

<!-- Input -->
<element class="caret/o=value" />

<!-- Output -->
<element class="caret/o" style="--caret: value;" />

CLS Alert

This feature may cause CLS (Cumulative Layout Shift). Make sure to include a z-not-ready class in your <head> tag.

.caret/o Sets caret color + opacity independently via --caret and --caret-o. Controls text cursor transparency.