Skip to main content
Deno 2 is finally here 🎉️
Learn more
Latest
class AtRule
extends Container
Re-export
import { AtRule } from "https://deno.land/x/postcss@8.4.16/lib/postcss.js";

Represents an at-rule.

Once (root, { AtRule }) {
  let media = new AtRule({ name: 'media', params: 'print' })
  media.append(…)
  root.append(media)
}

If it’s followed in the CSS by a {} block, this node will have a nodes property representing its children.

const root = postcss.parse('@charset "UTF-8"; @media print {}')

const charset = root.first
charset.type  //=> 'atrule'
charset.nodes //=> undefined

const media = root.last
media.nodes   //=> []

Constructors

new
AtRule(defaults?: AtRuleProps)

Properties

name: string

The at-rule’s name immediately follows the @.

const root  = postcss.parse('@media print {}')
media.name //=> 'media'
const media = root.first
params: string

The at-rule’s parameters, the values that follow the at-rule’s name but precede any {} block.

const root  = postcss.parse('@media print, screen {}')
const media = root.first
media.params //=> 'print, screen'
parent: Container | undefined
raws: AtRuleRaws
type: "atrule"

Methods

assign(overrides: object | AtRuleProps): this
clone(overrides?: Partial<AtRuleProps>): this
cloneAfter(overrides?: Partial<AtRuleProps>): this
cloneBefore(overrides?: Partial<AtRuleProps>): this