I want to tinker with Kotlin Compose for Web a bit. In some of my past web projects, I made use of some web components of the Clarity Design System (CDS).
In a JavaScript or TypeScript project,
you first need to install both npm packages@cds/core and @cds/city.
Secondly, you have to include some global stylesheets, e.g. via HTML or sass-import.
For each component you want to use, you need to import the corresponding register.js.
Lastly, you can include the component in your HTML like any other tag:
<cds-button>Click me!</cds-button>
I tried to replicate the steps with Kotlin Compose for Web, but wasn't able to get it to work. Any help appreciated!
Okay, I've got it to work now, which included several steps.
This seems to be required, in order to include the global stylesheets.
.woff2files included in stylesheet of ClarityThe stylesheet of CDS include font files of type
.woff2, whose support in webpack must be configured. This can be achieved by creating the filewebpack.config.d/support-fonts.jsat the project root with the following content:register.jsfor desired web componentSadly this solution makes use of APIs marked as
@OptIn(ComposeWebInternalApi::class), which stands for "This API is internal and is likely to change in the future". Any hints on how this may be implemented without relying on internal APIs are appreciated.@Composable!