Errors

Open in playground

import { reset } from "@cssints/reset" with { type: "cssints" };
import {
  bg,
  cn,
  color,
  display,
  flex,
  fontSize,
  fontWeight,
  lineClamp,
  overflow,
  p,
  WebkitBoxOrient,
  WebkitLineClamp,
} from "cssints" with { type: "cssints" };

reset();

// Teasers of three lines. The WebKit box is the way that works in every engine today and is quiet; the standard lineClamp()
// is a member too, and the build warns for the targets that lack it: the warning appears under the editor, with its place.
const clamp3 = cn(
  display("-webkit-box"),
  WebkitBoxOrient("vertical"),
  WebkitLineClamp(3),
  overflow("hidden"),
);
const standard = cn(lineClamp(3), overflow("hidden"));

const teaser = cn(p(4), bg("#f8fafc"), color("#0f172a"), fontSize("0.9375rem"));
const heading = cn(fontWeight(700), fontSize("1.125rem"));
const text =
  "A bad value is an error in the editor and again in the build, with the file and the place of the call. A value that a browser in your browserslist lacks is a warning, not an error, and it is said once per file.";

export default function App() {
  return (
    <div className={cn(flex().direction("column").gap(3), p(4), color("#0f172a"))}>
      <article className={teaser}>
        <h2 className={heading}>WebKit box</h2>
        <p className={clamp3}>{text}</p>
      </article>
      <article className={teaser}>
        <h2 className={heading}>Standard line-clamp</h2>
        <p className={standard}>{text}</p>
      </article>
    </div>
  );
}

A bad value fails in the types, where the call is, and again at build time with the file and the place of the call, so the Vite overlay points at it. The types catch most of it.

