Skip to content
Meeko
Type to search the guides and the API reference. Open it from any page with / or Ctrl K; move with the arrow keys and open a result with Enter.
Get started

Contents

On this page

Not translated yet

This page has not been translated into English yet, so it is shown in Spanish.

UtilityHelpers

interfaz Since 1.2.0

Helpers que recibe la función de utilidades. Crean nodos que el plugin valida y convierte en CSS: un selector, una propiedad o un valor no válidos detienen el build con la línea del @utilities.

ts
import type { UtilityHelpers } from "@meekojs/meeko/postcss";

Source code src/compiler/css/utilities.ts:230

Declaración #

ts
interface UtilityHelpers {
	rule(selector: string, declarations: UtilityDeclarations, ...children: UtilityOutput[]): UtilityRule
	rule(selector: string, ...children: UtilityOutput[]): UtilityRule
	atRule(name: string, params: string, declarations: UtilityAtRuleDeclarations, ...children: UtilityOutput[]): UtilityAtRule
	atRule(name: string, params: string, ...children: UtilityOutput[]): UtilityAtRule
	css(strings: TemplateStringsArray | string, ...values: readonly unknown[]): UtilityCss
}

Example #

ts
import { defineUtilities, type UtilityHelpers } from "@meekojs/meeko/postcss";

const sizes = ({ rule, atRule }: UtilityHelpers) => [
  rule(".button[data-size='sm']", { padding: "0.25rem 0.5rem" }),
  atRule("media", "(pointer: coarse)", rule(".button", { minHeight: "2.75rem" })),
];
export default defineUtilities(sizes);

Miembros #

rule #

método

rule(selector: string, declarations: UtilityDeclarations, ...children: UtilityOutput[]): UtilityRule
rule(selector: string, ...children: UtilityOutput[]): UtilityRule

Crea una regla. El segundo argumento es un objeto de declaraciones o la primera hija; las demás hijas (reglas con &, atRule, css, arrays) se anidan dentro.

atRule #

método

atRule(name: string, params: string, declarations: UtilityAtRuleDeclarations, ...children: UtilityOutput[]): UtilityAtRule
atRule(name: string, params: string, ...children: UtilityOutput[]): UtilityAtRule

Crea una at-rule, como @media, @supports, @container, @font-face o @property. name va sin @. Sin cuerpo (sólo name y params) se emite como sentencia.

css #

método

css(strings: TemplateStringsArray | string, ...values: readonly unknown[]): UtilityCss

CSS literal, como cadena o plantilla etiquetada; se analiza con PostCSS. Las barras invertidas se conservan (content: "\201C").

See also #

Was this page helpful?

Add a comment

It is sent when you choose “Yes” or “No”. Only the page, your answer and the comment are stored: no cookies and no personal data.

0 of 2000 characters

Edit on GitHub: packages/meeko/src/compiler/css/utilities.ts