Mixins / foldkit-mixins/utilities

Utilities

namespace · packages/mixins/src/utilities.ts:166

const Utilities = {
  p,
  px,
  py,
  m,
  mx,
  my,
  gap,
  text,
  font,
  leading,
  rounded,
  color,
  bg,
  items,
  justify,
  flex,
  column,
  grid,
  block,
  hidden,
  wFull,
  textCenter,
  uppercase,
  truncate,
  srOnly,
  scriptedOnly,
  plainOnly,
  pointer,
  selectNone,
  scrollFade,
  scrollDivider,
  scrollTimeline,
  steady,
  busyReveal,
}

In the guides

Members

Utilities.p

function · packages/mixins/src/utilities.ts:168

p(step: Space): StyleValue

padding on every side.

Utilities.px

function · packages/mixins/src/utilities.ts:170

px(step: Space): StyleValue

padding-inline.

Utilities.py

function · packages/mixins/src/utilities.ts:172

py(step: Space): StyleValue

padding-block.

Utilities.m

function · packages/mixins/src/utilities.ts:174

m(step: Margin): StyleValue

margin on every side.

Utilities.mx

function · packages/mixins/src/utilities.ts:176

mx(step: Margin): StyleValue

margin-inline; mx('auto') centers a block.

Utilities.my

function · packages/mixins/src/utilities.ts:178

my(step: Margin): StyleValue

margin-block.

Utilities.gap

function · packages/mixins/src/utilities.ts:180

gap(step: Space): StyleValue

gap between flex or grid children.

Utilities.text

function · packages/mixins/src/utilities.ts:182

text(size: keyof Tokens['size'] & string): StyleValue

font-size from the size scale.

Utilities.font

function · packages/mixins/src/utilities.ts:184

font(weight: keyof Tokens['weight'] & string): StyleValue

font-weight from the weight scale.

Utilities.leading

function · packages/mixins/src/utilities.ts:187

leading(name: keyof Tokens['leading'] & string): StyleValue

line-height from the leading scale.

Utilities.rounded

function · packages/mixins/src/utilities.ts:190

rounded(radius: keyof Tokens['radius'] & string): StyleValue

border-radius from the radius scale.

Utilities.color

function · packages/mixins/src/utilities.ts:193

color(name: ColorName): StyleValue

Text color from the palette.

Utilities.bg

function · packages/mixins/src/utilities.ts:195

bg(name: ColorName): StyleValue

background from the palette.

Utilities.items

function · packages/mixins/src/utilities.ts:197

items(align: keyof typeof alignments): StyleValue

align-items of a flex or grid container.

Utilities.justify

function · packages/mixins/src/utilities.ts:199

justify(justify: keyof typeof justifications): StyleValue

justify-content of a flex or grid container.

Utilities.flex

const · packages/mixins/src/utilities.ts:201

flex: StyleValue

Utilities.column

const · packages/mixins/src/utilities.ts:203

column: StyleValue

A flex column.

Utilities.grid

const · packages/mixins/src/utilities.ts:204

grid: StyleValue

Utilities.block

const · packages/mixins/src/utilities.ts:205

block: StyleValue

Utilities.hidden

const · packages/mixins/src/utilities.ts:206

hidden: StyleValue

Utilities.wFull

const · packages/mixins/src/utilities.ts:207

wFull: StyleValue

Utilities.textCenter

const · packages/mixins/src/utilities.ts:208

textCenter: StyleValue

Utilities.uppercase

const · packages/mixins/src/utilities.ts:209

uppercase: StyleValue

Utilities.truncate

const · packages/mixins/src/utilities.ts:211

truncate: StyleValue

One line, cut with an ellipsis.

Utilities.srOnly

const · packages/mixins/src/utilities.ts:213

srOnly: StyleValue

Visually hidden but announced: screen-reader-only content.

Utilities.scriptedOnly

const · packages/mixins/src/utilities.ts:229

scriptedOnly: StyleValue

Shown only where scripts run: a control a script drives, with a plain stand-in beside it that plainOnly shows. Last in a slot's pieces, so it wins over a width's display.

Utilities.plainOnly

function · packages/mixins/src/utilities.ts:231

plainOnly(display: string): StyleValue

The stand-in for a scriptedOnly control: not shown, and shown as display where no script runs.

Utilities.pointer

const · packages/mixins/src/utilities.ts:233

pointer: StyleValue

Utilities.selectNone

const · packages/mixins/src/utilities.ts:234

selectNone: StyleValue

Utilities.scrollFade

function · packages/mixins/src/utilities.ts:243

scrollFade(axis?: 'block' | 'inline'): StyleValue

A scroller's content dissolving toward an edge with more to scroll, as shadcn's scroll-fade: a mask whose two ends a scroll timeline moves, so the true start and end stay crisp until something is past them. A browser without scroll timelines (Firefox) gets no fade, since a still one would sit on an edge with nothing beyond it. The gradient is physical, so in a right-to-left page inline fades the left edge first.

Utilities.scrollDivider

function · packages/mixins/src/utilities.ts:254

scrollDivider(axis?: 'block' | 'inline'): StyleValue

A hairline at each edge of a scroller with more past it, as Fluid Functionalism's scroll-divider: on a positioned parent of the scroller, whose ::before and ::after it draws, because the fade's mask would erase a line inside the scroller at the very edge it marks. The scroller names its timeline with scrollTimeline(axis), and the parent borrows it (timeline-scope), so a browser without that draws no line. Give a parent one named scroller per axis: two make the name ambiguous, and an ambiguous timeline draws no line.

Utilities.scrollTimeline

function · packages/mixins/src/utilities.ts:256

scrollTimeline(axis?: 'block' | 'inline'): StyleValue

Names a scroller's timeline for its parent's scrollDivider.

Utilities.steady

function · packages/mixins/src/utilities.ts:268

steady(weight: keyof Tokens['weight'] & string): StyleValue

Room for a label at weight, so it turns heavier (chosen, pressed) without moving what is beside it. The element's data-label holds the label's text, which a hidden ::after sets at that weight with no height: a block as wide as its widest child takes the heavier width whatever the label's own weight. The element stays a block container, so a text-box trim on it still works; without data-label, nothing. Hidden, the copy is no part of the element's accessible name: Chrome's own accessibility tree names a steady button once. (Vitest's in-page locator reads it twice, so a test presses such a button with click().)

Utilities.busyReveal

const · packages/mixins/src/utilities.ts:93

busyReveal: StyleValue

Busy text said only once the wait is noticeable: on a status whose aria-busy="true" marks a wait, it fades in after 0.6s, so a read that answers sooner shows nothing where a "Loading…" drawn for a frame read as a flash. The element itself always renders, so its space is held from the start and nothing moves when the text shows; an answer in time removes aria-busy before the delay ends, and the text never appears. Without aria-busy it does nothing, so the same Slot can say "Nothing here." plainly. The fade follows the motion knob, the delay does not.