Skip to content

Latest commit

 

History

History
54 lines (45 loc) · 2.03 KB

css-if-notation.md

File metadata and controls

54 lines (45 loc) · 2.03 KB

CSS if() notation (inline conditionals on custom properties / self-styling feature)

.callout {
	border-color: if(
		style(--variant: success) ? var(--color-success-30) :
		style(--variant: danger) ? var(--color-danger-30) :
		/* (other variants) */
		var(--color-neutral-30)
	);
	background-color: if(
		style(--variant: success) ? var(--color-success-95) :
		style(--variant: danger) ? var(--color-danger-95) :
		/* (other variants) */
		var(--color-neutral-95)
	);

	@container (style(--variant: success)) {
		&::before {
			content: var(--icon-success);
			color: var(--color-success-05);
		}
	}

	/* (other variants) */
}

image

The major author pain point remains unsolved, and authors have to resort to HTML attributes instead (as explained in #5624).

zx-tag {
  /* if(media(<media-condition>): foo; else: bar) */
  /* if(style(<style-query>): foo; else: bar) */
  /* if(<supports-condition>): foo; else: bar) */
  background-color: if(
    style(--variant: success): green;
    else: white;
  );
}