File tree Expand file tree Collapse file tree 9 files changed +131
-0
lines changed
react/src/components/clipboard
solid/src/components/clipboard
svelte/src/lib/components/clipboard
vue/src/components/clipboard
website/src/content/pages/components Expand file tree Collapse file tree 9 files changed +131
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ export default meta
9
9
export { Basic } from './examples/basic'
10
10
export { Context } from './examples/context'
11
11
export { Controlled } from './examples/controlled'
12
+ export { CopyStatus } from './examples/copy-status'
12
13
export { CustomTimeout } from './examples/custom-timeout'
13
14
export { Programmatic } from './examples/programmatic'
14
15
export { RootProvider } from './examples/root-provider'
Original file line number Diff line number Diff line change
1
+ import { Clipboard } from '@ark-ui/react/clipboard'
2
+ import { CheckIcon , ClipboardCopyIcon } from 'lucide-react'
3
+ import { useState } from 'react'
4
+
5
+ export const CopyStatus = ( ) => {
6
+ const [ copyCount , setCopyCount ] = useState ( 0 )
7
+
8
+ return (
9
+ < Clipboard . Root
10
+ value = "https://ark-ui.com"
11
+ onStatusChange = { ( details ) => {
12
+ if ( details . copied ) {
13
+ setCopyCount ( ( prev ) => prev + 1 )
14
+ }
15
+ } }
16
+ >
17
+ < Clipboard . Trigger >
18
+ < Clipboard . Indicator copied = { < CheckIcon /> } >
19
+ < ClipboardCopyIcon />
20
+ </ Clipboard . Indicator >
21
+ Copy
22
+ </ Clipboard . Trigger >
23
+ < p > Copied { copyCount } times</ p >
24
+ </ Clipboard . Root >
25
+ )
26
+ }
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ export default meta
9
9
export { Basic } from './examples/basic'
10
10
export { Context } from './examples/context'
11
11
export { Controlled } from './examples/controlled'
12
+ export { CopyStatus } from './examples/copy-status'
12
13
export { CustomTimeout } from './examples/custom-timeout'
13
14
export { Programmatic } from './examples/programmatic'
14
15
export { RootProvider } from './examples/root-provider'
Original file line number Diff line number Diff line change
1
+ import { Clipboard } from '@ark-ui/solid/clipboard'
2
+ import { CheckIcon , ClipboardCopyIcon } from 'lucide-solid'
3
+ import { Show , createSignal } from 'solid-js'
4
+
5
+ export const CopyStatus = ( ) => {
6
+ const [ copyCount , setCopyCount ] = createSignal ( 0 )
7
+
8
+ return (
9
+ < Clipboard . Root
10
+ value = "https://ark-ui.com"
11
+ onStatusChange = { ( details ) => {
12
+ if ( details . copied ) {
13
+ setCopyCount ( ( prev ) => prev + 1 )
14
+ }
15
+ } }
16
+ >
17
+ < Clipboard . Trigger >
18
+ < Clipboard . Indicator >
19
+ < Show when = { false } fallback = { < ClipboardCopyIcon /> } >
20
+ < CheckIcon />
21
+ </ Show >
22
+ </ Clipboard . Indicator >
23
+ Copy
24
+ </ Clipboard . Trigger >
25
+ < p > Copied { copyCount ( ) } times</ p >
26
+ </ Clipboard . Root >
27
+ )
28
+ }
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import type { Meta } from '@storybook/svelte'
2
2
import BasicExample from './examples/basic.svelte'
3
3
import ContextExample from './examples/context.svelte'
4
4
import ControlledExample from './examples/controlled.svelte'
5
+ import CopyStatusExample from './examples/copy-status.svelte'
5
6
import CustomTimeoutExample from './examples/custom-timeout.svelte'
6
7
import ProgrammaticExample from './examples/programmatic.svelte'
7
8
import RootProviderExample from './examples/root-provider.svelte'
@@ -31,6 +32,12 @@ export const Controlled = {
31
32
} ) ,
32
33
}
33
34
35
+ export const CopyStatus = {
36
+ render : ( ) => ( {
37
+ Component : CopyStatusExample ,
38
+ } ) ,
39
+ }
40
+
34
41
export const CustomTimeout = {
35
42
render : ( ) => ( {
36
43
Component : CustomTimeoutExample ,
Original file line number Diff line number Diff line change
1
+ <script lang =" ts" >
2
+ import { CheckIcon , ClipboardCopyIcon } from ' lucide-svelte'
3
+ import { Clipboard } from ' @ark-ui/svelte/clipboard'
4
+
5
+ let copyCount = $state (0 )
6
+ </script >
7
+
8
+ <Clipboard .Root
9
+ value =" https://ark-ui.com"
10
+ onStatusChange ={(details ) => {
11
+ if (details .copied ) {
12
+ copyCount += 1
13
+ }
14
+ }}
15
+ >
16
+ <Clipboard .Trigger >
17
+ <Clipboard .Indicator >
18
+ <ClipboardCopyIcon />
19
+ {#snippet copied ()}
20
+ <CheckIcon />
21
+ {/ snippet }
22
+ </Clipboard .Indicator >
23
+ Copy
24
+ </Clipboard .Trigger >
25
+ <p >Copied {copyCount } times</p >
26
+ </Clipboard .Root >
Original file line number Diff line number Diff line change 2
2
import Basic from ' ./examples/basic.vue'
3
3
import Context from ' ./examples/context.vue'
4
4
import Controlled from ' ./examples/controlled.vue'
5
+ import CopyStatus from ' ./examples/copy-status.vue'
5
6
import CustomTimeout from ' ./examples/custom-timeout.vue'
6
7
import Programmatic from ' ./examples/programmatic.vue'
7
8
import RootProvider from ' ./examples/root-provider.vue'
@@ -18,6 +19,9 @@ import ValueText from './examples/value-text.vue'
18
19
<Variant title =" Controlled" >
19
20
<Controlled />
20
21
</Variant >
22
+ <Variant title =" CopyStatus" >
23
+ <CopyStatus />
24
+ </Variant >
21
25
<Variant title =" CustomTimeout" >
22
26
<CustomTimeout />
23
27
</Variant >
Original file line number Diff line number Diff line change
1
+ <script setup lang="ts">
2
+ import { Clipboard } from ' @ark-ui/vue/clipboard'
3
+ import { CheckIcon , ClipboardCopyIcon } from ' lucide-vue-next'
4
+ import { ref } from ' vue'
5
+
6
+ const copyCount = ref (0 )
7
+ </script >
8
+
9
+ <template >
10
+ <Clipboard .Root
11
+ default-value =" https://ark-ui.com"
12
+ @status-change ="
13
+ (details) => {
14
+ if (details.copied) {
15
+ copyCount += 1
16
+ }
17
+ }
18
+ "
19
+ >
20
+ <Clipboard .Trigger >
21
+ <Clipboard .Indicator >
22
+ <ClipboardCopyIcon />
23
+ <template #copied >
24
+ <CheckIcon />
25
+ </template >
26
+ </Clipboard .Indicator >
27
+ Copy
28
+ </Clipboard .Trigger >
29
+ <p >Copied {{ copyCount }} times</p >
30
+ </Clipboard .Root >
31
+ </template >
Original file line number Diff line number Diff line change @@ -29,6 +29,13 @@ Access the clipboard state and methods using `Clipboard.Context`. This provides
29
29
30
30
<Example id = " context" />
31
31
32
+ ### Copy Status
33
+
34
+ Use the ` onStatusChange ` prop to listen for copy operations. It exposes a ` copied ` property that you can use to display
35
+ a success message.
36
+
37
+ <Example id = " copy-status" />
38
+
32
39
### Controlled
33
40
34
41
Control the clipboard value externally by managing the state yourself and using ` onValueChange ` to handle updates.
You can’t perform that action at this time.
0 commit comments