I’m currently working with combo class styles and using the isComboClass() method to determine whether a style is a combo class:
const isCombo = await style.isComboClass();
if (isCombo) {
console.log('This style is a combo class');
}
However, I couldn’t find any method in the documentation to retrieve the parent class from an existing combo class style object. The docs explain how to create combo classes with parent-child relationships, but I haven’t seen anything like a getParent() method to access the parent programmatically.
I do have a workaround in mind:
one could track the parent-child relationships manually in the code when creating combo classes.
That said, this workaround doesn’t suit my use case, as I’m working with styles that already exits.
Is there any built-in way to retrieve the parent of a combo class? Or any reliable approach others have used in similar situations?
Based on the documentation, there does not seem to be an in-built way to fetch the parent class from a combo class as of now. The workaround you shared is the only one I can think of in order to keep a record of the parent-child relationship while creating those styles.
I am curious to know, if there is some workaround for existing styles though.
No built-in method for that yet , only way I’ve handled it was parsing the full selector name (e.g. splitting on the space or .) to infer the base class. Not perfect, but works reliably if you keep naming consistent.
Hi there! I noticed you have a suggestion for Webflow. I just wanted to let you know that Webflow keeps a wishlist where you can check for similar feedback or submit new ideas. While they may not always respond as quickly as we’d like, the wishlist is the best place to share your thoughts directly with their team.
@sri_sri
If your idea isn’t on there yet, I’d encourage you to add it!
Sharing your feedback helps Webflow understand what features are important to users like you. Even if it takes some time, adding your voice to the wishlist helps get your idea on their radar. Hopefully by working together we can help make Webflow even better. Let me know if you have any other questions!
Hey @sri_sri - you’re right that there isn’t an exposed API for getting that parent relationship yet from a combo class style. I’ve taken this back to our teams so we can work on exposing something like this, thanks for raising!
Hi @sri_sri - good news, you can now fetch the parent style from a combo class style. We’re going to update the docs shortly, but wanted to give an early heads up that this is in production and ready for usage.
/**
* Retrieves the parent style for a combo class and otherwise returns null.
* @example
* ```ts
* const parentStyle = await myStyle.getParent();
* ```
*/