Wix.Styles
getStyleId
Retrieves the component’s styleId. The styleId represents a set of style parameters we’ve stored for a specific component – colors, fonts, numbers, and booleans.
SDK Version: SDK 1.65.0+
Editor Version: New Editor
Display: Live Site, Preview
Components: Widget, Pinned (aka Fixed-Position) Widget, Page
Once you know the component’s styleId, you can retrieve these style parameters using getStyleParamsByStyleId.
Syntax:
1Wix.Styles.getStyleId(callback)
Parameters:
Name | Type | Description |
---|---|---|
callback (required) | Function | A callback function that receives the styleId |
Example:
1Wix.Styles.getStyleId(function(styleId){2 //do something with the styleId3});
getStyleParams
Retrieves the style parameters of the current component: booleans, numbers, colors, and fonts.
SDK Version: SDK 1.26.0+
Editor Version: New Editor, Old Editor
Display: Live Site, Preview
Components: Widget, Pinned (aka Fixed-Position) Widget, Page
Note:
If calling this method in the settings endpoint, it returns the style parameters of the component that opened the settings endpoint.
Syntax:
1Wix.Styles.getStyleParams(\[callback\])
Parameters:
Name | Type | Description |
---|---|---|
callback | Function | Callback function to retrieve the style values |
Example:
1Wix.Styles.getStyleParams( function(styleParams) {2 //do something with the style params3});
Returns:
1//returns an object with all of the style parameters2{3 booleans: {4 showDescription: true,5 showTitle: true6 },7 Colors:{8 titleColor: {9 themeName: "color-5",10 value: "#302D2D"11 }12 },13 fonts: {14 btnFont: {15 displayName: "Paragraph 2",16 editorKey: "font_8",17 family: "din-next-w01-light",18 fontStyleParam: true,19 preset: "Custom",20 Size: 15,21 Style: {22 bold: false,23 italic: false,24 underline: false,25 },26 value: "font:normal normal normal 15px/18px din-next-w01-light, din-next-w02-light, din-next-w10-light, sans-serif;"27 }28 },29 Numbers:{30 Animation: 231 }32}
getStyleParamsByStyleId
Retrieves the style parameters for a given styleId. The styleId represents a set of style parameters we’ve stored for a specific component – colors, fonts, numbers, and booleans.
SDK Version: SDK 1.65.0+
Editor Version: New Editor
Display: Live Site, Preview
Components: Widget, Pinned (aka Fixed-Position) Widget, Page
You can get the component’s styleId using getStyleId.
Syntax:
1Wix.Styles.getStyleParamsByStyleId(styleId, onSuccess, \[onFailure\])
Parameters:
Name | Type | Description |
---|---|---|
styleId (required) | String | The component’s styleId |
onSuccess (required) | Function | Callback function to retrieve the component’s style parameters |
onFailure | Function | Callback function to handle the case that the styleId wasn't found |
Example:
1Wix.Styles.getStyleParamsByStyleId(2 'djk32',3 function(styleParams) { //do something with the styleParams },4 function(){ //throw error }5);