सीधे मुख्य कॉन्टेंट पर जाएँ
menumenu tanreiexpand_morecontrasttranslate
tanreiexpand_more
शुरुआत करेंWebReactSwiftUIJetpack ComposeFlutterReact Nativeप्रीसेटआपका अपना डिज़ाइन सिस्टमAI एजेंट के साथ Tanrei का इस्तेमालब्रांडडिज़ाइन टोकनडिज़ाइन सिस्टम और कस्टमाइज़ेशनTheme Studioरंगटाइपोग्राफ़ीआइकनशेपएलिवेशनमोशनइंटरैक्शन स्टेटव्यवहारलेआउटसुलभताशब्दकलर टोकनटाइप स्केल टोकनशेप टोकनएलिवेशन टोकनमोशन टोकनस्टेट टोकनस्पेस और माप के टोकनकंपोनेंटबटनमुख्य ऐक्शन बटनसेगमेंटेड बटनबटन ग्रुपमेन्यू वाला बटनटूलबारकॉपी बटनचेकबॉक्सरेडियो बटनस्विचचिपमेन्यूस्लाइडरस्लाइडर फ़ील्डकैलेंडरDateTimePickerफ़ील्ड ग्रुपरेडियो ग्रुपचेकबॉक्स ग्रुपसिलेक्टसिलेक्ट फ़ील्डमेन्यू बारफ़ाइल अपलोडफ़ाइल पिकर उन्नतड्रॉप ज़ोनटेक्स्ट इनपुट उन्नतटेक्स्ट फ़ील्डचिप फ़ील्डफ़ील्डकॉम्बोबॉक्स उन्नतकॉम्बोबॉक्स फ़ील्डनंबर इनपुट उन्नतनंबर फ़ील्डकलर इनपुट उन्नतकलर फ़ील्डवन-टाइम कोड इनपुट उन्नतवन-टाइम कोड फ़ील्डएम्बेडेड टेक्स्ट इनपुट उन्नतचैट कंपोज़रकार्डडिवाइडरमोडल लेयर उन्नतडायलॉगलिस्टलिस्ट पंक्तिबॉटम शीटसाइड शीटकैरसेलकोड ब्लॉकटेबलपॉपओवरचरणअकॉर्डियनडिस्क्रिप्शन लिस्टफ़िगरऐप शेलपेज हेडरट्री व्यूटाइमलाइनइमेज प्रीव्यूसाइज़ हैंडलसाइज़ बदलने वाला फ़्रेमस्क्रॉल एरियाबैजप्रोग्रेस इंडिकेटरमीटरनंबर टिकरलोडिंग इंडिकेटरस्नैकबारटूलटिपकीबोर्ड शॉर्टकटटैगइनलाइन कोडकॉलआउटअवतारख़ाली स्टेटटैग ग्रुपस्केलेटनफ़ाइल आइटमस्वॉचमार्की टेक्स्टटैबटैब व्यूऐप बारनेविगेशन बारनेविगेशन ड्रॉअरखोजलिंकपेजिनेशनपिछला और अगला लिंकस्टेपरब्रेडक्रंबविषय सूचीलिंक कार्डFAB मेन्यूस्थितिTanrei कैसे बनता हैयोगदानलाइसेंस और श्रेय
होमकंपोनेंटकॉपी बटन

कॉपी बटन

वह Button जो दिए गए टेक्स्ट को एक बार दबाने पर कॉपी करता है और इसकी पुष्टि करता है, या बताता है कि वह ऐसा नहीं कर सका। इसे Button बनाता है, और डिफ़ॉल्ट रूप से यह लेआउट को कभी नहीं हिलाता।

content_copyMarkdown में देखें
श्रेणी
ऐक्शन
टोकन
comp.copy-button
स्तर
संयोजित
इनसे बना है
Button

अवलोकन

Web
tanrei-copy-button
schedule
SwiftUI
TanreiCopyButton
radio_button_unchecked
Jetpack Compose
TanreiCopyButton
radio_button_unchecked
Flutter
TanreiCopyButton
radio_button_unchecked
React Native
CopyButton
radio_button_unchecked

इससे जनरेट किया गया: docs/status/status.json, specs/copy-button.spec.json

कोई एक दबाएँ: ग्लिफ़ एक पल के लिए चेक बन जाता है

