Customization
Theme the Family SDK widgets, translate or rewrite their copy, and use the Family Portal's avatars and icons.
Appearance
There is no stylesheet to import. The provider injects its CSS under @layer kid, so your own unlayered CSS wins without !important.
<KidFamilyProvider
publishableKey="kgp_test_..."
baseUrl="https://family.test.k-id.com"
appearance={{
variables: { colorPrimary: '#5b2bff', fontFamily: 'Inter, sans-serif', radius: '8px' },
elements: { button: 'my-button-class', card: { maxWidth: 420 } },
}}
>
{children}
</KidFamilyProvider>Variables (AppearanceVariables) retheme every widget: colorPrimary, colorOnPrimary, colorText, colorTextMuted, colorSurface, colorSurfaceMuted, colorBorder, colorDanger, colorSuccess, fontFamily and radius.
Elements override one element by name, with a className to add or a style object to merge. Or target the kid-<name> classes in your own CSS. The names (ElementName) are:
card,title,muted,danger,description,label,rowbutton,secondaryButton,input,toggleTrack,toggleThumbavatar,avatarSelected- The verification list's
verificationMethod,verificationMethodIcon,verificationMethodTitle,verificationMethodTag,verificationMethodDescriptionandverificationMethodDisabledReason
.kid-button {
text-transform: uppercase;
}Every widget fills its container's width; size your own wrapper to constrain it. Appearance applies to every widget except the k-ID verification page itself.
Language and copy
import { getKidLocalization } from '@k-id/family-react/localizations'
<KidFamilyProvider
publishableKey="kgp_test_..."
baseUrl="https://family.test.k-id.com"
localization={getKidLocalization(locale)}
>
{children}
</KidFamilyProvider>The widgets render in English unless you pass a locale. getKidLocalization picks the one for the parent's language and falls back to English. Pass your app's own locale, the one your server renders with, not navigator.language: the server doesn't have it, so the first render in the browser wouldn't match. KID_LOCALES lists all 23, and each is also exported by name (for example, jaJP and frFR).
To change a line, pass only the keys you want to change. They're merged per section over English. Keep any {token} placeholders. The KidStrings type lists every section and key, and en holds the English text. For example, to call the setup's Next button Continue, and reword the disclosures step's line that names it:
import type { KidLocalization } from '@k-id/family-react/localizations'
const localization: KidLocalization = {
childSetup: { next: 'Continue' },
acceptDisclosures: {
publisherPolicyDescription:
"Click 'Continue' to agree to {publisherName}'s legal terms, which govern {publisherName}'s collection and use or processing of your child's data",
},
}To change a line in another language, spread your strings over that locale, per section:
import { jaJP, type KidLocalization } from '@k-id/family-react/localizations'
const localization: KidLocalization = {
...jaJP,
childSetup: { ...jaJP.childSetup, next: '続ける' },
acceptDisclosures: {
...jaJP.acceptDisclosures,
publisherPolicyDescription:
'「続ける」をクリックして、{publisherName}によるお子様のデータの収集、利用、または処理を規定する{publisherName}の法的条件に同意してください。',
},
}useKidStrings() returns the active copy, including errors[code] for your own error messages, and useKidJurisdictions() returns the jurisdiction list in the active language, for your own picker.
Avatars and icons
@k-id/family-react/assets loads the Family Portal's pictures one at a time, on demand. Each loader is async:
import { useEffect, useState } from 'react'
import { loadAvatar } from '@k-id/family-react/assets'
function ChildAvatar({ avatarIndex }: { avatarIndex: number }) {
const [avatar, setAvatar] = useState<{ src: string; alt: string } | null>(null)
useEffect(() => {
let current = true
void loadAvatar(avatarIndex).then((loaded) => current && setAvatar(loaded))
return () => {
current = false
}
}, [avatarIndex])
return avatar && <img src={avatar.src} alt={avatar.alt} width={72} height={72} />
}| Loader | Resolves to |
|---|---|
loadAvatar(index) | { src, alt }. Pass the avatarIndex a child comes with. For your own avatar picker, AVATAR_INDICES and DEFAULT_AVATAR_INDEX in @k-id/family-react/rules list the valid ones. |
loadIcon(name) | An icon's SVG markup. KidIconName lists the names. |
loadImage(name) | { src }. KidImageName lists the names. |
getDataNoticeIcon(key) | A data notice's icon, by the key the notice comes with. |