An attempt to make Material 3 in Svelte. See the website for docs.
- Install the library into a Svelte project (e.g.
npm install m3-svelte
) - Use the theme creator to construct your theme. This is needed for components to function, as it gives some base styling, and your theme's colors. Drop the component in
+layout.svelte
and import it. - Set up your typography. You can customize it with CSS variables or just import Roboto. The CSS variables used for font styles are:
- font-family:
--md-sys-typescale-body
- font-weight:
--md-sys-typescale-body-weight
- font-family:
- Set up your body defaults, such as foreground/background and default fonts. You can optionally use the classes
md-body-large
,md-body-medium
, ormd-body-small
depending on the desired root font size. - That's all; import components as needed!
Example +page.svelte
:
<script>
import { Card, Button } from 'm3-svelte';
</script>
<Card type='filled'>
Hello world
</Card>
<Button type='filled'>Press me</Button>