|
1 | 1 | # Compose HTML Material |
2 | 2 |
|
3 | | -[](https://search.maven.org/artifact/com.huanshankeji/compose-html-material) |
4 | | -[](https://plugins.gradle.org/plugin/com.huanshankeji.compose-html-material-conventions) |
| 3 | +[](https://search.maven.org/artifact/com.huanshankeji/compose-html-material3) |
5 | 4 |
|
6 | | -Some Material components for Compose HTML, with legacy Material 2 wrapper components based on [the obsolete `mwc` branch of Material Web](https://github.com/material-components/material-web/tree/mwc) (preferred) and [Material Components for the web (or material-components-web, or `mdc`)](https://github.com/material-components/material-components-web) (fallback), and Material 3 wrapper components based on [Material Web](https://github.com/material-components/material-web) |
| 5 | +Material 3 wrapper components for Compose HTML based on [Material Web](https://github.com/material-components/material-web) |
7 | 6 |
|
8 | | -~~This project is in prototype and the components are not complete. More components will be added. It will probably go through huge refactors and API changes, too.~~ |
| 7 | +For unified multiplatform APIs which are more akin to those in `androidx.compose`, check out [Compose Multiplatform Material](https://github.com/huanshankeji/compose-multiplatform-material). |
9 | 8 |
|
10 | | -**The Material 2 portion of this project is not currently under active development. Here is a list of reasons and alternatives:** |
| 9 | +For Material 2 support, you are recommended to check out [KMDC](https://github.com/mpetuska/kmdc) instead. For information on our obsolete work on legacy Material 2 components, check out [the legacy README](LEGACY_README.md). |
11 | 10 |
|
12 | | -1. The [material-web](https://github.com/material-components/material-web) team is working on Material 3 support and [the Material 2 branch (`mwc`)](https://github.com/material-components/material-web/tree/mwc) is no longer under active development. Existing Compose wrappers of their Material 2 components are still kept in [the `:compose-html-material-legacy` subproject](compose-html-material-legacy) but not updated. |
13 | | -1. [KMDC](https://github.com/mpetuska/kmdc) wrapping around [material-components-web (`mdc`)](https://github.com/material-components/material-components-web) provides a much more complete set of Material Design components for Compose HTML. |
14 | | -1. We are currently focusing more on [compose-multiplatform-material](https://github.com/huanshankeji/compose-multiplatform-material) to provide multiplatform Compose Material wrappers, whose web portion depends on KMDC and [the `:compose-html-common` subproject](compose-html-common), which may be occasionally updated for the dependent project. |
| 11 | +## Supported components |
15 | 12 |
|
16 | | -## Instructions on how to use |
| 13 | +Not all components of Material Web are supported yet. Also, not all Material Design components are supported by Material Web yet (see [their roadmap](https://github.com/material-components/material-web/blob/main/docs/roadmap.md)). |
17 | 14 |
|
18 | | -Some configurations are needed to use this library due to the immaturities of this project and Kotlin/JS. |
| 15 | +Here is a list of supported compoent APIs: |
19 | 16 |
|
20 | | -### Add the dependency |
21 | | - |
22 | | -Prior to v0.3.0: |
23 | | - |
24 | | -```kotlin |
25 | | -implementation("com.huanshankeji:compose-web-common:$version") |
26 | | -implementation("com.huanshankeji:compose-web-material:$version") |
27 | | -``` |
| 17 | +- `MdElevatedButton`, `MdFilledButton`, `MdFilledTonalButton`, `MdOutlinedButton`, `MdTextButton` |
| 18 | +- `MdCheckbox` |
| 19 | +- `MdFab`, `MdBrandedFab` |
| 20 | +- `MdIcon` |
| 21 | +- `MdIconButton`, `MdFilledIconButton`, `MdFilledTonalIconButton`, `MdOutlinedIconButton` |
| 22 | +- `MdList`, `MdListItem` |
| 23 | +- `MdSwitch`, `LabelWithMdSwitch` |
| 24 | +- `MdFilledTextField`, `MdOutlinedTextField` |
28 | 25 |
|
29 | | -Since v0.3.0: |
| 26 | +### "labs" components |
30 | 27 |
|
31 | | -```kotlin |
32 | | -implementation("com.huanshankeji:compose-html-common:$version") |
33 | | -implementation("com.huanshankeji:compose-html-material3:$version") |
34 | | - |
35 | | -implementation("com.huanshankeji:compose-html-material-legacy:$version") // Legacy Material 2 |
36 | | -``` |
| 28 | +Here is a list of supported component APIs in the [Material Web "labs" directory](https://github.com/material-components/material-web/tree/main/labs), which "contains experimental features that are not recommended for production" as they state: |
37 | 29 |
|
38 | | -### In code |
| 30 | +- `MdElevatedCard`, `MdOutlinedCard` |
| 31 | +- `MdNavigationBar` |
| 32 | +- `MdNavigationTab` |
39 | 33 |
|
40 | | -Call `mwcRequires()` in your `main` function before calling any component Composable functions. |
| 34 | +You should opt-in to `@MaterialWebLabsApi` to use them. |
41 | 35 |
|
42 | | -### Kotlin/JS Webpack configuration |
| 36 | +## Brief Instructions |
43 | 37 |
|
44 | | -If you use this library in an app project with Webpack [which Kotlin/JS currently uses](https://kotlinlang.org/docs/js-project-setup.html), you might want to configure it as recommended by Material Web and Material Components for the web. Some instructions on how to do this simply are as below. |
| 38 | +### Add the dependency |
45 | 39 |
|
46 | | -If you use a version prior to v0.3.0, this plugin helps add the dependency to this project (if you do this you can skip the "Add the dependency" step above) and the `devNpm` dependencies: |
| 40 | +With Gradle: |
47 | 41 |
|
48 | 42 | ```kotlin |
49 | | -plugins { |
50 | | - id("com.huanshankeji.compose-web-material-conventions") version someVersion |
| 43 | +kotlin { |
| 44 | + sourceSets { |
| 45 | + jsMain { |
| 46 | + dependencies { |
| 47 | + // ... |
| 48 | + implementation("com.huanshankeji:compose-html-material3:$version") |
| 49 | + } |
| 50 | + } |
| 51 | + } |
51 | 52 | } |
52 | 53 | ``` |
53 | 54 |
|
54 | | -However, the plugin doesn't [make further adjustments to the webpack configuration](https://kotlinlang.org/docs/js-project-setup.html#webpack-configuration-file), so you also need to refer to [the demo further adjustments](demo/webpack.config.d/further_adjustments.js) and [the demo HTML page](demo/html/demo.html) to add your own. Just copy and possibly adapt them as you like. |
55 | | - |
56 | 55 | ### Material Symbols & Icons |
57 | 56 |
|
58 | 57 | The Material 3 module uses [Material Symbols & Icons](https://fonts.google.com/icons), but doesn't depend on the stylesheet directly. For Material Icons to work properly, you may need to configure your project following the quick instructions below or [the developer guide](https://developers.google.com/fonts/docs/material_symbols). |
|
0 commit comments