ApiKeyField
A key from another service, pasted to connect it. Hidden with a Show button; when a pattern is given it says at once if what was pasted does not look like a key of that service.
import { ApiKeyField } from '@sypnia/ui/react'
On this page
A Stripe key
Find it in Stripe, under Developers → API keys.
Code
import { useState } from 'react';
import { ApiKeyField, Field } from '@sypnia/ui/react';
// Paste anything that does not start with sk_: it says so at once.
export default function Stripe() {
const [key, setKey] = useState('');
return <Field label="Stripe secret key" hint="Find it in Stripe, under Developers → API keys."><ApiKeyField value={key} onChange={setKey} pattern={/^sk_(live|test)_[A-Za-z0-9]{8,}$/} example="sk_live_ or sk_test_" placeholder="sk_live_…" /></Field>;
} When to use it
Use it when
- Connecting payments, email or AI providers.
Do not use it when
- Showing the person's own keys: use SecretField.
For everyone
- The warning is tied to the field and read with it.
Props
| ApiKeyField | Type | Default |
|---|---|---|
onChangerequired | (v: string) => void | |
valuerequired | string | |
exampleHow a key starts, said in the message: «sk_live_». | string | |
patternWhat a key of this service looks like: /^sk_(live|test)_[A-Za-z0-9]{24,}$/. | RegExp | |
size | "sm" | "md" | "lg" |