Skip to main content

Component basics

DialStack's embedded components are ready-made UI for voice features: call history, voicemail, phone numbers, routing, onboarding and a softphone. Most of them exist both as a React component in @dialstack/sdk-react and as a Web Component (a custom element) in @dialstack/sdk-js. The React component is a thin wrapper around the Web Component, so both render the same UI and take the same options. React passes them as props and the Web Component takes them through setter methods.

Before you use a component, initialize the SDK and, in React, wrap your tree in DialstackComponentsProvider. See Setup.

Component inventory​

ComponentReact importWeb ComponentPage
CallHistoryCallHistory from @dialstack/sdk-react/call-history<dialstack-call-history>Call history
CallLogsCallLogs from @dialstack/sdk-react/call-logs<dialstack-call-logs>Call logs
VoicemailsVoicemails from @dialstack/sdk-react/voicemails<dialstack-voicemails>Voicemails
PhoneNumbersPhoneNumbers from @dialstack/sdk-react/phone-numbers<dialstack-phone-numbers>Phone numbers
PhoneNumberOrderingPhoneNumberOrdering from @dialstack/sdk-react/phone-number-ordering<dialstack-phone-number-ordering>Phone number ordering
AIAgentAIAgent from @dialstack/sdk-react/ai-agent<dialstack-ai-agent>AI agent
DialPlanDialPlan from @dialstack/sdk-react/dial-planReact onlyDial plan
OnboardingPortalOnboardingPortal from @dialstack/sdk-react/onboardingReact onlyOnboarding portal
SoftphoneSoftphoneProvider, Softphone from @dialstack/sdk-react/softphoneReact onlySoftphone

Each React component has its own import path, so your bundle only includes the components you import.

Wiring a component​

Render the component anywhere inside DialstackComponentsProvider. It reads the instance from the provider.

TypeScript
import { CallLogs } from '@dialstack/sdk-react/call-logs';

function Dashboard() {
return <CallLogs limit={20} layoutVariant="compact" />;
}

Common options​

Every list component (CallHistory, CallLogs, Voicemails, PhoneNumbers) accepts these options. The component pages only list what is specific to each one.

React propWeb Component methodTypeDescription
—setInstance(instance)DialStackInstanceConnect the element to an initialized instance
localesetLocale(locale)LocaleUI strings. See Internationalization
formattingsetFormatting(options)FormattingOptionsDate, time and phone number formatting (see below)
iconssetIcons(icons)ComponentIconsReplace some or all of the default SVG icons
layoutVariantsetLayoutVariant(variant)'compact' | 'comfortable' | 'default'Spacing density (see below)
classessetClasses(classes)Component-specific …ClassesExtra CSS classes. See Theming
onLoaderStartsetOnLoaderStart(cb)(event: LoaderStart) => voidCalled when the component starts loading data
onLoadErrorsetOnLoadError(cb)(event: LoadError) => voidCalled when loading fails
className—stringClass on the React wrapper's container element
style—React.CSSPropertiesInline style on the React wrapper's container

LoaderStart is { elementTagName }. LoadError is { error, elementTagName }, where error is a message string.

TypeScript
<CallLogs
onLoaderStart={() => setLoading(true)}
onLoadError={(event) => {
console.error(`${event.elementTagName} failed to load:`, event.error);
}}
/>

FormattingOptions​

OptionTypeDefaultDescription
defaultCountrystring'US'Country used to format phone numbers (ISO 3166-1 alpha-2)
dateLocalestring'en-US'Locale for dates and times (BCP 47 language tag)
use24HourTimebooleanfalseUse 24-hour time
showTimezonebooleantrueShow the time zone in dates and times
JavaScript
{
defaultCountry: 'US',
dateLocale: 'en-US',
use24HourTime: false,
showTimezone: true,
}

Layout variants​

layoutVariant sets spacing density: 'compact' for tight spaces such as a side panel, 'default', or 'comfortable' for more breathing room.

TypeScript
<CallHistory phoneNumber="+14155551234" layoutVariant="compact" />

Pagination​

The list components page through their data for you. You never handle cursors or page state:

  • Call logs show Previous and Next controls under the table. limit sets the page size (default 10).
  • Voicemails load 20 at a time, with a Load more button at the end of the list.
  • Phone numbers load the whole account up front, then page client-side with Previous and Next. limit sets the page size (default 10).
  • Call history is not paginated. It shows the most recent calls, up to limit (default 5, maximum 20).

To page through the same data yourself, see Pagination.

The CallLog model​

Call logs and call history render CallLog records, and CallLogs passes one to onRowClick and to a custom row renderer. These are the fields you are most likely to use:

TypeScript
interface CallLog {
id: string;
direction: 'inbound' | 'outbound' | 'internal';
from_number: string;
from_label: string | null; // caller's display name, when known
to_number: string | null; // null while an inbound call is still in progress
to_label: string | null;
started_at: string; // ISO 8601
answered_at: string | null;
connected_at: string | null;
ended_at: string | null;
duration_seconds: number | null;
status: 'completed' | 'no-answer' | 'busy' | 'failed' | 'voicemail' | null; // null while live
summary: string | null; // AI-generated summary
recording_url: string | null;
// …plus user, did, related_call, sentiment, quality_metrics and more
}

The full type is in the SDK reference.

Next steps​