कॉपी बटन उस चीज़ के बग़ल में इस्तेमाल करें जिसे व्यक्ति कहीं और पेस्ट करेगा: कोई कमांड, कुंजी, पता या रंग का मान। यह ब्राउज़र के जवाब का इंतज़ार करता है, दो सेकंड के लिए एक चेक (या त्रुटि का निशान) दिखाता है, और सहायक तकनीक को शब्दों में बताता है। कोड ब्लॉक इसे आपके लिए ख़ुद रखता है।

इस्तेमाल

कॉपी बटन उस वेरिएंट और साइज़ का Button है जो आप बताते हैं। इसके अपने कोई रंग या माप नहीं हैं, इसलिए जो डिज़ाइन सिस्टम Button का स्टाइल बदलता है, वह उसके साथ हर कॉपी बटन का स्टाइल भी बदल देता है।

शब्द आपके हैं। label, copied-label और failed-label के कोई डिफ़ॉल्ट नहीं हैं, क्योंकि Tanrei किसी भी भाषा में कोई टेक्स्ट नहीं देता।

SwiftUI, Compose, Flutter और React Native नियोजित हैं: इस पेज के शुरू में हर प्लैटफ़ॉर्म के साथ दिए गए नाम वे हैं जो स्पेक उन्हें देता है, और वहाँ अभी कुछ उपलब्ध नहीं है।

<!-- सिर्फ़ आइकन (डिफ़ॉल्ट): नाम label से आता है। -->
<tanrei-copy-button
  text="npm install @tanrei/web"
  label="कॉपी करें"
  copied-label="कॉपी हो गया"
  failed-label="कॉपी नहीं हो सका"
></tanrei-copy-button>

<!-- लेबल के साथ: टेक्स्ट रूप के साथ बदलता है, और चौड़ाई कभी नहीं बदलती। -->
<tanrei-copy-button
  icon-only="false"
  variant="tonal"
  text="https://example.com/s/4f2a"
  label="लिंक कॉपी करें"
  copied-label="लिंक कॉपी हो गया"
  failed-label="कॉपी नहीं हो सका"
></tanrei-copy-button>

<!-- लेबल के साथ, ऐसी चौड़ाई जो शब्दों के साथ बदलती है: सिर्फ़ पंक्ति के आख़िर में। -->
<tanrei-copy-button
  icon-only="false"
  label-width="fit"
  text="sk-test-0000"
  label="कॉपी करें"
  copied-label="क्लिपबोर्ड पर कॉपी हो गया"
  failed-label="कॉपी नहीं हो सका"
></tanrei-copy-button>

<script type="module">
  import '@tanrei/web';

  document.querySelector('tanrei-copy-button').addEventListener('copyfailed', () => {
    // बटन बता चुका है कि वह कॉपी नहीं कर सका। इसके अलावा क्या होगा, यह आपको तय करना है।
  });
</script>
import { CopyButton } from '@tanrei/react';

<CopyButton text={command} label="कॉपी करें" copiedLabel="कॉपी हो गया" failedLabel="कॉपी नहीं हो सका" onCopyFailed={() => showHelp()} />

स्पेक

साइज़ और वेरिएंट Button के हैं

चौड़ाई तीनों टेक्स्ट में से सबसे लंबे के लिए रखी जाती है

एक पड़ोसी जो नहीं हिलता

label-width fit के साथ चौड़ाई शब्दों के साथ बदलती है

label-width="fit" के साथ लेबल वाला रूप उतना ही चौड़ा होता है जितने चौड़े उसके दिखाए गए शब्द हैं। जब शब्द बदलते हैं, तो उसकी चौड़ाई comp.copy-button.motion.resize-duration में धीरे-धीरे नए शब्दों की चौड़ाई तक जाती है, और जहाँ मोशन कम किया गया है वहाँ तुरंत बदलती है। डिफ़ॉल्ट widest ही रहता है, क्योंकि जो कंट्रोल ठीक उसी समय हिलता है जब कोई उसे दबाने जा रहा हो, वह ग़लती से दब जाता है। fit सिर्फ़ वहीं इस्तेमाल करें जहाँ बटन के बाद ऐसा कुछ न हो जिसे व्यक्ति अगली बार दबा सकता है, जैसे किसी पंक्ति के आख़िर में।

