Skip to Content
BBRICKSv0.7.4
PR PortalMessages

ChannelPicker

The composer's channel: ChoiceGroup cards, one per channel the app offers, an unavailable one greyed with its reason.

import { ChannelPicker } from '@ergasti/bricks';

Examples

Channel

App, SMS and WhatsApp as a radio group; a channel with unavailable is disabled and shows its reason.

Code
import { useState } from 'react';
import { ChannelPicker, type PrChannel } from '@ergasti/bricks';

function Channels() {
  const [channel, setChannel] = useState<PrChannel>('app');
  return <ChannelPicker value={channel} onChange={setChannel} channels={[{ channel: 'app' }, { channel: 'sms' }, { channel: 'whatsapp', unavailable: 'WhatsApp is not set up yet.' }]} />;
}

Props

Prop

Type

Labels

Every word this component draws, in both languages. Override one per component and language with BricksProvider labels under the key prChannelPicker, or with the component's own prop where it has one. A {name} is a value the component fills in.

prChannelPicker
KeyEnglishArabic
labelChannelالقناة
appTRNDR app,A notification in the creator appتطبيق TRNDR,إشعار في تطبيق صنّاع المحتوى
smsSMS,A text message to the creator’s phoneرسالة SMS,رسالة نصية على موبايل صانع المحتوى
whatsappWhatsApp,A WhatsApp message from TRNDRواتساب,رسالة واتساب من TRNDR

Design guidance

How the BRICKS design system uses ChannelPicker. Written in docs/content/components/ChannelPicker.md; the props above are read from the code, which wins where the two disagree.

The message composer's channel choice, TRNDR app, SMS or WhatsApp, as choice cards with an unavailable channel greyed and explained; use it in the announcement composer.

ChannelPicker wraps ChoiceGroup with the PR admin's channels: the app's notification (the mock's only channel), SMS and WhatsApp. Each channel has a fixed icon and tone. The app decides which channels to offer and which are unavailable, and the reason replaces the card's line ("WhatsApp is not set up yet."). The channel set is inferred: the v3 mock sends to the app only.

Anatomy

A ChoiceGroup labelled "Channel", 2 columns (3 with three channels), one card per channel:

ChannelIconToneTitleLine
appmessageslilacTRNDR appA notification in the creator app
smsphoneskySMSA text message to the creator's phone
whatsappchatlimeWhatsAppA WhatsApp message from TRNDR

Variants

channelsLayout
two entries2 columns
three entries3 columns
an entry with unavailableDisabled card, the reason as its line

States

Chosen (ink edge), hover, focus-visible, disabled (55% opacity, skipped by arrows), as ChoiceGroup.

Types

ChannelOption (channels): { channel: 'app' | 'sms' | 'whatsapp', unavailable?: string }, in order.

Usage

import { ChannelPicker } from '@ergasti/bricks';

<ChannelPicker
  channels={[{ channel: 'app' }, { channel: 'sms' }, { channel: 'whatsapp', unavailable: 'WhatsApp is not set up yet.' }]}
  value={channel}
  onChange={setChannel}
/>
// The composer chooses MessageFields' mode from the channel
<ChannelPicker channels={channels} value={channel} onChange={setChannel} />
<MessageFields channel={channel} subject={subject} body={body} onSubject={setSubject} onBody={setBody} />
<MessagePreview channel={channel} sender={null} subject={subject} body={body} />

Where it appears

  • PR Portal › Messages › New message: the mock sends to the app only, so the channel choice (SMS, WhatsApp) is library-only. AnnouncementComposer draws it for you.

Guidelines

Do

  • Offer only channels TRNDR can send through; mark the rest unavailable with a reason PR can act on.
  • Keep the app first: it is the default and free.

Don't

  • Don't hide an unavailable channel PR expects to see; explain it.
  • Don't reorder icons or tones per screen.

RTL and Arabic

Mirrors. Arabic: "القناة", "تطبيق TRNDR", "رسالة SMS", "واتساب" with their lines.

Tokens

ChoiceGroup and IconSquare tokens (--lilac, --sky, --lime-50, --olive).

Accessibility

As ChoiceGroup: a labelled radiogroup, one tab stop, arrows choose, disabled cards skipped and explained in text.

Found in the source

  • No roles, ARIA attributes or key handling are set in this component's own source; it renders native elements and the components it composes.

Read from the component's source and tests. See Accessibility for the patterns the library follows.

See also: useLanguage · AudienceLabel · AudiencePicker · MessageDrawer

Source

src/pr/ChannelPicker.tsx (line 37) on GitHub.

On this page