I have been exploring Figma API to build a Figma plugin that exports a frame into a web component. While I can copy computed CSS from the frame manually via the interface, it looks like there is no way I can access it via API.
Am I missing something here? Any help is appreciated.
Retrieving CSS code for a Figma layer style can be accomplished by utilizing Figma API's
GET /v1/files/{file_id}/styles/{style_id}
endpoint. This endpoint will return the desired information about the style, including the CSS code nestled within the "code" field of the response.Here's a demo of how you can obtain the CSS code for your layer style:
NOTE: You need to have the access token to access the Figma API and retrieve the CSS code for a specific layer style.