Multiplayer Team Poll
Build a live team poll where votes sync across collaborators without conflicts, paired with private per-viewer notes.
Blocks in Orbix aren't limited to single-player widgets. A single block can combine shared team state, per-member multiplayer votes, and private personal state at the same time.
In the interactive poll below, switch between Alex, Maya, Sam, and Jordan to see how each teammate's vote is tallied across the team while their private note at the bottom stays visible only to them:
How multiplayer state works
If you built a poll by storing a single { count: 4 } number in shared state, two teammates voting at the same time could overwrite each other's count, and nothing would stop one person from clicking the button ten times.
useVoting (built on top of useOrbixState and useMemberState) solves this by splitting the data into three scopes:
| Part of the poll | SDK primitive | Who sees it | How multiplayer sync works |
|---|---|---|---|
| Question & options | useOrbixState (scope: 'team') | Everyone on the page | Stored on the block in the document so any editor can add an option or close the poll. |
| Each person's vote | useMemberState / useVoting | Everyone on the page | Each teammate writes only to their own member slot (memberId -> optionId), so simultaneous votes never collide. |
| Private note | useOrbixState (scope: 'personal') | Only the current viewer | Saved in the viewer's personal state slot so teammates can jot down private context without sharing it. |
Full block code
Copy this file into Block Studio or your local project. useVoting requires no special manifest capabilities.
import { useState } from 'react';
import {
defineBlock,
useVoting,
type BlockRenderProps,
} from '@orbixdocs/sdk';
export default defineBlock({
manifest: {
id: 'acme.team-poll',
name: 'Team Poll',
version: '1.0.0',
sdk: '^3.0.0',
},
component(props: BlockRenderProps) {
const poll = useVoting('migration_poll', {
question: 'Which database migration strategy should we use for v3.2?',
options: [
'Dual-write with background backfill',
'Blue-green cutover during maintenance window',
'Lazy row migration on read',
],
});
const [newOption, setNewOption] = useState('');
const handleAddOption = (e: React.FormEvent) => {
e.preventDefault();
if (props.isReadOnly || !newOption.trim()) return;
poll.addOption(newOption.trim());
setNewOption('');
};
return (
<div
style={{
padding: 20,
borderRadius: 12,
background: '#09090b',
border: '1px solid rgba(255, 255, 255, 0.08)',
color: '#f4f4f5',
}}
>
<div
style={{
display: 'flex',
justifyContent: 'space-between',
alignItems: 'baseline',
marginBottom: 14,
}}
>
<div style={{ fontSize: 16, fontWeight: 500 }}>{poll.question}</div>
<span style={{ fontSize: 12, color: '#a1a1aa' }}>
{poll.totalVoters} {poll.totalVoters === 1 ? 'voter' : 'voters'}
</span>
</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
{poll.results.map((opt) => (
<button
key={opt.id}
type="button"
disabled={props.isReadOnly || poll.isClosed}
onClick={() => poll.vote(opt.id)}
style={{
position: 'relative',
overflow: 'hidden',
padding: '10px 14px',
borderRadius: 8,
background: '#0e0e11',
border: opt.isVotedByMe
? '1px solid rgba(255, 255, 255, 0.3)'
: '1px solid rgba(255, 255, 255, 0.08)',
color: '#f4f4f5',
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
cursor: props.isReadOnly ? 'default' : 'pointer',
textAlign: 'left',
}}
>
<div
style={{
position: 'absolute',
inset: 0,
width: `${opt.percentage}%`,
background: opt.isVotedByMe
? 'rgba(255, 255, 255, 0.12)'
: 'rgba(255, 255, 255, 0.05)',
transition: 'width 240ms ease',
pointerEvents: 'none',
}}
/>
<span style={{ position: 'relative', fontSize: 14, fontWeight: 500 }}>
{opt.label}
</span>
<span
style={{
position: 'relative',
fontSize: 12,
color: '#a1a1aa',
fontFamily: 'monospace',
}}
>
{opt.count} ({opt.percentage}%)
</span>
</button>
))}
</div>
{!props.isReadOnly && (
<form
onSubmit={handleAddOption}
style={{ display: 'flex', gap: 8, marginTop: 12 }}
>
<input
type="text"
value={newOption}
onChange={(e) => setNewOption(e.target.value)}
placeholder="Add an option..."
style={{
flex: 1,
height: 32,
padding: '0 10px',
borderRadius: 6,
background: '#0e0e11',
border: '1px solid rgba(255, 255, 255, 0.08)',
color: '#f4f4f5',
fontSize: 12,
}}
/>
<button
type="submit"
style={{
height: 32,
padding: '0 12px',
borderRadius: 6,
background: '#ffffff',
color: '#09090b',
border: 'none',
fontSize: 12,
fontWeight: 500,
cursor: 'pointer',
}}
>
Add
</button>
</form>
)}
{/* Personal note scoped to the current viewer */}
<div
style={{
marginTop: 16,
paddingTop: 14,
borderTop: '1px solid rgba(255, 255, 255, 0.07)',
}}
>
<div style={{ fontSize: 11, color: '#a1a1aa', marginBottom: 6 }}>
Your private note (only visible to you)
</div>
<input
type="text"
value={poll.myNote}
onChange={(e) => poll.setMyNote(e.target.value)}
placeholder="Jot down private context for this decision..."
style={{
width: '100%',
height: 32,
padding: '0 10px',
borderRadius: 6,
background: '#0e0e11',
border: '1px solid rgba(255, 255, 255, 0.08)',
color: '#f4f4f5',
fontSize: 12,
}}
/>
</div>
</div>
);
},
});