docs menuvalue with copy — try it in the demo below
Code
An inline code value, shown exactly as it is, with an optional copy button.
import { Code } from "@meowerse/ui"; · source packages/ui/src/components/Code.tsx
variants and states
meow.alxnko.devk3m9-X2p4-q8w1try it
your invite code: k3m9-X2p4-q8w1
working: loading the demo…
demo source
import { Code } from "@meowerse/ui";
export default function Demo() {
return <p className="demo">your invite code: <Code value="k3m9-X2p4-q8w1" copy /></p>;
}
props
| prop | type | default | required |
|---|---|---|---|
value | string the value to show, kept in its original case. | — | yes |
copy | boolean shows a copy button next to the value. | false | no |
className | string extra class names to append. | — | no |
css custom properties
| variable | dark | light |
|---|---|---|
--c-fg | #ededeb | #1a1a1c |
--c-fg-subtle | #8c8c88 | #5e5e5b |
--c-line | #232326 | #cfcec8 |
--c-surface | #151517 | #dfded9 |
--font-mono | "JetBrains Mono", "JetBrains Mono Fallback", ui-monospace, "SFMono-Regular", Menlo, monospace | same |
--fs-2 | 0.8125rem | same |
--r-m | 4px | same |
--r-s | 2px | same |
--sp-1 | 4px | same |
--sp-2 | 8px | same |
Classes: .mw-code. Set any of these variables on an ancestor (or wrap a subtree in .mw-theme--dark / .mw-theme--light) to restyle just that part of a page.
usage
value
import { Code } from "@meowerse/ui";
<Code value="meow.alxnko.dev" /><span class="mw-code"><code class="mono" data-case="preserve">meow.alxnko.dev</code></span>with copy
import { Code } from "@meowerse/ui";
<Code value="k3m9-X2p4-q8w1" copy />accessibility
- The value keeps its case: what you see is what you copy.
- The copy button is 44×44 px and named "copy".
- Success is shown by the icon only and a refused clipboard is silent (audit U-19); that is fixed in the accounts redesign (sub-project 3).
| key | does |
|---|---|
| Tab | reaches the copy button |
| Enter or Space | copies |
do and don't
do
- Use it for ids, keys, codes and commands.
don't
- Don't use it for ordinary words.