Skip to content

CharacterSelector

A pre-built character discovery component that surfaces a roster of characters users can play minigames with. Pass in your own platform characters or omit characters to default to Simula's prebuilt roster.

Character selector component showing a roster of playable characters

Basic Usage

jsx
function RewardFlow() {
  const [selectorOpen, setSelectorOpen] = useState(false);
  const rewardedGame = useRef(null);

  useEffect(() => {
    rewardedGame.current = SimulaRewardedMiniGame.init({
      adUnitId: 'simula-xxxx-rewarded', // Optional: provided by Simula
    });
    rewardedGame.current.load();
  }, []);

  return (
    <>
      <button onClick={() => setSelectorOpen(true)}>Earn free message credits</button>
      <CharacterSelector
        isOpen={selectorOpen}
        onClose={() => setSelectorOpen(false)}
        characters={characterAICharacters} // Optional: omit to use Simula's default roster
        onCharacterSelected={(character) => {
          setSelectorOpen(false);
          rewardedGame.current.show({
            charID: character.id,
            charName: character.name,
            charImage: character.imageUrl,
            charDesc: character.description,
          });
        }}
        ctaText="Launch Game"
      />
    </>
  );
}

Where characterAICharacters is an array of SimulaCharacter objects:

jsx
const characterAICharacters = [
  { id: 'luna-123', name: 'Luna', imageUrl: '/luna.png', description: 'A helpful AI companion' },
  { id: 'nova-456', name: 'Nova', imageUrl: '/nova.png', description: 'A curious space explorer' },
];

Required Props

PropTypeDescription
isOpenbooleanControls selector visibility
onClose() => voidCalled when the user dismisses without selecting
onCharacterSelected(character: SimulaCharacter) => voidCalled with the selected character. Pass fields into .show().

Optional Props

PropTypeDefaultDescription
charactersSimulaCharacter[]Your platform's characters. Omit to use Simula's default roster.
layout"grid" | "list""grid"Display layout
themeCharacterSelectorTheme{}Theme configuration
onCharacterPreview(character: SimulaCharacter) => voidCalled when user previews a character before confirming

SimulaCharacter Object

typescript
interface SimulaCharacter {
  id: string;
  name: string;
  imageUrl: string;
  description: string;
}

CharacterSelector Theme

FieldTypeDefaultDescription
backgroundColorstring"#1A1A2E"Selector background
titleFontColorstring"#FFFFFF"Title text color
secondaryFontColorstring"#A0A0B0"Subtitle/tag text color
accentColorstring"#3B82F6"Selection highlight and CTA color
ctaFontColorstring"#FFFFFF"CTA button text color
cardBackgroundColorstring"rgba(255,255,255,0.06)"Character card background
cardBorderColorstring"rgba(255,255,255,0.1)"Character card border
cardCornerRadiusnumber12Character avatar corner radius (pt)
fontFamilystring"sans-serif"Font family