Skip to content

Main content

Random CSS Grid Layout Preset Generator

Generate a definite-width grid preset with delegated fixed-track fit counts and initial fr shares, excluding intrinsic browser sizing.

Loading tool…

Description

Generate a definite-width grid preset with delegated fixed-track fit counts and initial fr shares, excluding intrinsic browser sizing.

An interface fixture makes content and state explicit so a consumer can test a rendering or interaction. Literal labels, modeled states, and calculated geometry remain separate from what a browser or assistive technology actually displays or announces.

Generate a definite-width grid preset with delegated fixed-track fit counts and initial fr shares, excluding intrinsic browser sizing.

When to use this tool

Use this generator to create reproducible css grid layout preset cases from the supplied model or bank. Inspect the returned evidence before using cases in a test or exercise.

How to use the tool and how it works

  1. Supply containerWidthPx, gapPx, minimumTrackPx, trackWeight in the field shapes below. Set seed when you need an explicit replay.
  2. Run the tool and correct any input error. For generated controls, distinguish a successful fixture containing an invalid case from failure to generate the fixture.
  3. Read containerWidthPx, gapPx, minimumTrackPx, fitCount, trackWeights, initialTrackSharesPx, unallocatedFreeSpacePx, oneTrackOverflows, css. Use the conventions below. Keep answer-bearing fields separate when presenting an exercise.

Draw container, gap, minimum-track width, and track weights. Delegate a fit count and initial fractional-track shares after gaps, then emit grid CSS using minmax with zero minima and the sampled fr weights.1

Delegated operations used for this result: grid repeat count from gap width; grid fr unit free space share. Their calculation or parsing conventions apply to the corresponding result fields.2, 3

Input fieldMeaning and unitsAccepted input
containerWidthPxContainer Width PxRequired. Object; no unknown keys.
containerWidthPx.minimumMinimumRequired. Safe integer; minimum 1.
containerWidthPx.maximumMaximumRequired. Safe integer; minimum 1.
gapPxGap PxRequired. Object; no unknown keys.
gapPx.minimumMinimumRequired. Safe integer; minimum 0.
gapPx.maximumMaximumRequired. Safe integer; minimum 0.
minimumTrackPxMinimum Track PxRequired. Object; no unknown keys.
minimumTrackPx.minimumMinimumRequired. Safe integer; minimum 1.
minimumTrackPx.maximumMaximumRequired. Safe integer; minimum 1.
trackWeightTrack WeightRequired. Object; no unknown keys.
trackWeight.minimumMinimumRequired. Safe integer; minimum 1.
trackWeight.maximumMaximumRequired. Safe integer; minimum 1.
seedOptional numeric seed; takes precedence over context randomness. Without either, use the fixed tool.io default seed.Optional. Safe integer.
Output fieldInterpretationReturned shape
containerWidthPxContainer Width PxRequired. Finite number.
gapPxGap PxRequired. Finite number.
minimumTrackPxMinimum Track PxRequired. Finite number.
fitCountFit CountRequired. Safe integer; minimum 0; maximum 32.
trackWeightsTrack WeightsRequired. Array of Safe integer; minimum 1.; minimum items 1; maximum items 32.
initialTrackSharesPxInitial Track Shares PxRequired. Array of Finite number.; minimum items 1; maximum items 32.
unallocatedFreeSpacePxUnallocated Free Space PxRequired. Finite number.
oneTrackOverflowsOne Track OverflowsRequired. Boolean.
cssCssRequired. Text; maximum UTF-16 length 2048.
randomnessReplay source and normalized 32-bit seed, or null seed for an advancing context source.Required. Object; no unknown keys.
randomness.seedOptional safe-integer replay seed; normalization and precedence are explained below.Required. Safe integer. or Null.
randomness.sourceSourceRequired. Text; one of "context", "seed".

An explicit safe-integer seed takes precedence over injected context randomness and is normalized to an unsigned 32-bit integer. With no seed and no context source, replay uses the fixed tool.io default seed. A context source must return finite values from zero inclusive to one exclusive; its advancing state must be retained separately. randomness records the source and normalized seed, or null for context. These generators are not cryptographic random sources.

json
{
  "input": {
    "containerWidthPx": {
      "minimum": 640,
      "maximum": 640
    },
    "gapPx": {
      "minimum": 20,
      "maximum": 20
    },
    "minimumTrackPx": {
      "minimum": 200,
      "maximum": 200
    },
    "trackWeight": {
      "minimum": 1,
      "maximum": 3
    },
    "seed": 42
  },
  "output": {
    "containerWidthPx": 640,
    "gapPx": 20,
    "minimumTrackPx": 200,
    "fitCount": 3,
    "trackWeights": [
      3,
      1,
      2
    ],
    "initialTrackSharesPx": [
      300,
      100,
      200
    ],
    "unallocatedFreeSpacePx": 0,
    "oneTrackOverflows": false,
    "css": "display: grid; width: 640px; gap: 20px; grid-template-columns: minmax(0, 3fr) minmax(0, 1fr) minmax(0, 2fr);",
    "randomness": {
      "seed": 42,
      "source": "seed"
    }
  }
}

Limitations and assumptions

  • minimumTrackPx is used to choose count, not as the emitted CSS minimum. A mandatory single track can overflow and is flagged. Intrinsic sizing, content constraints, and full browser grid layout are not computed.
  • A replay requires the same complete input and implementation. The stated sampling convention applies within its eligible space. A finite draw does not exhaust all possible outputs; repeats remain possible unless a distinct-selection rule is explicit.
  • The field tables state structural bounds; cross-field constraints and bounded search or output budgets also apply. Unknown keys are rejected where the object contract disallows them. Input errors are distinct from null fields and deliberate invalid controls in a successful output.

Alternative or Complementary methods

For a supplied example, inspect the returned construction or delegated check directly. To evaluate a consumer, also test cases chosen for its own boundaries; a generated finite corpus does not establish exhaustive coverage.

References

  1. Tool behavior and example: Random CSS Grid Layout Preset Generator — tool.io

  2. Calculation or validation: css/grid-repeat-count-from-gap-width — tool.io

  3. Calculation or validation: css/grid-fr-unit-free-space-share — tool.io

Similar or alternative tools