बटन के तीन रूप हैं: सामान्य (ग्लिफ़ content_copy), कॉपी हो चुका (check) और विफल (error)। वह कॉपी हो चुका वाला रूप तभी दिखाता है जब ब्राउज़र कॉपी की पुष्टि कर देता है, और comp.copy-button.confirmation.duration (2 सेकंड) के बाद सामान्य रूप में लौट आता है। जब वह पुष्टि दिखा रहा हो, तब दबाने पर वह फिर से कॉपी करता और पुष्टि करता है।

रूप बदलने पर कुछ नहीं हिलता। तीनों ग्लिफ़ एक ही बॉक्स में बनते हैं। डिफ़ॉल्ट रूप से लेबल वाला रूप हर समय अपने सबसे चौड़े टेक्स्ट की चौड़ाई रखता है; label-width="fit" के साथ उसकी चौड़ाई उसके शब्दों के साथ बदलती है, जैसा ऊपर है।

ग्लिफ़ तुरंत बदलता है, बिना किसी मोशन के। ये दो सेकंड ध्यान जाने के लिए हैं, इसलिए जहाँ मोशन कम किया गया है वहाँ भी ये रखे जाते हैं।

अगर बटन के “कॉपी हो गया” दिखाते समय टेक्स्ट बदल जाए, तो वह तुरंत सामान्य रूप में लौट आता है: जो कॉपी हुआ था, वह अब वह नहीं है जो कॉपी होता।

इवेंट copied और copyfailed हैं। इनका नाम copy नहीं रखा गया है, क्योंकि copy दस्तावेज़ का अपना क्लिपबोर्ड इवेंट है।

संरचना

भाग विवरण
1 container The button: a Button of the chosen variant and size, drawn from the Button's tokens. It carries the state answer.
2 icon The glyph, in one box whatever it shows: content_copy at rest, check when the text has been copied, error when it could not be.
3 label · वैकल्पिक The button's text, where it is not icon-only: label at rest, copiedLabel and failedLabel in the two other forms, in a box as wide as the widest of the three (labelWidth widest) or as the one shown (labelWidth fit).

प्रॉपर्टी

प्रॉपर्टी टाइप डिफ़ॉल्ट विवरण
text string "" The text to copy, exactly as it will be pasted. Plain text only.
label string "" What the button does, in the product's language ("Copy", "Copy link", "Copy JSON"): the accessible name of the icon-only form and the visible text of the labelled one. Required.
copiedLabel string "" What is announced, and shown in the labelled form, when the text has been copied ("Copied"). Required.
failedLabel string "" What is announced, and shown in the labelled form, when the platform refuses the copy ("Could not copy"). Required.
iconOnly boolean true True draws the glyph alone, named by label. False draws the glyph and the label as text.
labelWidth widest | fit "widest" How wide the labelled form's text box is. widest, the default, keeps it as wide as the widest of label, copiedLabel and failedLabel at all times, so the button never changes its width and nothing beside it moves (CPY-7). fit makes it as wide as the text it shows, and eases its width to the new text when the form changes (CPY-19): for a button with nothing after it in its row that a person may press next. Ignored while iconOnly is true.
variant filled | tonal | elevated | outlined | text "text" The Button variant it is drawn as. The default, text, is the quiet icon action beside what it copies; a copy that is a view's main action takes another. The values are Button's.
size small | medium | large "medium" The Button size it is drawn at (32 / 40 / 56). The values are Button's.
disabled boolean false Prevents the copy; the button is drawn and exposed as a disabled Button.

इवेंट

इवेंट विवरण
copied The platform confirmed that the text is on the clipboard; carries the text.
copyFailed The platform refused the copy or has no clipboard to write to; carries the platform's reason where it gives one.

स्टेट

व्यवहार

EARS रूप में लिखी गई आवश्यकताएँ। हर प्लैटफ़ॉर्म के इम्प्लीमेंटेशन को इन ID के आधार पर टेस्ट किया जाता है। आवश्यकताओं का पाठ स्पेक फ़ाइल से ज्यों का त्यों, अंग्रेज़ी में दिखाया गया है।

