mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-16 10:51:06 +00:00
feat(theme): add Theme (#741)
* feat(theme): add Theme * fix(theme): fix broken type test * docs(theme): add examples * docs(theme): add description, update carbon theme link [ci skip] * docs: pre-wrap type code snippet [ci skip]
This commit is contained in:
parent
18c6f03224
commit
fac78ee4aa
18 changed files with 475 additions and 4 deletions
46
docs/src/pages/components/Theme.svx
Normal file
46
docs/src/pages/components/Theme.svx
Normal file
|
@ -0,0 +1,46 @@
|
|||
<script>
|
||||
import { Theme } from "carbon-components-svelte";
|
||||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
This utility component dynamically updates the Carbon theme on the client-side using CSS variables.
|
||||
|
||||
### Default
|
||||
|
||||
<FileSource src="/framed/Theme/Theme" />
|
||||
|
||||
### Persist locally
|
||||
|
||||
Set `persist` to `true` to persist the theme locally using the [Window.localStorage API](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage).
|
||||
|
||||
<FileSource src="/framed/Theme/ThemePersist" />
|
||||
|
||||
### Custom theme
|
||||
|
||||
Define keys and values in the `tokens` prop that override default Carbon theme tokens. Refer to the [Carbon website](https://carbondesignsystem.com/guidelines/themes/overview#customizing-a-theme) for guidance on customizing a theme using token values.
|
||||
|
||||
<FileSource src="/framed/Theme/ThemeTokens" />
|
||||
|
||||
### Theme toggle
|
||||
|
||||
Set `render` to `"toggle"` to render a toggle switch to control the theme.
|
||||
|
||||
<FileSource src="/framed/Theme/ThemeToggle" />
|
||||
|
||||
### Theme toggle (custom)
|
||||
|
||||
Customize the toggle using the `toggle` prop.
|
||||
|
||||
<FileSource src="/framed/Theme/ThemeToggleCustom" />
|
||||
|
||||
### Theme select
|
||||
|
||||
Set `render` to `"select"` to render a select dropdown to control the theme.
|
||||
|
||||
<FileSource src="/framed/Theme/ThemeSelect" />
|
||||
|
||||
### Theme select (custom)
|
||||
|
||||
Customize the select using the `select` prop.
|
||||
|
||||
<FileSource src="/framed/Theme/ThemeSelectCustom" />
|
Loading…
Add table
Add a link
Reference in a new issue