@molecule/app-copy-link-field-svelte
Feature · copy-link-field · App (browser) · v1.2.1 · Apache-2.0
Read-only input + copy-to-clipboard button for share links, API keys, webhook URLs
npm install @molecule/app-copy-link-field-svelteHow it works
@molecule/app-copy-link-field-svelte is a ready-made copy-link-field feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.
<script lang="ts">
import { setMoleculeContext } from '@molecule/app-svelte'
import { CopyLinkField } from '@molecule/app-copy-link-field-svelte'
setMoleculeContext({ i18n: i18nProvider })
</script>
<CopyLinkField
label="Share link"
value="https://example.com/invite/abc123"
onCopy={() => console.log('copied')}
feedbackMs={2000}
/>Works with: @molecule/app-clipboard, @molecule/app-svelte, @molecule/app-ui, @molecule/app-ui-svelte
Reference
Svelte copy-link field.
Exports <CopyLinkField> — read-only input + copy-to-clipboard button with
"Copied!" feedback. Svelte counterpart of
@molecule/app-copy-link-field-react: the same props (React names), the
same DOM for the same input, the same ClassMap tokens and i18n keys.
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
Quick Start
<script lang="ts">
import { setMoleculeContext } from '@molecule/app-svelte'
import { CopyLinkField } from '@molecule/app-copy-link-field-svelte'
setMoleculeContext({ i18n: i18nProvider })
</script>
<CopyLinkField
label="Share link"
value="https://example.com/invite/abc123"
onCopy={() => console.log('copied')}
feedbackMs={2000}
/>
Type
feature
Installation
npm install @molecule/app-copy-link-field-svelte @molecule/app-clipboard @molecule/app-svelte @molecule/app-ui @molecule/app-ui-svelte svelte
API
Interfaces
CopyLinkFieldProps
Props for the CopyLinkField component.
interface CopyLinkFieldProps {
/** Value to display (and copy on click). */
value: string
/** Optional label above the field. */
label?: string
/** Called after a successful copy. */
onCopy?: () => void
/** How long the "Copied!" state lingers (ms). Defaults to 1500. */
feedbackMs?: number
/** Size of the copy button. Defaults to `'sm'`. */
size?: 'sm' | 'md'
/** Extra classes. */
className?: string
}
Constants
CopyLinkField
const CopyLinkField: LegacyComponentType
Injection Notes
Requirements
Peer dependencies:
@molecule/app-clipboard^1.0.1@molecule/app-svelte^3.6.0 || ^4.0.0@molecule/app-ui^1.0.1@molecule/app-ui-svelte^1.1.0svelte^5.0.0
Runtime Dependencies
@molecule/app-clipboard@molecule/app-svelte@molecule/app-ui@molecule/app-ui-sveltesvelte
The copy button copies through @molecule/app-clipboard
(copyTextWithFallback — the bonded clipboard provider first, then a
legacy copy fallback — which resolves false instead of throwing), so it
works on insecure (non-HTTPS) contexts too; the copied feedback shows and
onCopy fires only when the copy succeeded. The input is read-only and
selects its content on focus, so manual Ctrl/Cmd+C still works as the
fallback. Labels use copyLink.* i18n keys (companion bond:
@molecule/app-locales-copy-link-field), read through the binding's
useTranslation() — the bonded @molecule/app-i18n provider satisfies it,
so the static t works wherever the provider is bonded. Styling routes
through ClassMap tokens (cm.stack(1), cm.flex, cm.input(),
cm.flex1) and requires a bonded ClassMap (e.g.
@molecule/app-ui-tailwind).
Translations
Translation strings are provided by @molecule/app-locales-copy-link-field.