#ele.style()
// Get all style
ele.style(): unknownResolved style read off the stored channels — all of the first element's group props.
unknownthe whole group's props (numbers for numeric props, rgb()/rgba() strings for colors, keywords otherwise), or undefined when the collection is empty
Example
console.log(cy.nodes().first().style()['background-color']); // "rgb(153,153,153)"#ele.style(name)
// Get style by name
ele.style(name: string): unknownResolved style read off the stored channels — one value. A bypassed prop reads its bypass value, since a bypass writes stored truth.
| Name | Description |
|---|---|
name: string | the property to read, dash-case or camelCase |
unknownthe resolved value, or undefined when the collection is empty or the prop belongs to the other group
Example
console.log(cy.nodes().first().style('background-color')); // "rgb(153,153,153)"#eles.style(name, value)
// Set style by name
eles.style(name: string, value: unknown): thisSet a per-element style bypass on every element. Sugar over the stylesheet's bypasses section: the value must be a constant (mappers belong in the sheet's group blocks), the entry is keyed by the element's id and survives remove/re-add, it beats every sheet rule including the default sheet's selection color, and it exports from cy.json().
| Name | Description |
|---|---|
name: string | the property to bypass, dash-case or camelCase |
value: unknown | the constant value to pin |
thisthis collection, for chaining
Example
const result = eles.style('width', 40);console.log(result === eles); // trueon a mapper value, a global font prop, a transition config prop, a wrong-group prop, or an invalid value
#eles.style(props)
// Set several style fields
eles.style(props: Record<string, unknown>): thisSet several per-element style bypasses on every element. The object form of the setter: each key–value pair joins the element's bypass declaration.
| Name | Description |
|---|---|
props: Record<string, unknown> | prop → constant value, dash-case or camelCase keys |
thisthis collection, for chaining
Example
eles.style({ width: 40 });console.log(eles.first().numericStyle('width')); // 40as the name/value form does, per prop
Also spelled eles.css.