-
Notifications
You must be signed in to change notification settings - Fork 3
Add Copy component documentation #1868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| ## New Copy component for inline copyable text | ||
|
|
||
| The `<Copy>` component makes text copyable with a single click. Use it inline to allow readers to quickly copy version numbers, commands, API keys, or other text snippets without selecting and copying manually. | ||
|
|
||
| You can also customize what gets copied to the clipboard using the `clipboard` prop. This is useful when you want to display formatted text but copy plain text or a different value. | ||
|
|
||
| ```jsx | ||
| Use the Fern CLI to build and consume REST APIs. The latest version is <Copy>v2.0</Copy>. | ||
|
|
||
| If you want the full version, you can use the <Copy clipboard="foobopbar">v1.0</Copy> version. | ||
| ``` | ||
|
|
||
| Read more in the [Copy component documentation](/learn/docs/writing-content/components/copy). | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| --- | ||
| title: Copy | ||
| description: Make text copyable with a click-to-copy button. | ||
| --- | ||
|
|
||
| The `<Copy>` component makes text copyable with a single click. Use it inline to allow readers to quickly copy version numbers, commands, API keys, or other text snippets without selecting and copying manually. | ||
|
||
|
|
||
| ## Usage | ||
|
|
||
| <div className="highlight-frame"> | ||
| <div className="highlight-frame-content"> | ||
| Use the Fern CLI to build and consume REST APIs. The latest version is <Copy>v2.0</Copy>. | ||
|
||
| </div> | ||
| </div> | ||
|
|
||
| ```jsx Markdown | ||
| Use the Fern CLI to build and consume REST APIs. The latest version is <Copy>v2.0</Copy>. | ||
| ``` | ||
|
|
||
| ## Variants | ||
|
|
||
| ### Custom clipboard content | ||
|
|
||
| You can customize what gets copied to the clipboard using the `clipboard` prop. This is useful when you want to display formatted text but copy plain text or a different value. | ||
|
|
||
| <div className="highlight-frame"> | ||
| <div className="highlight-frame-content"> | ||
| If you want the full version, you can use the <Copy clipboard="foobopbar">v1.0</Copy> version. | ||
| </div> | ||
| </div> | ||
|
|
||
| ```jsx Markdown | ||
| If you want the full version, you can use the <Copy clipboard="foobopbar">v1.0</Copy> version. | ||
| ``` | ||
|
|
||
| ## Properties | ||
|
|
||
| <ParamField path="children" type="string | ReactNode" required={true}> | ||
| The text content to display and make copyable. This is what users see on the page. | ||
| </ParamField> | ||
|
|
||
| <ParamField path="clipboard" type="string" required={false}> | ||
| Custom text to copy to the clipboard. If not specified, the component copies the children content. Use this when you want to display one value but copy a different value. | ||
| </ParamField> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 [vale] reported by reviewdog 🐶
[FernStyles.Adverbs] Remove 'quickly' if it's not important to the meaning of the statement.