Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/style-engine/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Enhancements

- Export the `Style`, `StyleOptions`, and `GeneratedCSSRule` TypeScript types so that consumers of the public API can type their usage of `compileCSS` and `getCSSRules`.

## 2.48.0 (2026-06-10)

### Code Quality
Expand Down
12 changes: 12 additions & 0 deletions packages/style-engine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ _Changelog_

`6.1.0` Introduced in WordPress core.

### GeneratedCSSRule

A single generated CSS rule, as returned by `getCSSRules`.

### getCSSRules

Returns a JSON representation of the generated CSS rules.
Expand Down Expand Up @@ -276,6 +280,14 @@ _Returns_

- `StyleValue`: A CSS custom var value if the incoming style value is a preset value.

### Style

A style object, for example the value of a block's `attributes.style` object or the top-level styles in `theme.json`. Passed to `compileCSS` and `getCSSRules` to generate CSS.

### StyleOptions

Options that adjust how styles are generated by `compileCSS` and `getCSSRules`.

<!-- END TOKEN(Autogenerated API docs) -->

## Glossary
Expand Down
18 changes: 18 additions & 0 deletions packages/style-engine/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@ import type {
} from './types';
import { styleDefinitions } from './styles';

/**
* A style object, for example the value of a block's `attributes.style` object
* or the top-level styles in `theme.json`. Passed to `compileCSS` and
* `getCSSRules` to generate CSS.
*/
export type { Style } from './types';
Comment thread
ralucaStan marked this conversation as resolved.
Resolved

/**
* Options that adjust how styles are generated by `compileCSS` and
* `getCSSRules`.
*/
export type { StyleOptions } from './types';

/**
* A single generated CSS rule, as returned by `getCSSRules`.
*/
export type { GeneratedCSSRule } from './types';

/**
* Generates a stylesheet for a given style object and selector.
*
Expand Down
12 changes: 12 additions & 0 deletions packages/style-engine/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ export interface BorderIndividualStyles< T extends BoxEdge > {
width?: CSSProperties[ `border${ Capitalize< T > }Width` ];
}

/**
* A style object, for example the value of a block's `attributes.style` object
* or the top-level styles in `theme.json`. Passed to `compileCSS` and
* `getCSSRules` to generate CSS.
*/
export interface Style {
background?: {
backgroundImage?:
Expand Down Expand Up @@ -89,13 +94,20 @@ export interface CssRulesKeys {
individual: string;
}

/**
* Options that adjust how styles are generated by `compileCSS` and
* `getCSSRules`.
*/
export interface StyleOptions {
/**
* CSS selector for the generated style.
*/
selector?: string;
}

/**
* A single generated CSS rule, as returned by `getCSSRules`.
*/
export interface GeneratedCSSRule {
selector?: string;
value: string | unknown;
Expand Down
Loading