ID आवश्यकता
CPY-1 THE copy button SHALL be drawn as a Button (BTN) of its variant and size, from the Button's own tokens in every state — its container, its glyph, its label, its state layer, its outline and elevation, its disabled form — icon-only with the glyph content_copy WHILE iconOnly is true, and with that glyph leading and label as its text otherwise. It SHALL have no color, shape or measure of its own, SHALL extend its hit area as BTN-5 says, and SHALL draw its glyphs through the platform's icon helper, as a Button does.
CPY-2 WHEN the copy button is activated by pointer, touch, Enter, Space or assistive technology THE copy button SHALL ask the platform to put text on the clipboard as plain text, exactly as given; it SHALL NOT read the clipboard, SHALL NOT copy anything but text, SHALL NOT move focus, and SHALL NOT show the copied form before the platform has answered. A second activation before that answer SHALL be ignored.
CPY-3 WHEN the platform confirms that the text is on the clipboard THE copy button SHALL take the copied form: the glyph check in place of content_copy, in the same box and the same color, and, WHILE iconOnly is false, copiedLabel in place of label; it SHALL emit copied once, carrying the text, and SHALL return to rest comp.copy-button.confirmation.duration after it took the form.
CPY-4 IF the platform refuses the copy or has no clipboard to write to THEN THE copy button SHALL take the failed form — the glyph error in the same box and the same color, and, WHILE iconOnly is false, failedLabel in place of label — SHALL emit copyFailed once, and SHALL return to rest comp.copy-button.confirmation.duration after it took the form. It SHALL NOT select the text, open a dialog or try another way by itself: what else happens is the product's, on that event. IF text is empty WHEN the copy button is activated THEN it SHALL copy nothing and take the failed form, and in debug builds report that there was nothing to copy.
CPY-5 WHEN the copy button takes the copied form THE copy button SHALL have assistive technology announce copiedLabel once, politely (after what is being read); WHEN it takes the failed form it SHALL have failedLabel announced once, assertively. Every activation SHALL be announced anew, also when the same words were announced a moment before. The announcement SHALL NOT move keyboard or screen-reader focus, and nothing SHALL be announced on the return to rest.
CPY-6 WHILE iconOnly is true THE copy button SHALL be named by label in every form: its name does not change with its form, and the form is told by the announcement of CPY-5. WHILE iconOnly is false THE copy button SHALL be named by the text it shows. THE glyph SHALL be kept from assistive technology in every form.
CPY-7 THE copy button SHALL NOT move or resize anything when it changes form, but as CPY-19 says WHILE labelWidth is fit: the three glyphs are drawn in one box; WHILE iconOnly is false and labelWidth is widest the label's box SHALL be as wide as the widest of label, copiedLabel and failedLabel at all times, the shown text at its start, and the button's width and height SHALL be the same in every form; its height SHALL be the same in every form whatever labelWidth is; and the copy button SHALL open no popover, menu or other surface of its own but the confirmation of CPY-18, which takes no room.
CPY-8 WHEN the copy button is activated WHILE it is in the copied or the failed form THE copy button SHALL copy again as CPY-2 says and, on the platform's answer, take the form that answer gives, emit its event, announce it (CPY-5) and count the duration from that moment.
CPY-9 THE copy button SHALL change its glyph and its text at once, without a motion, in both directions (WHILE labelWidth is fit only the width of the text's box moves, as CPY-19 says); the time of comp.copy-button.confirmation.duration is a time to notice and SHALL NOT be shortened or skipped where motion is reduced. WHEN text changes WHILE the copy button is in the copied form THE copy button SHALL return to rest at once: what was copied is no longer what would be.
CPY-10 WHILE disabled is true THE copy button SHALL be drawn and exposed as a disabled Button, SHALL copy nothing and SHALL emit nothing; WHEN it becomes disabled WHILE in the copied or the failed form it SHALL return to rest at once.
CPY-11 WHILE the system's icon set cannot yet draw a glyph of the copy button (its font is still loading) THE copy button SHALL draw nothing in that glyph's place, never the glyph's name as text, SHALL keep the glyph's box, and SHALL draw the glyph once the set can; label, copiedLabel and failedLabel SHALL still reach assistive technology.
CPY-12 WHEN the copy button is pressed by pointer, touch, Enter or Space THE copy button SHALL show the pressed state without delay and SHALL keep it visible for at least sys.motion.duration.press-hold, even when the press ends sooner.
CPY-13 WHILE pressed THE copy button SHALL answer as sys.behavior.pressed-feedback names: overlay applies the pressed tokens to the whole container at once; ripple grows the pressed state layer from the point of contact (from the center for keyboard activation); dim applies the pressed opacity to the whole control and draws no state layer; none draws no answer to the press. Under ripple and dim only the container color stays with the state under the press; label, icon, outline, elevation, opacity and shape still come from the pressed tokens. Under none every part stays with the state under the press. The ripple grows over comp.button.motion.feedback-duration with comp.button.motion.state-easing, fades over the state duration of its size (comp.button.motion.state-duration.small, .medium or .large) with comp.button.motion.state-easing once the press has ended and press-hold has passed, and appears whole where motion is reduced.
CPY-14 THE copy button SHALL ease its container corners by sys.shape.corner-smoothing (0 is a quarter circle, 0.6 the iOS continuous corner; a platform with only the OS curve draws it for any amount above 0) and show its keyboard focus as sys.behavior.focus-style names (ring or glow); a platform that cannot draw a choice SHALL fall back to the first value and state that in its README.
CPY-15 THE copy button SHALL take its layout direction from where it is used — the direction of the nearest ancestor that sets one, and the platform's own where none does — and SHALL have no direction setting of its own; WHEN that direction changes while the copy button is shown THE copy button SHALL draw itself for the new direction at once, without a motion of its own, keeping its form, the time left before it returns to rest and its focus.
CPY-16 WHERE the layout direction is right-to-left THE copy button SHALL place its glyph and its label as a Button places a leading icon and a label (BTN-11), and SHALL draw each of its glyphs mirrored left to right exactly when the system's icon set marks that glyph's name as mirrored: the icon helper mirrors the glyph inside its own box, changing neither its place, size, color and fill. THE copy button SHALL NOT mirror a glyph itself.
CPY-17 WHILE label, copiedLabel or failedLabel is empty THE copy button SHALL still render and copy, and in debug builds report which is missing: an icon-only button without label has no accessible name, unless the product gives it a name of its own on the element — aria-label, or aria-labelledby naming an element — which it then exposes as its accessible name and does not report missing. WHILE label is not empty THE copy button SHALL expose the name CPY-6 says, over a name the product gives it on the element (aria-label or aria-labelledby). WHEN variant or size names a value the Button does not have in the active design system THE copy button SHALL be drawn with its own default for that prop, and in debug builds report the unknown value.
CPY-18 WHEN the copy button takes the copied or the failed form WHILE iconOnly is true THE copy button SHALL show copiedLabel or failedLabel as a plain Tooltip (TIP) of its button — drawn from the Tooltip's own tokens and placed as it places itself, at the top by default — for as long as the form lasts, and SHALL close it at the return to rest; each answer of CPY-8 SHALL show it anew. It SHALL take no focus and no room, move nothing, and SHALL NOT open or close on hover, focus or a long press; it SHALL be closed by Escape and by another tooltip that opens, as any tooltip is, and SHALL be kept from assistive technology, which hears the words once, from the announcement of CPY-5. WHILE iconOnly is false THE copy button SHALL show no such bubble: its label says it.
CPY-19 WHILE iconOnly is false and labelWidth is fit THE copy button SHALL make the label's box as wide as the text it shows, and its button as wide as that box and its glyph make it, the text on one line; WHEN the shown text changes — the form changes, or the words of the form shown do — THE copy button SHALL change the box's width from the width it has to the new text's over comp.copy-button.motion.resize-duration with comp.copy-button.motion.resize-easing, keeping its height, its glyph and the start of its text in place and clipping the text at the box's end while the box is narrower than it, and SHALL change the width at once where motion is reduced. THE copy button SHALL take its first width, and a width that changes because the text's face has arrived, at once. A change of form during the motion SHALL continue from the width reached.
CPY-20 WHERE the platform has ARIA attributes (the web), WHEN the product sets an aria- attribute on the host, by the attribute or by the ARIA property that reflects it, THE copy button SHALL move it to the data-aria- attribute of the same name, so that the host is no second node with its name, description or state, and SHALL expose it on the element that carries its role — an id reference by the elements it names in the host's tree or a tree around it, an error message as part of the description while the copy button is invalid — except those the copy button owns (aria-pressed, aria-disabled), which it SHALL move and not expose. WHEN the product removes the aria- attribute or its data-aria- twin, or sets the ARIA property that reflects it (ariaLabel, ariaDescribedByElements…) to null, THE copy button SHALL take it off that element. WHEN the product sets an aria- attribute the copy button owns THE copy button SHALL report it in debug builds.

प्लैटफ़ॉर्म के अनुसार नामों का मिलान

पैरिटी का मतलब एक जैसे API नहीं है। हर प्लैटफ़ॉर्म एक ही कॉन्ट्रैक्ट को अपने तरीक़े से व्यक्त करता है।

स्पेक Web SwiftUI Jetpack Compose Flutter React Native
कंपोनेंट tanrei-copy-button TanreiCopyButton TanreiCopyButton TanreiCopyButton CopyButton
text · प्रॉपर्टी text text text text text
label · प्रॉपर्टी label label label label label
copiedLabel · प्रॉपर्टी copiedLabel copiedLabel copiedLabel copiedLabel copiedLabel
failedLabel · प्रॉपर्टी failedLabel failedLabel failedLabel failedLabel failedLabel
iconOnly · प्रॉपर्टी iconOnly iconOnly iconOnly iconOnly iconOnly
labelWidth · प्रॉपर्टी labelWidth labelWidth labelWidth labelWidth labelWidth
variant · प्रॉपर्टी variant variant variant variant variant
size · प्रॉपर्टी size size size size size
disabled · प्रॉपर्टी disabled disabled enabled enabled disabled
copied · इवेंट copied onCopied onCopied onCopied onCopied
copyFailed · इवेंट copyfailed onCopyFailed onCopyFailed onCopyFailed onCopyFailed
टिप्पणियाँ <tanrei-copy-button text="…" label="Copy" copied-label="Copied" failed-label="Could not copy">, with icon-only="false" for the labelled form. Its shadow root holds a <tanrei-button> (so every Button token and state applies unchanged) and one visually hidden live region: role="status" for the copied announcement and role="alert" for the failed one, emptied and set again on each activation so the same words are spoken twice (CPY-5). CPY-2 is navigator.clipboard.writeText(text), which needs a secure context and the person's activation; where the API is missing or the promise rejects, that is CPY-4 — no document.execCommand fallback. The events are named copied and copyfailed, not copy, because copy is the document's own clipboard event and bubbles. CPY-7: the three labels are stacked in one grid cell, two of them visibility: hidden. CPY-19 (label-width="fit"): the box's inline-size is set to the shown text's measured width and transitions over the resize tokens (none under prefers-reduced-motion: reduce), clipped at its end with overflow-x: clip; a ResizeObserver on the three texts takes a new face's widths at once. The timer is a setTimeout of the token's value read from the custom property, cleared on a new activation and on disconnect. TanreiCopyButton(text:, label:, copiedLabel:, failedLabel:, iconOnly:, variant:, size:) over TanreiButton. Writes UIPasteboard.general.string (NSPasteboard.general on macOS), which does not fail; the failed form is reached only where no pasteboard exists (a preview). Announces with AccessibilityNotification.Announcement, at high priority for the failed form. disabled is the environment's isEnabled. It owes labelWidth (CPY-19) as well: fit, a width that follows the shown text, eased over comp.copy-button.motion.resize-duration and at once where motion is reduced. TanreiCopyButton(text, label, copiedLabel, failedLabel, iconOnly, variant, size, enabled) over TanreiButton, writing through the platform clipboard of the composition. Android 13 and later show the system's own confirmation of a copy: there the copy button still changes its glyph and leaves the announcement of copiedLabel to the system, so the person is told once; the README says so. Earlier versions announce through a polite live region on the button's semantics. It owes labelWidth (CPY-19) as well: fit, a width that follows the shown text, eased over comp.copy-button.motion.resize-duration and at once where motion is reduced. TanreiCopyButton(text: …, label: …, copiedLabel: …, failedLabel: …) over TanreiButton. Clipboard.setData(ClipboardData(text: text)); a PlatformException is CPY-4. Announces with SemanticsService.announce, assertively for the failed form. On Android 13 and later the same rule as Compose's applies. It owes labelWidth (CPY-19) as well: fit, a width that follows the shown text, eased over comp.copy-button.motion.resize-duration and at once where motion is reduced. <CopyButton text="…" label="Copy" copiedLabel="Copied" failedLabel="Could not copy" /> over Button. React Native has no clipboard in its core: the package takes the app's writer (write={(text) => Clipboard.setStringAsync(text)}) or a provider set once at the app's root, and a missing writer is CPY-4 with a debug report. Which of the two, and whether a clipboard module becomes an optional peer dependency, is the platform agent's to propose. Announces with AccessibilityInfo.announceForAccessibility. Follows the app's direction where an ancestor's is not known. It owes labelWidth (CPY-19) as well: fit, a width that follows the shown text, eased over comp.copy-button.motion.resize-duration and at once where motion is reduced.

टोकन

टोकन किसका एलियास रिज़ॉल्व किया गया मान (लाइट)
--tanrei-comp-copy-button-confirmation-duration — 2000ms
--tanrei-comp-copy-button-motion-resize-duration sys.motion.role.resize.default 300ms
--tanrei-comp-copy-button-motion-resize-easing sys.motion.easing.spatial cubic-bezier(0.2, 0, 0, 1)

फ़िक्स्चर

मानक रेंडरिंग। हर प्लैटफ़ॉर्म हर फ़िक्स्चर का स्नैपशॉट एक ही ID से लेता है, ताकि नतीजों की तुलना की जा सके।

इससे जनरेट किया गया: specs/copy-button.spec.json, tokens/comp/copy-button.tokens.json, design/tokens/

वेब क्या अलग ढंग से बनाता है

  • कॉपी के लिए navigator.clipboard.writeText इस्तेमाल होता है। उसे एक सुरक्षित पेज (HTTPS या localhost) और व्यक्ति का दबाना चाहिए। जहाँ ब्राउज़र में क्लिपबोर्ड नहीं है या वह मना कर देता है, वहाँ बटन विफल रूप ले लेता है। कोई फ़ॉलबैक नहीं है।
  • दोनों इवेंट बबल होते हैं और शैडो रूट के पार नहीं जाते।

दिशानिर्देश

सिर्फ़ आइकन, या लेबल के साथ

रूप क्या दिखाता है कब इस्तेमाल करें
सिर्फ़ आइकन ग्लिफ़, और जब तक वह चेक दिखाता है, उसके ऊपर एक छोटे बबल में शब्द उस चीज़ के बग़ल में जिसे वह कॉपी करता है: कोई कमांड, कोड ब्लॉक, पंक्ति का कोई मान
लेबल के साथ ग्लिफ़ और शब्द, जो रूप के साथ बदलते हैं कॉपी व्यू की क्रियाओं में से एक है, या शब्द सबके लिए मायने रखते हैं

करें

  • जब जगह से यह साफ़ न हो कि क्या कॉपी होता है, तो लेबल में बताएँ: “लिंक कॉपी करें”, “JSON कॉपी करें”।
  • जब व्यक्ति को टेक्स्ट फिर भी मिलना ही चाहिए, तो copyfailed सुनें और ऐसा कुछ दिखाएँ जो बना रहे, जैसे किसी फ़ील्ड में चुना हुआ टेक्स्ट।
  • अपने कॉन्टेंट के बग़ल के कॉपी बटन के लिए text वेरिएंट ही रखें। जब कॉपी करना व्यू की मुख्य क्रिया हो, तब कोई और वेरिएंट चुनें।
  • जब लेबल वाले कॉपी बटन के बाद ऐसा कुछ हो जिसे व्यक्ति अगली बार दबा सकता है, तो डिफ़ॉल्ट चौड़ाई रखें। label-width="fit" सिर्फ़ वहीं चुनें जहाँ ऐसा कुछ न हो।

न करें

  • बटन को सिर्फ़ होवर पर न दिखाएँ। तब वह टच से ढूँढ़ा नहीं जा सकता।
  • सफल कॉपी के लिए अपनी ओर से टूलटिप या स्नैकबार न खोलें। बटन पहले ही उसकी पुष्टि कर देता है, शब्दों में भी।
  • इसे टेक्स्ट के अलावा कुछ और कॉपी करने के लिए इस्तेमाल न करें।

सुलभता

रोल
button
लेबलिंग
The icon-only form is named by label, which is required, in every form: the name does not change when the glyph does. The labelled form is named by the text it shows. The result is announced through a live region: copiedLabel politely, failedLabel assertively (CPY-5).
न्यूनतम टार्गेट
दिखने वाला आकार छोटा होने पर भी हिट एरिया न्यूनतम टार्गेट साइज़ को पूरा करता है। minimum 32px · pointer 44px · spacing 8px · touch 48px

कीबोर्ड

कुंजियाँ क्रिया
Tab Moves focus to the copy button.
Enter / Space Copies the text and confirms it; focus stays on the button.

टिप्पणियाँ

  • The target is the Button's (BTN-5): at least sys.target.touch for touch and sys.target.pointer for a fine pointer on both axes, whatever size is drawn.
  • The confirmation is a status message (WCAG 4.1.3): it reaches assistive technology without moving focus. The glyph change alone would say nothing to a person who cannot see it, and a changed name is not announced on every platform, which is why the icon-only form's name stays and the live region speaks.
  • The confirmation is not given by color: the glyph changes shape (check, error) in the Button's own icon color, and the words are announced. No success or error color is used.
  • The confirmation returns by itself after comp.copy-button.confirmation.duration. Nothing a person must act on is in it, so no timing control is needed (WCAG 2.2.1); a failure a person must act on is the product's to show, on copyFailed, in something that stays.
  • A sighted person using the icon-only form sees the check and, for as long as it shows, the same words in a bubble drawn as a plain Tooltip (CPY-18): the change of a glyph alone can be missed by a person who does not know the check, or who reads the page magnified. The bubble is not read a second time: the announcement of CPY-5 is the one assistive technology hears.
  • The labelled form's visible text is its name (WCAG 2.5.3) in every form. By default (labelWidth widest) its width is reserved for the widest of the three texts, so neighbouring controls do not move under a pointer about to press them (CPY-7). labelWidth fit lets the width follow the text — a change the person asked for by pressing, eased over a short motion and at once where motion is reduced (WCAG 2.3.3) — and is for a button that nothing a person may press next stands after; its own box still keeps the minimum target in every form.
  • Copying needs the platform's permission and, on the web, a secure page and a press by the person: a copy asked for by script alone may be refused, and is then a failure (CPY-4).

इससे जनरेट किया गया: specs/copy-button.spec.json, tokens/sys/measure.tokens.json

कंपोनेंट क्या सँभालता है

  • यह एक बटन है, जिसके पास Button का फ़ोकस इंडिकेटर, उसका न्यूनतम टार्गेट और उसकी कुंजियाँ (Enter और Space) हैं।
  • सिर्फ़ आइकन वाले रूप का नाम हर रूप में label से आता है। ग्लिफ़ बदलने पर नाम नहीं बदलता।
  • नतीजा एक लाइव रीजन के ज़रिए पढ़कर सुनाया जाता है: copied-label बिना टोके (polite), failed-label ज़ोर देकर, हर बार दबाने पर, फ़ोकस को हिलाए बिना।
  • सिर्फ़ आइकन वाला रूप, पुष्टि जितनी देर रहती है उतनी देर, वही शब्द एक बबल में भी दिखाता है, जो सादे टूलटिप की तरह बनता है। यह फ़ोकस नहीं लेता, दोबारा नहीं पढ़ा जाता, और Escape इसे बंद करती है।
  • पुष्टि एक शेप और शब्द हैं, कोई रंग नहीं।
  • दाएँ से बाएँ वाले लेआउट में कॉपी का ग्लिफ़ मिरर होता है, जैसा आइकन सेट कहता है। चेक और त्रुटि का निशान मिरर नहीं होते।
  • लेबल वाला रूप डिफ़ॉल्ट रूप से अपनी चौड़ाई रखता है, इसलिए दबाने जा रहे पॉइंटर के नीचे कुछ नहीं हिलता। label-width="fit" के साथ चौड़ाई धीरे-धीरे नए शब्दों की चौड़ाई तक जाती है, और जहाँ मोशन कम किया गया है वहाँ तुरंत बदलती है।

आपको क्या करना है

  • तीनों लेबल दें, अपने प्रॉडक्ट की भाषा में। बिना label के सिर्फ़ आइकन वाले बटन का कोई एक्सेसिबल नाम नहीं होता।
  • जहाँ व्यक्ति को टेक्स्ट नहीं खोना चाहिए, वहाँ विफलता के बाद का काम ख़ुद सँभालें।