import * as import csscss from "cssints" with { type: "cssints" };
import csscss.const padding: <readonly ["1rem", "solid"]>(parts_0: "1rem", parts_1: "padding: unexpected \"solid\" in \"1rem solid\", grammar <'padding-top'>{1,4}") => css.Style
`<'padding-top'>{1,4}`. Chrome 1, Edge 12, Firefox 1, Safari 1, iOS 1, Android 18. [MDN](https://developer.mozilla.org/docs/Web/CSS/padding)
padding
("1rem", "solid"); // error: not a padding value
Argument of type '"solid"' is not assignable to parameter of type '"padding: unexpected \"solid\" in \"1rem solid\", grammar <'padding-top'>{1,4}"'.
import csscss.const width: <readonly [4]>(parts_0: "width: unexpected \"4\" in \"4\", grammar auto | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()>") => css.Style
`auto | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()>`. Chrome 1, Edge 12, Firefox 1, Safari 1, iOS 1, Android 18. [MDN](https://developer.mozilla.org/docs/Web/CSS/width)
width
(4); // error: a bare number is a length only in spacing properties
Argument of type '4' is not assignable to parameter of type '"width: unexpected \"4\" in \"4\", grammar auto | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()>"'.
import csscss.
const flex: css.Layout
() => css.Chain<css.FlexMethods> (+1 overload)
The layout context: sets `display` and chains its container properties.
flex
().padding(4); // error: flex() does not chain padding
Property 'padding' does not exist on type 'Chain<FlexMethods>'.
import csscss.
const flex: css.Layout
<readonly ["1"]>(parts_0: "1") => css.Style (+1 overload)
The shorthand property of this name: parts are checked against its mdn grammar. A plain style, it does not chain.
flex
("1").gap(2); // error: flex("1") is a plain style, it does not chain
Property 'gap' does not exist on type 'Style'.
import csscss.
const flex: css.Layout
<readonly ["sideways"]>(parts_0: "flex: unexpected \"sideways\" in \"sideways\", grammar none | [ <'flex-grow'> <'flex-shrink'>? || <'flex-basis'> ]") => css.Style (+1 overload)
The shorthand property of this name: parts are checked against its mdn grammar. A plain style, it does not chain.
flex
("sideways"); // error: not a flex value
Argument of type '"sideways"' is not assignable to parameter of type '"flex: unexpected \"sideways\" in \"sideways\", grammar none | [ <'flex-grow'> <'flex-shrink'>? || <'flex-basis'> ]"'.
import csscss.const padding: <readonly [css.Style]>(parts_0: "padding: unexpected \"⟨style⟩\" in \"⟨style⟩\", grammar <'padding-top'>{1,4}") => css.Style
`<'padding-top'>{1,4}`. Chrome 1, Edge 12, Firefox 1, Safari 1, iOS 1, Android 18. [MDN](https://developer.mozilla.org/docs/Web/CSS/padding)
padding
(css.p(1)); // error: a style is not a value
Argument of type 'Style' is not assignable to parameter of type '"padding: unexpected \"⟨style⟩\" in \"⟨style⟩\", grammar <'padding-top'>{1,4}"'.
import csscss.items("center"); // error: there is no items
Property 'items' does not exist on type 'typeof import("packages/cssints/src/types")'.
import csscss.
const media: Condition
<Record<string, string>>(queries: {
    [x: string]: string;
}) => {
    [x: string]: css.QueryWrap;
} (+2 overloads)
media
("min-width > 40rem"); // error: a range needs parentheses
No overload matches this call. Overload 1 of 3, '(queries: { [x: string]: string; }): { [x: string]: QueryWrap; }', gave the following error. Argument of type 'string' is not assignable to parameter of type '{ [x: string]: string; }'. Overload 2 of 3, '(query: "@media: unexpected \">\" in \"min-width > 40rem\", grammar <media-query-list>"): QueryWrap', gave the following error. Argument of type '"min-width > 40rem"' is not assignable to parameter of type '"@media: unexpected \">\" in \"min-width > 40rem\", grammar <media-query-list>"'.

The build checks more than the types see:

import * as import csscss from "cssints" with { type: "cssints" };

import csscss.const p: <readonly [-1]>(parts_0: -1) => css.Style
`<'padding-top'>{1,4}`. Chrome 1, Edge 12, Firefox 1, Safari 1, iOS 1, Android 18. [MDN](https://developer.mozilla.org/docs/Web/CSS/padding)
p
(-1); // padding: unexpected "-0.25rem" in "-0.25rem", expected <length-percentage [0,∞]>
import csscss.const width: <readonly ["calc(1px + 2s)"]>(parts_0: "calc(1px + 2s)") => css.Style
`auto | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()>`. Chrome 1, Edge 12, Firefox 1, Safari 1, iOS 1, Android 18. [MDN](https://developer.mozilla.org/docs/Web/CSS/width)
width
("calc(1px + 2s)"); // width: unexpected "calc(1px" ... (cannot add length and time)
import csscss.
const supports: Condition
<"(display: grdi)">(query: "(display: grdi)") => css.Wrap (+2 overloads)
supports
("(display: grdi)"); // @supports: unexpected "grdi" in "(display: grdi)", expected <supports-in-parens>
import {
  function cn(...styles: Style[]): Style (+1 overload)
Merges styles into one class string. What is known at build time merges (the later property wins); a runtime value (`on && p(4)`, `props.class`, a state call) is joined when the code runs, and a style in it replaces the classes it overrides while it is active.
cn
,
const display: Prop<"display">
`[ <display-outside> || <display-inside> ] | <display-listitem> | <display-internal> | <display-box> | <display-legacy> | grid-lanes | inline-grid-lanes | <display-outside> || [ <display-inside> | math ]`. Chrome 1, Edge 12, Firefox 1, Safari 1, iOS 1, Android 18. [MDN](https://developer.mozilla.org/docs/Web/CSS/display)
display
,
const overflow: Prop<"overflow">
`[ visible | hidden | clip | scroll | auto ]{1,2}`. Chrome 1, Edge 12, Firefox 1, Safari 1, iOS 1, Android 18. [MDN](https://developer.mozilla.org/docs/Web/CSS/overflow)
overflow
,
const WebkitBoxOrient: Prop<"-webkit-box-orient">
`horizontal | vertical | inline-axis | block-axis`
WebkitBoxOrient
,
const WebkitLineClamp: Prop<"-webkit-line-clamp">
`none | <integer [1,∞]>`. [MDN](https://developer.mozilla.org/docs/Web/CSS/-webkit-line-clamp)
WebkitLineClamp
,
} from "cssints" with { type: "cssints" }; export const const clamp2: Styleclamp2 = function cn(...styles: Style[]): Style (+1 overload)
Merges styles into one class string. What is known at build time merges (the later property wins); a runtime value (`on && p(4)`, `props.class`, a state call) is joined when the code runs, and a style in it replaces the classes it overrides while it is active.
cn
(
display<readonly ["-webkit-box"]>(parts_0: "-webkit-box"): Style
`[ <display-outside> || <display-inside> ] | <display-listitem> | <display-internal> | <display-box> | <display-legacy> | grid-lanes | inline-grid-lanes | <display-outside> || [ <display-inside> | math ]`. Chrome 1, Edge 12, Firefox 1, Safari 1, iOS 1, Android 18. [MDN](https://developer.mozilla.org/docs/Web/CSS/display)
display
("-webkit-box"),
WebkitBoxOrient<readonly ["vertical"]>(parts_0: "vertical"): Style
`horizontal | vertical | inline-axis | block-axis`
WebkitBoxOrient
("vertical"),
WebkitLineClamp<readonly [2]>(parts_0: 2): Style
`none | <integer [1,∞]>`. [MDN](https://developer.mozilla.org/docs/Web/CSS/-webkit-line-clamp)
WebkitLineClamp
(2),
overflow<readonly ["hidden"]>(parts_0: "hidden"): Style
`[ visible | hidden | clip | scroll | auto ]{1,2}`. Chrome 1, Edge 12, Firefox 1, Safari 1, iOS 1, Android 18. [MDN](https://developer.mozilla.org/docs/Web/CSS/overflow)
overflow
("hidden"),
);