mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-14 18:01:06 +00:00
docs(content-switcher): improve docs
This commit is contained in:
parent
e77fc533d6
commit
073091f4f6
1 changed files with 18 additions and 0 deletions
|
@ -9,8 +9,12 @@ components: ["ContentSwitcher", "Switch"]
|
|||
import Preview from "../../components/Preview.svelte";
|
||||
</script>
|
||||
|
||||
`ContentSwitcher` lets users switch between different views or sections of content. Use it to organize related content into distinct categories or states.
|
||||
|
||||
## Default
|
||||
|
||||
Create a content switcher with `Switch` components. Each switch needs a `text` prop.
|
||||
|
||||
<ContentSwitcher>
|
||||
<Switch text="Latest news" />
|
||||
<Switch text="Trending" />
|
||||
|
@ -18,6 +22,8 @@ components: ["ContentSwitcher", "Switch"]
|
|||
|
||||
## Initial selected index
|
||||
|
||||
Set `selectedIndex` to pre-select a switch when the content switcher loads.
|
||||
|
||||
<ContentSwitcher selectedIndex={1}>
|
||||
<Switch text="Latest news" />
|
||||
<Switch text="Trending" />
|
||||
|
@ -26,10 +32,16 @@ components: ["ContentSwitcher", "Switch"]
|
|||
|
||||
## Reactive example
|
||||
|
||||
This example demonstrates how to programmatically control the content switcher using
|
||||
the `bind:selectedIndex` directive. Update the selected index based on user
|
||||
interactions or application state.
|
||||
|
||||
<FileSource src="/framed/ContentSwitcher/ContentSwitcherReactive" />
|
||||
|
||||
## Custom switch slot
|
||||
|
||||
Override the default slot in `Switch` to customize how each option displays.
|
||||
|
||||
<ContentSwitcher>
|
||||
<Switch>
|
||||
<div style="display: flex; align-items: center;">
|
||||
|
@ -45,6 +57,8 @@ components: ["ContentSwitcher", "Switch"]
|
|||
|
||||
## Extra-large size
|
||||
|
||||
Set `size` to `"xl"` for an extra-large content switcher.
|
||||
|
||||
<ContentSwitcher size="xl">
|
||||
<Switch text="All" />
|
||||
<Switch text="Archived" />
|
||||
|
@ -52,6 +66,8 @@ components: ["ContentSwitcher", "Switch"]
|
|||
|
||||
## Small size
|
||||
|
||||
Set `size` to `"sm"` for a small content switcher.
|
||||
|
||||
<ContentSwitcher size="sm">
|
||||
<Switch text="All" />
|
||||
<Switch text="Archived" />
|
||||
|
@ -59,6 +75,8 @@ components: ["ContentSwitcher", "Switch"]
|
|||
|
||||
## Disabled
|
||||
|
||||
Set `disabled` to `true` on individual switches to prevent interaction.
|
||||
|
||||
<ContentSwitcher>
|
||||
<Switch disabled text="All" />
|
||||
<Switch disabled text="Archived" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue