Skip to main content

AudienceSelector

Location: src/components/AudienceSelector.jsx

Overview

AudienceSelector lets users control who can see their post. It provides three audience levels: public (anyone), friends (mutual friends only), and circles (specific named groups). When "Circles" is selected, a secondary dropdown appears for choosing which circles to share with.

Selected circles are displayed as removable pill badges below the selector. The component integrates with the useCircles hook to fetch the user's circles.

Relevant Invariants

  • Invariant #7: "Human-Scale Social Contexts" -- Circle-based sharing keeps posts within small, intentional groups.
  • Invariant #18: "Defaults Are Moral Decisions" -- Public is the initial option, ensuring intentional visibility choices.

Props

PropTypeRequiredDefaultDescription
audiencestringYes--Current audience: 'public', 'friends', or 'circles'
onAudienceChangefunctionYes--Callback when the audience type changes
selectedCircleIdsarrayYes--Array of selected circle IDs (for circle audience)
onCirclesChangefunctionYes--Callback when selected circles change
compactbooleanNofalseWhen true, hides the audience description text below

Audience Options

IDLabelIconDescription
publicPublicGlobeAnyone can see this post
friendsFriendsUsersOnly your friends can see this
circlesCirclesLockOnly selected circles can see this

Key Behaviors

  • Dropdown Toggle: Clicking the trigger button opens/closes the audience dropdown.
  • Circle Selector: Selecting "Circles" opens a secondary checkbox list of the user's circles. Each circle shows its member count.
  • Circle Pills: Selected circles appear as removable pill badges. Removing all circles switches back to public audience.
  • Empty Circle State: If the user has no circles, an informative message is shown instead of the checkbox list.
  • Click Outside: Both dropdowns close when clicking outside the .audience-selector container.
  • Compact Mode: When compact is true, the description paragraph below the selector is hidden.

Usage

import AudienceSelector from '@/components/AudienceSelector';

const [audience, setAudience] = useState('public');
const [circleIds, setCircleIds] = useState([]);

<AudienceSelector
audience={audience}
onAudienceChange={setAudience}
selectedCircleIds={circleIds}
onCirclesChange={setCircleIds}
/>

Last updated: 2026-02-07