Skip to content

Commit e9e041e

Browse files
committed
docs(code-snippet): add "Portal tooltip" example
1 parent 5e3c785 commit e9e041e

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

docs/src/pages/components/CodeSnippet.svx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@ Re-render the component to fix this issue.
110110

111111
<FileSource src="/framed/CodeSnippet/HiddenCodeSnippet" />
112112

113+
## Portal tooltip
114+
115+
Set `portalTooltip` to `true` to render the feedback tooltip in a floating portal. This prevents the tooltip from being clipped by parent containers with `overflow: hidden` or z-index stacking contexts. The example below uses a container with hidden overflow; with `portalTooltip`, the tooltip breaks out of the container.
116+
117+
When inside a [Modal](/components/Modal), `portalTooltip` defaults to `true` unless explicitly set to `false`.
118+
119+
<FileSource src="/framed/CodeSnippet/CodeSnippetPortalTooltip" />
120+
113121
## Inside a modal
114122

115123
When used inside a `Modal`, the feedback tooltip is automatically portalled to prevent it from being clipped by `overflow: hidden`. Set `portalTooltip` to explicitly control this behavior.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<script>
2+
import { CodeSnippet, Stack } from "carbon-components-svelte";
3+
</script>
4+
5+
<Stack
6+
gap={4}
7+
style="overflow: hidden; border: 1px dashed var(--cds-border-subtle); padding: 1rem; max-height: 120px;"
8+
>
9+
<CodeSnippet
10+
code="npm i carbon-components-svelte"
11+
feedback="Copied!"
12+
portalTooltip={true}
13+
/>
14+
</Stack>

0 commit comments

Comments
 (0)