React Spectrum provides components for building AI-powered experiences, including prompts, messages, suggestions, attachments, and voice input.
Responses are generated using AI, and may be inaccurate. Check before using. AI User Guidelines
import {useState, useRef} from 'react';
import {
AttachFileMenuItem,
CommandMenuItem,
InsertTokenMenuItem,
InsertMenuButton,
PromptField,
Attachment,
AttachmentPreview,
PromptFieldAttachment,
PromptFieldAttachmentList,
PromptFieldSubmitButton,
PromptFieldToolbar,
PromptFieldValue,
PromptFieldVoiceButton,
PromptToken,
PromptTokenField
} from '@react-spectrum/ai';
import {type FocusableRefValue} from '@react-types/shared';
import {getIcon, slashCommands, objects, renderCompletions, suggestions, type UploadState} from './ai-component-helpers/promptfield';
import {style} from '@react-spectrum/s2/style' with {type: 'macro'};
import {Collection, SubmenuTrigger, Menu, MenuItem, MenuSection, Header, Heading, Text} from '@react-spectrum/s2';
import Data from '@react-spectrum/s2/icons/Data';
import Plugin from '@react-spectrum/s2/icons/Plugin';
import Prompt from '@react-spectrum/s2/icons/Prompt';
import {VirtualizedStreamingChat} from './ai-component-helpers/chat';
function Example() {
let [value, setValue] = useState<PromptFieldValue>(() => new PromptFieldValue([]));
let promptFieldRef = useRef<FocusableRefValue<HTMLDivElement>>(null);
let [attachments, setAttachments] = useState<PromptFieldAttachment[]>([]);
let [attachmentState, setAttachmentState] = useState<Map<string, UploadState>>(new Map());
let mockUpload = async (id: string) => {
await new Promise(resolve => setTimeout(resolve, Math.random() * 30));
setAttachmentState(prev => {
let item = prev.get(id);
if (!item || item.status === 'completed') {
return prev;
}
let newState = new Map(prev);
let progress = (item.progress ?? 0) + 1;
if (progress >= 100) {
newState.set(id, {status: 'completed'});
} else {
newState.set(id, {status: 'uploading', progress});
mockUpload(id);
}
return newState;
});
};
let clearPrompt = () => {
setValue(new PromptFieldValue([]));
setAttachments([]);
alert('Conversation cleared');
};
let compactPrompt = () => {
alert('Conversation compacted');
};
return (
<div className={style({height: 700, width: 'full'})}>
<VirtualizedStreamingChat
suggestions={suggestions}
onSelectSuggestion={value => {
setValue(value as PromptFieldValue);
promptFieldRef.current?.focus();
}}>
{(onSend, isGenerating) => (
<PromptField
ref={promptFieldRef}
value={value}
onChange={setValue}
attachments={attachments}
onAttachmentsChange={setAttachments}
isGenerating={isGenerating}
onSubmit={prompt => {
onSend(prompt);
setValue(new PromptFieldValue([]));
setAttachments([]);
setAttachmentState(new Map());
}}
acceptedAttachmentTypes={['*/*']}
onAddAttachments={newAttachments => {
setAttachmentState(prev => {
let newState = new Map(prev);
newAttachments.forEach(attachment => {
newState.set(attachment.id, {status: 'uploading', progress: 0});
mockUpload(attachment.id);
});
return newState;
});
}}
onRemoveAttachments={removedAttachments => {
setAttachmentState(prev => {
let newState = new Map(prev);
removedAttachments.forEach(attachment => {
newState.delete(attachment.id);
});
return newState;
});
}}>
<PromptFieldAttachmentList dependencies={[attachmentState]}>
{attachment => {
let state = attachmentState.get(attachment.id);
return (
<Attachment uploadProgress={state?.status === 'uploading' ? state?.progress : undefined}>
<AttachmentPreview mimeType={attachment.file.type} src={attachment.image} />
</Attachment>
);
}}
</PromptFieldAttachmentList>
<PromptTokenField
completionTrigger={/(?<=^|\s)[@/]/}
menuWidth={200}
renderCompletions={(filterValue, valueType) => {
return renderCompletions(filterValue, {valueType, onClear: clearPrompt, onCompact: compactPrompt});
}}>
{token => (
<PromptToken token={token}>
{getIcon(token)}
{token.text}
</PromptToken>
)}
</PromptTokenField>
<PromptFieldToolbar>
<div className={style({display: 'flex', gap: 8, alignItems: 'center'})}>
<InsertMenuButton>
<AttachFileMenuItem />
<SubmenuTrigger>
<MenuItem>
<Prompt />
<Text>Commands</Text>
</MenuItem>
<Menu items={slashCommands.filter(item => item.kind === 'command')}>
{item => (
<CommandMenuItem
id={item.command}
onAction={item.command === '/clear' ? clearPrompt : compactPrompt}>
<Prompt />
<Text slot="label">{item.command}</Text>
<Text slot="description">{item.description}</Text>
</CommandMenuItem>
)}
</Menu>
</SubmenuTrigger>
<SubmenuTrigger>
<MenuItem>
<Plugin />
<Text>Skills</Text>
</MenuItem>
<Menu items={slashCommands.filter(item => item.kind === 'skill')}>
{item => (
<InsertTokenMenuItem
id={item.command}
token={{
type: 'token',
text: item.command,
value: {type: 'custom', anchor: '/', valueType: item.kind, data: item}
}}>
<Plugin />
<Text slot="label">{item.command}</Text>
<Text slot="description">{item.description}</Text>
</InsertTokenMenuItem>
)}
</Menu>
</SubmenuTrigger>
<SubmenuTrigger>
<MenuItem>
<Data />
<Text>Reference an object</Text>
</MenuItem>
<Menu items={objects}>
{item => (
<MenuSection>
<Header>
<Heading>{item.section}</Heading>
</Header>
<Collection items={item.items}>
{item => (
<InsertTokenMenuItem
id={item.title}
token={{
type: 'token',
text: item.title,
value: {type: 'custom', anchor: '@', valueType: item.kind, data: item}
}}>
{item.title}
</InsertTokenMenuItem>
)}
</Collection>
</MenuSection>
)}
</Menu>
</SubmenuTrigger>
</InsertMenuButton>
</div>
<div className={style({display: 'flex', gap: 8, alignItems: 'center'})}>
<PromptFieldVoiceButton />
<PromptFieldSubmitButton />
</div>
</PromptFieldToolbar>
</PromptField>
)}
</VirtualizedStreamingChat>
</div>
);
}
Installation
AI components are published as a separate package from @react-spectrum/s2.
npm install @react-spectrum/ai
Prompt fields
Use PromptField as the foundation for allowing the user to submit a prompt. It manages an editable sequence of text and tokens, while PromptTokenField renders the input and PromptFieldToolbar contains its actions.
Responses are generated using AI, and may be inaccurate. Check before using. AI User Guidelines
Suggestions and tokens
Suggestions can prefill a prompt, and a token field can offer context-aware completions such as mentions or commands.
Try asking
Responses are generated using AI, and may be inaccurate. Check before using. AI User Guidelines
import {useState} from 'react';
import {
InsertTokenMenuItem,
MessageSuggestion,
MessageSuggestionList,
PromptField,
PromptFieldSubmitButton,
PromptFieldToolbar,
PromptFieldValue,
PromptTokenField
} from '@react-spectrum/ai';
import {style} from '@react-spectrum/s2/style' with {type: 'macro'};
let people = ['Customers', 'Designers', 'Developers'];
let suggestions = [
new PromptFieldValue([{type: 'text', text: 'Summarize this report'}]),
new PromptFieldValue([
{type: 'text', text: 'Draft a project brief for '},
{
type: 'token',
text: 'Designers',
value: {type: 'custom', anchor: '@', valueType: 'person', data: 'Designers'}
}
]),
new PromptFieldValue([{type: 'text', text: 'Find risks in this plan'}])
];
function PromptSuggestions() {
let [value, setValue] = useState<PromptFieldValue>(() => new PromptFieldValue([]));
return (
<div style={{display: 'flex', flexDirection: 'column', gap: 16}}>
<MessageSuggestionList title="Try asking">
{suggestions.map((suggestion, i) => (
<MessageSuggestion key={i} onPress={() => setValue(suggestion)}>
{suggestion.segments.map((segment, j) =>
segment.type === 'token' ? (
<span key={j} className={suggestionToken}>{segment.text}</span>
) : (
segment.text
)
)}
</MessageSuggestion>
))}
</MessageSuggestionList>
<PromptField value={value} onChange={setValue} onSubmit={console.log}>
<PromptTokenField
completionTrigger={/(?<=^|\s)@/}
menuWidth={200}
renderCompletions={filterValue =>
people
.filter(person => person.toLowerCase().includes(filterValue.slice(1).toLowerCase()))
.map(person => (
<InsertTokenMenuItem
key={person}
id={person}
token={{
type: 'token',
text: person,
value: {type: 'custom', anchor: '@', valueType: 'person', data: person}
}}>
{person}
</InsertTokenMenuItem>
))
}
placeholder="Ask about @customers" />
<PromptFieldToolbar>
<div style={{marginInlineStart: 'auto'}}>
<PromptFieldSubmitButton />
</div>
</PromptFieldToolbar>
</PromptField>
</div>
);
}
Attachments and actions
Use PromptFieldAttachmentList to render a preview of attached files the user has dragged onto the PromptField or added via the InsertMenuButton in the toolbar. Wrap the attachment list and a LightboxCarousel in a LightboxTrigger to let users activate an attachment to see images in a larger preview and browse attached files. Non-image files display a placeholder with their filename and file type. Custom menu items and toolbar controls can be added as well.
Responses are generated using AI, and may be inaccurate. Check before using. AI User Guidelines
Chat threads
Compose a conversation from Chat, Thread, ResponseStatus, Alert, and message components. The thread can be driven by a collection as messages arrive from your application.
import {Alert, AttachmentGrid, AttachmentGridItem, AttachmentPreview, Chat, Thread, ThreadItem, UserMessage, ResponseStatus, ResponseStatusTitle, ResponseStatusPanel, ExecutionTrace, ExecutionTraceItem, LightboxTrigger, LightboxCarousel, LightboxPicker, LightboxPickerItem, LightboxItems, LightboxItem} from '@react-spectrum/ai';
import {Image} from '@react-spectrum/s2';
import {prose} from '@react-spectrum/ai/style' with {type: 'macro'};
import {style} from '@react-spectrum/s2/style' with {type: 'macro'};
let attachmentImages = [
{
name: 'Desert Sunset.png',
mimeType: 'image/png',
src: 'https://images.unsplash.com/photo-1705034598432-1694e203cdf3?q=80&w=600&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D'
},
{
name: 'Hiking Trail.jpeg',
mimeType: 'image/jpeg',
src: 'https://images.unsplash.com/photo-1722233987129-61dc344db8b6?q=80&w=600&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D'
},
{
name: 'Lion.jpeg',
mimeType: 'image/jpeg',
src: 'https://images.unsplash.com/photo-1629812456605-4a044aa38fbc?q=80&w=600&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D'
},
{
name: 'Mountain Sunrise.png',
mimeType: 'image/png',
src: 'https://images.unsplash.com/photo-1722172118908-1a97c312ce8c?q=80&w=600&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D'
},
{
name: 'Peeking Leopard.jpeg',
mimeType: 'image/jpeg',
src: 'https://images.unsplash.com/photo-1456926631375-92c8ce872def?q=80&w=600&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D'
}
];
let messages = [
{
id: 1,
type: 'user',
text: 'Summarize the campaign results.'
},
{
id: 2,
type: 'status',
status: 'success' as const,
text: 'Response complete',
steps: [
{id: 1, label: 'Fetching campaign', status: 'success' as const, detail: 'Loaded campaign details and fetched engagement results from the database.'},
{id: 2, label: 'Summarizing results', status: 'success' as const, detail: 'Created a full channel report and summarized the results.'}
]
},
{
id: 3,
type: 'assistant',
text: 'Engagement increased 18% this month, led by email and social. See the full report for a channel breakdown.',
content: (
<>
Engagement increased <strong>18%</strong> this month, led by email and social. See the{' '}
<a href="#">full report</a> for a channel breakdown.
</>
)
},
{id: 4, type: 'user', text: 'Which channel performed best?'},
{
id: 5,
type: 'assistant',
text: 'Email drove the most conversions, with social close behind: Email with 4,200 conversions, Social with 3,100 conversions.',
content: (
<>
<p>Email drove the most conversions, with social close behind:</p>
<ul>
<li>Email: 4,200 conversions</li>
<li>Social: 3,100 conversions</li>
</ul>
</>
)
},
{
id: 6,
type: 'user',
text: 'I want to use the following images in future campaigns.',
attachments: Array.from({length: 20}, (_, i) => ({
id: i + 1,
...attachmentImages[i % attachmentImages.length]
}))
},
{
id: 7,
type: 'alert',
variant: 'notice' as const,
text: "This summary may be incomplete. The connected data source hasn't synced in 2 hours."
}
];
function BasicChat() {
return (
<div className={style({height: 450, width: 'full'})}>
<Chat>
<Thread
items={messages}
aria-label="Campaign discussion">
{message => {
switch (message.type) {
case 'user':
return (
<ThreadItem
textValue={message.text}
styles={style({display: 'flex', justifyContent: 'end'})}>
<UserMessage>
<div className={style({display: 'flex', flexDirection: 'column', gap: 12})}>
{message.attachments && (
<LightboxTrigger>
<AttachmentGrid
aria-label="Uploaded files"
align="end"
styles={style({maxWidth: 380, height: 128})}>
{message.attachments.map(attachment => (
<AttachmentGridItem key={attachment.id} id={attachment.id} aria-label={attachment.name} textValue={attachment.name}>
<AttachmentPreview
mimeType={attachment.mimeType}
slot="thumbnail"
src={attachment.src}
/>
</AttachmentGridItem>
))}
</AttachmentGrid>
<LightboxCarousel aria-label="Attachment preview">
<LightboxPicker aria-label="Choose attachment">
{message.attachments.map(attachment => (
<LightboxPickerItem key={attachment.id} id={attachment.id} aria-label={attachment.name}>
<Image src={attachment.src} alt="" />
</LightboxPickerItem>
))}
</LightboxPicker>
<LightboxItems>
{message.attachments.map(attachment => (
<LightboxItem key={attachment.id} id={attachment.id}>
<Image src={attachment.src} alt={attachment.name} />
</LightboxItem>
))}
</LightboxItems>
</LightboxCarousel>
</LightboxTrigger>
)}
<div>{message.text}</div>
</div>
</UserMessage>
</ThreadItem>
);
case 'assistant':
return (
<ThreadItem textValue={message.text}>
<div className={prose()}>{message.content}</div>
</ThreadItem>
);
case 'status':
return (
<ThreadItem textValue={message.text}>
<ResponseStatus status={message.status}>
<ResponseStatusTitle>{message.text}</ResponseStatusTitle>
<ResponseStatusPanel>
<ExecutionTrace>
{message.steps?.map(step => (
<ExecutionTraceItem
key={step.id}
status={step.status}
detail={<p className={style({font: 'body-sm', margin: 0})}>{step.detail}</p>}>
{step.label}
</ExecutionTraceItem>
))}
</ExecutionTrace>
</ResponseStatusPanel>
</ResponseStatus>
</ThreadItem>
);
case 'alert':
return (
<ThreadItem textValue={message.text}>
<Alert variant={message.variant} >
{message.text}
</Alert>
</ThreadItem>
)
}
}}
</Thread>
</Chat>
</div>
);
}
Loaders
PixelLoader is the animated pixel icon shown inside PromptField and ResponseStatus while the assistant is working. It can also be used standalone anywhere an AI loading indicator is needed.
The icon prop accepts either a single icon, which loops forever, or a themed preset, which cycles through several icons, one per loop. Icons and presets are exported individually from @react-spectrum/ai/loader.
Usage
Use the pixelLoader prop on ResponseStatusTitle and PromptTokenField to display the pixel loader.
import {cc} from '@react-spectrum/ai/loader';
import {ResponseStatus, ResponseStatusTitle} from '@react-spectrum/ai';
import {style} from '@react-spectrum/s2/style' with {type: 'macro'};
function LoadingStatus() {
return (
<div className={style({height: 40})}>
<ResponseStatus status="pending">
<ResponseStatusTitle pixelLoader={cc}>Analyzing campaign data...</ResponseStatusTitle>
</ResponseStatus>
</div>
);
}
Available icons
AI buttons
AIButton triggers an AI-powered action, such as opening an assistant or generating content. It displays an AI icon alongside an optional label.
API
<Chat>
<Thread>
<ThreadItem />
</Thread>
<PromptField />
</Chat>
Chat
A Chat displays an accessible, streaming conversation between a user and an AI.
| Name | Type | |
|---|---|---|
styles | StyleString | |
Spectrum-defined styles, returned by the | ||
children | ReactNode | |
Children of the chat, such as Thread, PromptField, and ThreadScrollButton. | ||
Thread
<Thread>
<ThreadItem>
<UserMessage /> or <ResponseStatus /> or <MessageSuggestionList /> or assistant content
<MessageSource /> and/or <MessageFeedback />
</ThreadItem>
<ThreadLoadMoreItem />
</Thread>
A Thread shows a conversation within a Chat.
| Name | Type | Default |
|---|---|---|
styles | StyleString | Default: — |
Spectrum-defined styles, returned by the | ||
scrollEndThreshold | number | Default: 100
|
The maximum distance in px from the bottom of the content for the viewport to be considered "near the end". While near the end, appended content and streaming size changes will keep the viewport pinned to the latest output. | ||
children | ReactNode | | Default: — |
The contents of the collection. | ||
items | Iterable | Default: — |
Item objects in the collection. | ||
aria-label | string | Default: — |
Defines a string value that labels the current element. | ||
aria-labelledby | string | Default: — |
Identifies the element (or elements) that labels the current element. | ||
ThreadItem
A ThreadItem displays an individual chat message.
| Name | Type | |
|---|---|---|
styles | StyleString | |
Spectrum-defined styles, returned by the | ||
isStreaming | boolean | |
Whether or not the item's content is currently being streamed in. | ||
shouldAnnounceOnMount | boolean | |
Announce textValue on mount even when isStreaming is provided. | ||
children | ReactNode | |
The content to display in the ThreadItem. | ||
id | Key | |
The unique id of the item. | ||
textValue | string | |
A string representation of the item's contents, used for features like typeahead. | ||
focusMode | 'child' | 'row' | |
Whether the row or its first focusable child element should be focused when navigating to the row. Defaults to 'row'. | ||
allowsArrowNavigation | boolean | |
Whether the row should support arrow key navigation even when the containing collection uses tab keyboard navigation. Allows users to navigate between rows with arrow keys while focus is on an interactive child element within the row. | ||
ThreadLoadMoreItem
A ThreadLoadMoreItem loads more chat messages when it is scrolled into the viewport.
| Name | Type | Default |
|---|---|---|
children | ReactNode | Default: — |
The load more spinner to render when loading additional items. | ||
isLoading | boolean | Default: — |
Whether or not the loading spinner should be rendered or not. | ||
scrollOffset | number | Default: 1
|
The amount of offset from the bottom of your scrollable region that should trigger load more. Uses a percentage value relative to the scroll body's client height. Load more is then triggered when your current scroll position's distance from the bottom of the currently loaded list of items is less than or equal to the provided value. (e.g. 1 = 100% of the scroll region's height). | ||
onLoadMore | | Default: — |
Handler that is called when more items should be loaded, e.g. while scrolling near the bottom. | ||
style | CSSProperties | Default: — |
The inline style for the element. | ||
className | string | Default: 'react-aria-GridListLoadingIndicator'
|
The CSS className for the element. | ||
render | DOMRenderFunction | Default: — |
Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components. Requirements:
| ||
Default className: react-aria-GridListLoadingIndicator
UserMessage
UserMessage renders a single user-authored message in a conversational AI thread.
Pass slot="image" on an Image child to switch to a vertical layout with a full-width preview.
| Name | Type | |
|---|---|---|
children | ReactNode | |
The contents of the user message bubble. | ||
styles | StyleString | |
Spectrum-defined styles, returned by the | ||
id | string | |
The element's unique identifier. See MDN. | ||
aria-label | string | |
Defines a string value that labels the current element. | ||
aria-labelledby | string | |
Identifies the element (or elements) that labels the current element. | ||
aria-describedby | string | |
Identifies the element (or elements) that describes the object. | ||
aria-details | string | |
Identifies the element (or elements) that provide a detailed, extended description for the object. | ||
slot | string | null | |
A slot name for the component. Slots allow the component to receive props from a parent
component. An explicit | ||
AttachmentGrid
Use AttachmentGrid to display file attachments as a wrapping, vertically-scrolling grid of
thumbnails within a UserMessage. Unlike PromptFieldAttachmentList, it does not support selection or removal.
<AttachmentGrid aria-label="Uploaded files">
<AttachmentGridItem aria-label="file.pdf">
<AttachmentPreview mimeType="application/pdf" slot="thumbnail" src={src} />
</AttachmentGridItem>
</AttachmentGrid>
An AttachmentGrid displays file attachments as a wrapping, vertically-scrolling grid of thumbnails. Unlike AttachmentList, it does not support selection or removal.
| Name | Type | |
|---|---|---|
styles | StyleString | |
Spectrum-defined styles, returned by the | ||
children | ReactNode | | |
The contents of the collection. | ||
items | Iterable | |
Item objects in the collection. | ||
dependencies | ReadonlyArray | |
Values that should invalidate the item cache when using dynamic collections. | ||
align | 'start'
| 'center'
| 'end' | |
The alignment of attachments within the grid. | ||
onAction | | |
Handler that is called when a user performs an action on an item. The exact user event depends
on the collection's | ||
id | string | |
The element's unique identifier. See MDN. | ||
aria-label | string | |
Defines a string value that labels the current element. | ||
aria-labelledby | string | |
Identifies the element (or elements) that labels the current element. | ||
aria-describedby | string | |
Identifies the element (or elements) that describes the object. | ||
aria-details | string | |
Identifies the element (or elements) that provide a detailed, extended description for the object. | ||
AttachmentGridItem
AttachmentGridItem displays an individual file attachment thumbnail within an AttachmentGrid.
| Name | Type | |
|---|---|---|
size | 'XS'
| 'S'
| 'M'
| 'L'
| 'XL' | |
The size of the Card. | ||
uploadProgress | number | |
The upload progress percentage (0-100). Values under 100 render a loading state. | ||
children | ReactNode | |
The children of the AttachmentGridItem. | ||
styles | StyleString | |
Spectrum-defined styles, returned by the | ||
id | Key | |
The unique id of the item. | ||
textValue | string | |
A string representation of the item's contents, used for features like typeahead. | ||
isInvalid | boolean | |
Whether the attachment has an error. | ||
onAction | | |
Handler that is called when a user performs an action on the attachment. | ||
aria-label | string | |
Defines a string value that labels the current element. | ||
aria-labelledby | string | |
Identifies the element (or elements) that labels the current element. | ||
aria-describedby | string | |
Identifies the element (or elements) that describes the object. | ||
aria-details | string | |
Identifies the element (or elements) that provide a detailed, extended description for the object. | ||
ResponseStatus
<ResponseStatus>
<ResponseStatusTitle />
<ResponseStatusPanel>
<ExecutionTrace>
<ExecutionTraceItem />
</ExecutionTrace>
</ResponseStatusPanel>
</ResponseStatus>
A ResponseStatus indicates the progress of a system response while it is being generated and when it is complete. If a ResponseStatusPanel is provided, the title can be pressed to expand and collapse it.
| Name | Type | Default |
|---|---|---|
status | 'pending'
| 'failed'
| 'success' | Default: 'pending'
|
The current status of the response. | ||
children | ReactNode | Default: — |
The contents of the response status, consisting of a ResponseStatusTitle and ResponseStatusPanel. | ||
styles | StyleString | Default: — |
Spectrum-defined styles, returned by the | ||
id | Key | Default: — |
An id for the disclosure when used within a DisclosureGroup, matching the id used in
| ||
isDisabled | boolean | Default: — |
Whether the disclosure is disabled. | ||
isExpanded | boolean | Default: — |
Whether the disclosure is expanded (controlled). | ||
defaultExpanded | boolean | Default: — |
Whether the disclosure is expanded by default (uncontrolled). | ||
onExpandedChange | | Default: — |
Handler that is called when the disclosure's expanded state changes. | ||
slot | string | null | Default: — |
A slot name for the component. Slots allow the component to receive props from a parent
component. An explicit | ||
ResponseStatusTitle
A response status title consisting of a heading and a trigger button. The leading icon is a progress circle while loading and a chevron once complete and there is further content to display.
| Name | Type | Default |
|---|---|---|
level | number | Default: 3
|
The heading level of the response status header. | ||
children | string | Default: — |
The contents of the response status header. | ||
styles | StyleString | Default: — |
Spectrum-defined styles, returned by the | ||
pixelLoader | Cell | Default: — |
Pixel loader icon or sequence to display. | ||
id | string | Default: — |
The element's unique identifier. See MDN. | ||
ResponseStatusPanel
A response status panel is a collapsible section of content that is hidden until the response status is expanded.
| Name | Type | Default |
|---|---|---|
children | React.ReactNode | Default: — |
styles | StyleString | Default: — |
Spectrum-defined styles, returned by the | ||
labelElementType | ElementType | Default: 'label'
|
The HTML element used to render the label, e.g. 'label', or 'span'. | ||
label | ReactNode | Default: — |
The content to display as the label. | ||
role | 'group' | 'region' | Default: 'group'
|
The accessibility role for the disclosure's panel. | ||
id | string | Default: — |
The element's unique identifier. See MDN. | ||
aria-label | string | Default: — |
Defines a string value that labels the current element. | ||
aria-labelledby | string | Default: — |
Identifies the element (or elements) that labels the current element. | ||
aria-describedby | string | Default: — |
Identifies the element (or elements) that describes the object. | ||
aria-details | string | Default: — |
Identifies the element (or elements) that provide a detailed, extended description for the object. | ||
ExecutionTrace
An ExecutionTrace displays a timeline of the steps taken while generating a response, such as tool calls or searches.
| Name | Type | |
|---|---|---|
children | ReactNode | |
The ExecutionTraceItem elements to render as a timeline. Typically placed inside a ResponseStatusPanel. | ||
styles | StyleString | |
Spectrum-defined styles, returned by the | ||
id | string | |
The element's unique identifier. See MDN. | ||
aria-label | string | |
Defines a string value that labels the current element. | ||
aria-labelledby | string | |
Identifies the element (or elements) that labels the current element. | ||
aria-describedby | string | |
Identifies the element (or elements) that describes the object. | ||
aria-details | string | |
Identifies the element (or elements) that provide a detailed, extended description for the object. | ||
ExecutionTraceItem
An ExecutionTraceItem represents a single step within an ExecutionTrace, such as
a tool call or search. When a detail is provided, the row can be expanded to reveal it.
| Name | Type | Default |
|---|---|---|
children | string | Default: — |
The label describing the step. | ||
status | 'pending'
| 'failed'
| 'success' | Default: — |
The status of this step. | ||
detail | ReactNode | Default: — |
Additional detail revealed when the step is expanded, such as tool call input or output. If omitted, the row is static and cannot be expanded. | ||
detailMaxHeight | number | Default: 120
|
Maximum height for the detail panel. | ||
icon | ReactNode | Default: — |
An icon shown at the leading edge of the row. If omitted, a checkmark is rendered by default. | ||
styles | StyleString | Default: — |
Spectrum-defined styles, returned by the | ||
onExpandedChange | | Default: — |
Handler that is called when the trace is expanded or collapsed. | ||
id | string | Default: — |
The element's unique identifier. See MDN. | ||
aria-label | string | Default: — |
Defines a string value that labels the current element. | ||
aria-labelledby | string | Default: — |
Identifies the element (or elements) that labels the current element. | ||
aria-describedby | string | Default: — |
Identifies the element (or elements) that describes the object. | ||
aria-details | string | Default: — |
Identifies the element (or elements) that provide a detailed, extended description for the object. | ||
Alert
An Alert shows an error message within a Chat thread or PromptField.
| Name | Type | |
|---|---|---|
children | ReactNode | |
variant | 'informative'
| 'positive'
| 'notice'
| 'negative'
| 'neutral' | |
styles | StyleString | |
onDismiss | | |
id | string | |
The element's unique identifier. See MDN. | ||
aria-label | string | |
Defines a string value that labels the current element. | ||
aria-labelledby | string | |
Identifies the element (or elements) that labels the current element. | ||
aria-describedby | string | |
Identifies the element (or elements) that describes the object. | ||
aria-details | string | |
Identifies the element (or elements) that provide a detailed, extended description for the object. | ||
MessageSuggestionList
<MessageSuggestionList>
<MessageSuggestion />
</MessageSuggestionList>
MessageSuggestionList renders a group of suggestion responses with a title heading.
| Name | Type | |
|---|---|---|
children | ReactNode | |
The MessageSuggestion children to display. | ||
title | string | |
Heading displayed above the suggestions. | ||
size | 'S'
| 'M'
| 'L'
| 'XL' | |
The size of hte Buttons within the MessageSuggestionList. | ||
styles | StyleString | |
Spectrum-defined styles, returned by the | ||
id | string | |
The element's unique identifier. See MDN. | ||
aria-label | string | |
Defines a string value that labels the current element. | ||
aria-labelledby | string | |
Identifies the element (or elements) that labels the current element. | ||
aria-describedby | string | |
Identifies the element (or elements) that describes the object. | ||
aria-details | string | |
Identifies the element (or elements) that provide a detailed, extended description for the object. | ||
slot | string | null | |
A slot name for the component. Slots allow the component to receive props from a parent
component. An explicit | ||
MessageSuggestion
MessageSuggestion renders a single pressable suggestion in a conversation.
| Name | Type | Default |
|---|---|---|
children | ReactNode | Default: — |
The text content of the suggestion. | ||
size | 'S'
| 'M'
| 'L'
| 'XL' | Default: 'M'
|
The size of the MessageSuggestion. | ||
styles | StyleString | Default: — |
Spectrum-defined styles, returned by the | ||
onPress | | Default: — |
Handler that is called when the press is released over the target. | ||
onPressStart | | Default: — |
Handler that is called when a press interaction starts. | ||
onPressEnd | | Default: — |
Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target. | ||
onPressChange | | Default: — |
Handler that is called when the press state changes. | ||
onPressUp | | Default: — |
Handler that is called when a press is released over the target, regardless of whether it started on the target or not. | ||
onClick | | Default: — |
Not recommended – use | ||
onFocus | | Default: — |
Handler that is called when the element receives focus. | ||
onBlur | | Default: — |
Handler that is called when the element loses focus. | ||
onFocusChange | | Default: — |
Handler that is called when the element's focus status changes. | ||
onKeyDown | | Default: — |
Handler that is called when a key is pressed. | ||
onKeyUp | | Default: — |
Handler that is called when a key is released. | ||
onHoverStart | | Default: — |
Handler that is called when a hover interaction starts. | ||
onHoverEnd | | Default: — |
Handler that is called when a hover interaction ends. | ||
onHoverChange | | Default: — |
Handler that is called when the hover state changes. | ||
name | string | Default: — |
Submitted as a pair with the button's value as part of the form data. | ||
value | string | Default: — |
The value associated with the button's name when it's submitted with the form data. | ||
type | 'button'
| 'submit'
| 'reset' | Default: 'button'
|
The behavior of the button when used in an HTML form. | ||
form | string | Default: — |
The | ||
formTarget | string | Default: — |
Overrides the target attribute of the button's form owner. | ||
formNoValidate | boolean | Default: — |
Indicates that the form is not to be validated when it is submitted. | ||
formMethod | string | Default: — |
Indicates the HTTP method used to submit the form. | ||
formEncType | string | Default: — |
Indicates how to encode the form data that is submitted. | ||
formAction | ButtonHTMLAttributes | Default: — |
The URL that processes the information submitted by the button. Overrides the action attribute of the button's form owner. | ||
autoFocus | boolean | Default: — |
Whether the element should receive focus on render. | ||
id | string | Default: — |
The element's unique identifier. See MDN. | ||
excludeFromTabOrder | boolean | Default: — |
Whether to exclude the element from the sequential tab order. If true, the element will not be focusable via the keyboard by tabbing. This should be avoided except in rare scenarios where an alternative means of accessing the element or its functionality via the keyboard is available. | ||
preventFocusOnPress | boolean | Default: — |
Whether to prevent focus from moving to the button when pressing it. Caution, this can make the button inaccessible and should only be used when alternative keyboard interaction is provided, such as ComboBox's MenuTrigger or a NumberField's increment/decrement control. | ||
aria-disabled | boolean
| 'true'
| 'false' | Default: — |
Indicates whether the element is disabled to users of assistive technology. | ||
aria-expanded | boolean
| 'true'
| 'false' | Default: — |
Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed. | ||
aria-haspopup | boolean
| 'menu'
| 'listbox'
| 'tree'
| 'grid'
| 'dialog'
| 'true'
| 'false' | Default: — |
Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. | ||
aria-controls | string | Default: — |
Identifies the element (or elements) whose contents or presence are controlled by the current element. | ||
aria-pressed | boolean
| 'true'
| 'false'
| 'mixed' | Default: — |
Indicates the current "pressed" state of toggle buttons. | ||
aria-current | boolean
| 'true'
| 'false'
| 'page'
| 'step'
| 'location'
| 'date'
| 'time' | Default: — |
Indicates whether this element represents the current item within a container or set of related elements. | ||
aria-label | string | Default: — |
Defines a string value that labels the current element. | ||
aria-labelledby | string | Default: — |
Identifies the element (or elements) that labels the current element. | ||
aria-describedby | string | Default: — |
Identifies the element (or elements) that describes the object. | ||
aria-details | string | Default: — |
Identifies the element (or elements) that provide a detailed, extended description for the object. | ||
slot | string | null | Default: — |
A slot name for the component. Slots allow the component to receive props from a parent
component. An explicit | ||
MessageFeedback
MessageFeedback collects thumbs up / thumbs down feedback on an AI response.
| Name | Type | Default |
|---|---|---|
isDisabled | boolean | Default: — |
Whether the feedback controls are disabled. | ||
thumbUpLabel | string | Default: — |
Accessible label for the thumbs up button. | ||
thumbDownLabel | string | Default: — |
Accessible label for the thumbs down button. | ||
styles | StylesPropWithHeight | Default: — |
Spectrum-defined styles, returned by the | ||
size | 'XS'
| 'S'
| 'M'
| 'L'
| 'XL' | Default: 'M'
|
Size of the buttons. | ||
value | MessageFeedbackValue | Default: — |
The selected feedback value (controlled). | ||
defaultValue | MessageFeedbackValue | Default: — |
The default feedback value (uncontrolled). | ||
onChange | | Default: — |
Called when the selection changes, including when toggled off (value=null). | ||
id | string | Default: — |
The element's unique identifier. See MDN. | ||
aria-label | string | Default: — |
Defines a string value that labels the current element. | ||
aria-labelledby | string | Default: — |
Identifies the element (or elements) that labels the current element. | ||
aria-describedby | string | Default: — |
Identifies the element (or elements) that describes the object. | ||
aria-details | string | Default: — |
Identifies the element (or elements) that provide a detailed, extended description for the object. | ||
slot | string | null | Default: — |
A slot name for the component. Slots allow the component to receive props from a parent
component. An explicit | ||
MessageSource
<MessageSource>
<SourceList>
<SourceListItem />
</SourceList>
</MessageSource>
Message sources display references associated with a system message. Associating the source to the output builds trust and transparency in the conversation.
| Name | Type | Default |
|---|---|---|
size | 'S'
| 'M'
| 'L'
| 'XL' | Default: 'M'
|
The size of the disclosure. | ||
density | 'compact'
| 'regular'
| 'spacious' | Default: 'regular'
|
The amount of space between the disclosures. | ||
children | ReactNode | Default: — |
The contents of the disclosure, consisting of a DisclosureTitle and DisclosurePanel. | ||
id | Key | Default: — |
An id for the disclosure when used within a DisclosureGroup, matching the id used in
| ||
isDisabled | boolean | Default: — |
Whether the disclosure is disabled. | ||
isExpanded | boolean | Default: — |
Whether the disclosure is expanded (controlled). | ||
defaultExpanded | boolean | Default: — |
Whether the disclosure is expanded by default (uncontrolled). | ||
styles | StylesProp | Default: — |
Spectrum-defined styles, returned by the | ||
label | string | Default: — |
onExpandedChange | | Default: — |
Handler that is called when the disclosure's expanded state changes. | ||
slot | string | null | Default: — |
A slot name for the component. Slots allow the component to receive props from a parent
component. An explicit | ||
SourceList
A SourceList displays an ordered list of sources inside a MessageSource. Wrap SourceListItem children inside to have them numbered automatically.
| Name | Type | Default |
|---|---|---|
children | React.ReactNode | Default: — |
labelElementType | ElementType | Default: 'label'
|
The HTML element used to render the label, e.g. 'label', or 'span'. | ||
label | ReactNode | Default: — |
The content to display as the label. | ||
role | 'group' | 'region' | Default: 'group'
|
The accessibility role for the disclosure's panel. | ||
id | string | Default: — |
The element's unique identifier. See MDN. | ||
aria-label | string | Default: — |
Defines a string value that labels the current element. | ||
aria-labelledby | string | Default: — |
Identifies the element (or elements) that labels the current element. | ||
aria-describedby | string | Default: — |
Identifies the element (or elements) that describes the object. | ||
aria-details | string | Default: — |
Identifies the element (or elements) that provide a detailed, extended description for the object. | ||
UNSAFE_className | UnsafeClassName | Default: — |
Sets the CSS className
for the element. Only use as a last resort. Use the | ||
UNSAFE_style | CSSProperties | Default: — |
Sets inline style for the
element. Only use as a last resort. Use the | ||
SourceListItem
A SourceListItem represents a single source within a SourceList. The item number is provided automatically by the parent SourceList.
| Name | Type | |
|---|---|---|
children | React.ReactNode | |
The content of the source list item. | ||
styles | StyleString | |
Spectrum-defined styles, returned by the | ||
isDisabled | boolean | |
Whether the link is disabled. | ||
onPress | | |
Handler that is called when the press is released over the target. | ||
onPressStart | | |
Handler that is called when a press interaction starts. | ||
onPressEnd | | |
Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target. | ||
onPressChange | | |
Handler that is called when the press state changes. | ||
onPressUp | | |
Handler that is called when a press is released over the target, regardless of whether it started on the target or not. | ||
onClick | | |
Not recommended – use | ||
onFocus | | |
Handler that is called when the element receives focus. | ||
onBlur | | |
Handler that is called when the element loses focus. | ||
onFocusChange | | |
Handler that is called when the element's focus status changes. | ||
onKeyDown | | |
Handler that is called when a key is pressed. | ||
onKeyUp | | |
Handler that is called when a key is released. | ||
onHoverStart | | |
Handler that is called when a hover interaction starts. | ||
onHoverEnd | | |
Handler that is called when a hover interaction ends. | ||
onHoverChange | | |
Handler that is called when the hover state changes. | ||
href | Href | |
A URL to link to. See MDN. | ||
hrefLang | string | |
Hints at the human language of the linked URL. SeeMDN. | ||
target | HTMLAttributeAnchorTarget | |
The target window for the link. See MDN. | ||
rel | string | |
The relationship between the linked resource and the current page. See MDN. | ||
download | boolean | string | |
Causes the browser to download the linked URL. A string may be provided to suggest a file name. See MDN. | ||
ping | string | |
A space-separated list of URLs to ping when the link is followed. See MDN. | ||
referrerPolicy | HTMLAttributeReferrerPolicy | |
How much of the referrer to send when following the link. See MDN. | ||
routerOptions | RouterOptions | |
Options for the configured client side router. | ||
autoFocus | boolean | |
Whether the element should receive focus on render. | ||
id | string | |
The element's unique identifier. See MDN. | ||
aria-current | boolean
| 'true'
| 'false'
| 'page'
| 'step'
| 'location'
| 'date'
| 'time' | |
Indicates whether this element represents the current item within a container or set of related elements. | ||
aria-label | string | |
Defines a string value that labels the current element. | ||
aria-labelledby | string | |
Identifies the element (or elements) that labels the current element. | ||
aria-describedby | string | |
Identifies the element (or elements) that describes the object. | ||
aria-details | string | |
Identifies the element (or elements) that provide a detailed, extended description for the object. | ||
slot | string | null | |
A slot name for the component. Slots allow the component to receive props from a parent
component. An explicit | ||
PromptField
<PromptField>
<PromptFieldAttachmentList />
<PromptTokenField />
<PromptFieldToolbar />
</PromptField>
A PromptField allows users to compose and submit prompts containing text, tokens, and attachments.
| Name | Type | Default |
|---|---|---|
children | React.ReactNode | Default: — |
acceptedAttachmentTypes | string | Default: — |
attachments | PromptFieldAttachment | Default: — |
defaultAttachments | PromptFieldAttachment | Default: — |
isGenerating | boolean | Default: — |
styles | StyleString | Default: — |
variant | 'balanced'
| 'prominent'
| 'subtle' | Default: 'balanced'
|
brandColor | string | Default: — |
size | 'S' | 'M' | Default: 'M'
|
The size of the PromptField. | ||
aiDisclaimer | React.ReactNode | Default: — |
Custom text for the AI usage disclaimer shown below the prompt field. | ||
value | PromptFieldValue | Default: — |
defaultValue | PromptFieldValue | Default: — |
onChange | | Default: — |
onAttachmentsChange | | Default: — |
onSubmit | | Default: — |
onStop | | Default: — |
onAddAttachments | | Default: — |
onRemoveAttachments | | Default: — |
onAITermsPress | | Default: — |
PromptFieldAttachmentList
<PromptFieldAttachmentList>
{attachment => (
<Attachment>
<AttachmentPreview />
</Attachment>
)}
</PromptFieldAttachmentList>
PromptFieldAttachmentList displays a list of file attachments within a PromptField.
| Name | Type | |
|---|---|---|
styles | StyleString | |
Spectrum-defined styles, returned by the | ||
children | | |
items | Iterable | |
Item objects in the collection. | ||
dependencies | ReadonlyArray | |
Values that should invalidate the item cache when using dynamic collections. | ||
disabledKeys | Iterable | |
The item keys that are disabled. These items cannot be selected, focused, or otherwise interacted with. | ||
onRemove | | |
Handler that is called when a user deletes a tag. | ||
onAction | | |
Handler that is called when a user performs an action on an item. The exact user event depends
on the collection's | ||
id | string | |
The element's unique identifier. See MDN. | ||
aria-label | string | |
Defines a string value that labels the current element. | ||
aria-labelledby | string | |
Identifies the element (or elements) that labels the current element. | ||
aria-describedby | string | |
Identifies the element (or elements) that describes the object. | ||
aria-details | string | |
Identifies the element (or elements) that provide a detailed, extended description for the object. | ||
slot | string | null | |
A slot name for the component. Slots allow the component to receive props from a parent
component. An explicit | ||
Attachment
Attachment displays an individual file attachment within a PromptFieldAttachmentList.
| Name | Type | Default |
|---|---|---|
children | ReactNode | Default: — |
The children of the Attachment. | ||
uploadProgress | number | Default: — |
styles | StyleString | Default: — |
Spectrum-defined styles, returned by the | ||
size | 'XS'
| 'S'
| 'M'
| 'L'
| 'XL' | Default: 'M'
|
The size of the Card. | ||
density | 'compact'
| 'regular'
| 'spacious' | Default: 'regular'
|
The amount of internal padding within the Card. | ||
variant | 'primary'
| 'secondary'
| 'tertiary'
| 'quiet' | Default: 'primary'
|
The visual style of the Card. | ||
id | Key | Default: — |
The unique id of the item. | ||
value | T | Default: — |
The object value that this item represents. When using dynamic collections, this is set automatically. | ||
textValue | string | Default: — |
A string representation of the item's contents, used for features like typeahead. | ||
isDisabled | boolean | Default: — |
Whether the item is disabled. | ||
isInvalid | boolean | Default: — |
Whether the attachment has an error. | ||
onAction | | Default: — |
Handler that is called when a user performs an action on the item. The exact user event depends
on the collection's | ||
onPress | | Default: — |
Handler that is called when the press is released over the target. | ||
onPressStart | | Default: — |
Handler that is called when a press interaction starts. | ||
onPressEnd | | Default: — |
Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target. | ||
onPressChange | | Default: — |
Handler that is called when the press state changes. | ||
onPressUp | | Default: — |
Handler that is called when a press is released over the target, regardless of whether it started on the target or not. | ||
onFocus | | Default: — |
Handler that is called when the element receives focus. | ||
onBlur | | Default: — |
Handler that is called when the element loses focus. | ||
onFocusChange | | Default: — |
Handler that is called when the element's focus status changes. | ||
href | Href | Default: — |
A URL to link to. See MDN. | ||
hrefLang | string | Default: — |
Hints at the human language of the linked URL. SeeMDN. | ||
target | HTMLAttributeAnchorTarget | Default: — |
The target window for the link. See MDN. | ||
rel | string | Default: — |
The relationship between the linked resource and the current page. See MDN. | ||
download | boolean | string | Default: — |
Causes the browser to download the linked URL. A string may be provided to suggest a file name. See MDN. | ||
ping | string | Default: — |
A space-separated list of URLs to ping when the link is followed. See MDN. | ||
referrerPolicy | HTMLAttributeReferrerPolicy | Default: — |
How much of the referrer to send when following the link. See MDN. | ||
routerOptions | RouterOptions | Default: — |
Options for the configured client side router. | ||
aria-label | string | Default: — |
Defines a string value that labels the current element. | ||
aria-labelledby | string | Default: — |
Identifies the element (or elements) that labels the current element. | ||
aria-describedby | string | Default: — |
Identifies the element (or elements) that describes the object. | ||
aria-details | string | Default: — |
Identifies the element (or elements) that provide a detailed, extended description for the object. | ||
render | DOMRenderFunction | Default: — |
Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components. Requirements:
| ||
AttachmentPreview
AttachmentPreview renders a preview of a file attachment.
| Name | Type | |
|---|---|---|
mimeType | string | |
The MIME type of the attachment. Determines the fallback icon, and enables the file-type badge on large thumbnail variants. | ||
src | string | ImageSource | |
The URL of the image or a list of conditional sources. | ||
alt | string | |
Accessible alt text for the image. | ||
crossOrigin | 'anonymous' | 'use-credentials' | |
Indicates if the fetching of the image must be done using a CORS request. See MDN. | ||
decoding | 'async'
| 'auto'
| 'sync' | |
Whether the browser should decode images synchronously or asynchronously. See MDN. | ||
fetchPriority | 'high'
| 'low'
| 'auto' | |
Provides a hint of the relative priority to use when fetching the image. See MDN. | ||
loading | 'eager' | 'lazy' | |
Whether the image should be loaded immediately or lazily when scrolled into view. See MDN. | ||
width | number | |
The intrinsic width of the image. See MDN. | ||
height | number | |
The intrinsic height of the image. See MDN. | ||
styles | StyleString | |
Spectrum-defined styles, returned by the | ||
renderError | | |
A function that is called to render a fallback when the image fails to load. | ||
group | ImageGroup | |
A group of images to coordinate between, matching the group passed to the | ||
referrerPolicy | HTMLAttributeReferrerPolicy | |
A string indicating which referrer to use when fetching the resource. See MDN. | ||
itemProp | string | |
Associates the image with a microdata object. See MDN. | ||
UNSAFE_className | UnsafeClassName | |
Sets the CSS className
for the element. Only use as a last resort. Use the | ||
UNSAFE_style | CSSProperties | |
Sets inline style for the
element. Only use as a last resort. Use the | ||
slot | string | null | |
A slot name for the component. Slots allow the component to receive props from a parent
component. An explicit | ||
Lightbox
<LightboxTrigger>
<PromptFieldAttachmentList />
<LightboxCarousel>
<LightboxPicker>
<LightboxPickerItem id="image" />
</LightboxPicker>
<LightboxItems>
<LightboxItem id="image" />
</LightboxItems>
</LightboxCarousel>
</LightboxTrigger>
LightboxTrigger
Manages opening a modal lightbox and selecting which item to display.
| Name | Type | |
|---|---|---|
children | ReactNode | |
The children of the component. | ||
LightboxCarousel
Displays content in a carousel, either inline or in a modal when used within a LightboxTrigger.
| Name | Type | |
|---|---|---|
children | ReactNode | |
The children of the component. | ||
styles | StyleString | |
Spectrum-defined styles, returned by the | ||
onSelectionChange | | |
Handler that is called when the selection changes. | ||
id | string | |
The element's unique identifier. See MDN. | ||
aria-label | string | |
Defines a string value that labels the current element. | ||
aria-labelledby | string | |
Identifies the element (or elements) that labels the current element. | ||
aria-describedby | string | |
Identifies the element (or elements) that describes the object. | ||
aria-details | string | |
Identifies the element (or elements) that provide a detailed, extended description for the object. | ||
LightboxPicker
Displays a list of thumbnails for selecting an item in a lightbox carousel.
| Name | Type | |
|---|---|---|
styles | StyleString | |
Spectrum-defined styles, returned by the | ||
children | ReactNode | | |
The contents of the collection. | ||
items | Iterable | |
Item objects in the collection. | ||
dependencies | ReadonlyArray | |
Values that should invalidate the item cache when using dynamic collections. | ||
aria-label | string | |
Defines a string value that labels the current element. | ||
aria-labelledby | string | |
Identifies the element (or elements) that labels the current element. | ||
aria-describedby | string | |
Identifies the element (or elements) that describes the object. | ||
aria-details | string | |
Identifies the element (or elements) that provide a detailed, extended description for the object. | ||
LightboxPickerItem
A thumbnail that selects its corresponding item in a lightbox carousel.
| Name | Type | |
|---|---|---|
children | ReactNode | |
The children of the component. | ||
styles | StyleString | |
Spectrum-defined styles, returned by the | ||
id | Key | |
The unique id of the tab. | ||
aria-label | string | |
Defines a string value that labels the current element. | ||
aria-labelledby | string | |
Identifies the element (or elements) that labels the current element. | ||
aria-describedby | string | |
Identifies the element (or elements) that describes the object. | ||
aria-details | string | |
Identifies the element (or elements) that provide a detailed, extended description for the object. | ||
LightboxItems
Contains the items displayed in a lightbox carousel.
| Name | Type | |
|---|---|---|
children | ReactNode | |
The children of the component. | ||
styles | StyleString | |
Spectrum-defined styles, returned by the | ||
LightboxItem
Displays the content for an individual item in a lightbox carousel.
| Name | Type | |
|---|---|---|
children | ReactNode | |
The children of the component. | ||
styles | StyleString | |
Spectrum-defined styles, returned by the | ||
id | Key | |
The unique id of the tab. | ||
aria-label | string | |
Defines a string value that labels the current element. | ||
aria-labelledby | string | |
Identifies the element (or elements) that labels the current element. | ||
aria-describedby | string | |
Identifies the element (or elements) that describes the object. | ||
aria-details | string | |
Identifies the element (or elements) that provide a detailed, extended description for the object. | ||
PromptTokenField
<PromptTokenField>
{token => <PromptToken token={token} />}
</PromptTokenField>
PromptTokenField renders an editable text input for a prompt, and supports inserting inline object references as tokens via autocomplete.
| Name | Type | |
|---|---|---|
completionTrigger | RegExp | |
renderCompletions | | |
children | | |
pixelLoader | Cell | |
shouldAnimatePixelLoader | boolean | |
placeholder | string | |
menuWidth | number | |
onKeyDown | | |
onKeyUp | | |
PromptToken
A PromptToken displays a non-editable inline object reference within a PromptTokenField.
| Name | Type |
|---|---|
token | TokenSegment |
children | React.ReactNode |
PromptFieldToolbar
<PromptFieldToolbar>
<InsertMenuButton>
<AttachFileMenuItem />
<SubmenuTrigger>
<InsertTextMenuItem /> or <InsertTokenMenuItem /> or <CommandMenuItem />
<Menu />
</SubmenuTrigger>
</InsertMenuButton>
<PromptFieldVoiceButton />
<PromptFieldSubmitButton />
</PromptFieldToolbar>
PromptFieldToolbar contains action buttons related to the PromptField.
| Name | Type |
|---|---|
children | React.ReactNode |
InsertMenuButton
InsertMenuButton renders an ActionButton with a plus icon that opens a menu.
| Name | Type | |
|---|---|---|
children | React.ReactNode | |
onOpenChange | | |
Handler that is called when the overlay's open state changes. | ||
AttachFileMenuItem
AttachFileMenuItem triggers a system file dialog to attach files within an InsertMenuButton.
| Name | Type | |
|---|---|---|
id | Key | |
The unique id of the item. | ||
value | T | |
The object value that this item represents. When using dynamic collections, this is set automatically. | ||
textValue | string | |
A string representation of the item's contents, used for features like typeahead. | ||
isDisabled | boolean | |
Whether the item is disabled. | ||
styles | StylesProp | |
Spectrum-defined styles, returned by the | ||
shouldCloseOnSelect | boolean | |
Whether the menu should close when the menu item is selected. | ||
onAction | | |
Handler that is called when the item is selected. | ||
onHoverStart | | |
Handler that is called when a hover interaction starts. | ||
onHoverEnd | | |
Handler that is called when a hover interaction ends. | ||
onHoverChange | | |
Handler that is called when the hover state changes. | ||
onFocus | | |
Handler that is called when the element receives focus. | ||
onBlur | | |
Handler that is called when the element loses focus. | ||
onFocusChange | | |
Handler that is called when the element's focus status changes. | ||
onPress | | |
Handler that is called when the press is released over the target. | ||
onPressStart | | |
Handler that is called when a press interaction starts. | ||
onPressEnd | | |
Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target. | ||
onPressChange | | |
Handler that is called when the press state changes. | ||
onPressUp | | |
Handler that is called when a press is released over the target, regardless of whether it started on the target or not. | ||
aria-label | string | |
An accessibility label for this item. | ||
InsertTextMenuItem
InsertTextMenuItem inserts plain text into the PromptField from within an InsertMenuButton.
| Name | Type | |
|---|---|---|
text | string | |
children | ReactNode | |
The contents of the item. | ||
id | Key | |
The unique id of the item. | ||
textValue | string | |
A string representation of the item's contents, used for features like typeahead. | ||
isDisabled | boolean | |
Whether the item is disabled. | ||
styles | StylesProp | |
Spectrum-defined styles, returned by the | ||
shouldCloseOnSelect | boolean | |
Whether the menu should close when the menu item is selected. | ||
onAction | | |
Handler that is called when the item is selected. | ||
onHoverStart | | |
Handler that is called when a hover interaction starts. | ||
onHoverEnd | | |
Handler that is called when a hover interaction ends. | ||
onHoverChange | | |
Handler that is called when the hover state changes. | ||
onFocus | | |
Handler that is called when the element receives focus. | ||
onBlur | | |
Handler that is called when the element loses focus. | ||
onFocusChange | | |
Handler that is called when the element's focus status changes. | ||
onPress | | |
Handler that is called when the press is released over the target. | ||
onPressStart | | |
Handler that is called when a press interaction starts. | ||
onPressEnd | | |
Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target. | ||
onPressChange | | |
Handler that is called when the press state changes. | ||
onPressUp | | |
Handler that is called when a press is released over the target, regardless of whether it started on the target or not. | ||
aria-label | string | |
An accessibility label for this item. | ||
InsertTokenMenuItem
InsertTokenMenuItem inserts a token (i.e. object reference) into the PromptField within an InsertMenuButton.
| Name | Type | |
|---|---|---|
token | TokenSegment | |
children | ReactNode | |
The contents of the item. | ||
id | Key | |
The unique id of the item. | ||
textValue | string | |
A string representation of the item's contents, used for features like typeahead. | ||
isDisabled | boolean | |
Whether the item is disabled. | ||
styles | StylesProp | |
Spectrum-defined styles, returned by the | ||
shouldCloseOnSelect | boolean | |
Whether the menu should close when the menu item is selected. | ||
onAction | | |
Handler that is called when the item is selected. | ||
onHoverStart | | |
Handler that is called when a hover interaction starts. | ||
onHoverEnd | | |
Handler that is called when a hover interaction ends. | ||
onHoverChange | | |
Handler that is called when the hover state changes. | ||
onFocus | | |
Handler that is called when the element receives focus. | ||
onBlur | | |
Handler that is called when the element loses focus. | ||
onFocusChange | | |
Handler that is called when the element's focus status changes. | ||
onPress | | |
Handler that is called when the press is released over the target. | ||
onPressStart | | |
Handler that is called when a press interaction starts. | ||
onPressEnd | | |
Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target. | ||
onPressChange | | |
Handler that is called when the press state changes. | ||
onPressUp | | |
Handler that is called when a press is released over the target, regardless of whether it started on the target or not. | ||
aria-label | string | |
An accessibility label for this item. | ||
CommandMenuItem
CommandMenuItem performs an immediate action from within an InsertMenuButton.
| Name | Type | |
|---|---|---|
children | ReactNode | |
The contents of the item. | ||
id | Key | |
The unique id of the item. | ||
value | T | |
The object value that this item represents. When using dynamic collections, this is set automatically. | ||
textValue | string | |
A string representation of the item's contents, used for features like typeahead. | ||
isDisabled | boolean | |
Whether the item is disabled. | ||
styles | StylesProp | |
Spectrum-defined styles, returned by the | ||
shouldCloseOnSelect | boolean | |
Whether the menu should close when the menu item is selected. | ||
onAction | | |
Handler that is called when the item is selected. | ||
onHoverStart | | |
Handler that is called when a hover interaction starts. | ||
onHoverEnd | | |
Handler that is called when a hover interaction ends. | ||
onHoverChange | | |
Handler that is called when the hover state changes. | ||
onFocus | | |
Handler that is called when the element receives focus. | ||
onBlur | | |
Handler that is called when the element loses focus. | ||
onFocusChange | | |
Handler that is called when the element's focus status changes. | ||
onPress | | |
Handler that is called when the press is released over the target. | ||
onPressStart | | |
Handler that is called when a press interaction starts. | ||
onPressEnd | | |
Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target. | ||
onPressChange | | |
Handler that is called when the press state changes. | ||
onPressUp | | |
Handler that is called when a press is released over the target, regardless of whether it started on the target or not. | ||
aria-label | string | |
An accessibility label for this item. | ||
PromptFieldVoiceButton
PromptFieldVoiceButton triggers voice input for the PromptField.
| Name | Type | |
|---|---|---|
lang | string | |
isDisabled | boolean | |
onError | | |
onToggle | | |
PromptFieldSubmitButton
PromptFieldSubmitButton submits the PromptField.
PixelLoader
| Name | Type | Default |
|---|---|---|
size | number | Default: — |
Size of the loader in pixels. Multiples of 7 render evenly on the pixel grid. | ||
isPlaying | boolean | Default: — |
Whether the animation is playing. | ||
icon | Cell | Default: — |
The icon or sequence of icons to display. These should be imported from '@react-spectrum/ai/loader'. | ||
color | string | Default: 'currentColor'
|
The color of the icon. | ||
className | string | Default: — |
A custom CSS class to apply. | ||
AIButton
An AIButton triggers an AI-powered action.
| Name | Type | Default |
|---|---|---|
size | 'S'
| 'M'
| 'L'
| 'XL' | Default: 'M'
|
The size of the AIButton. | ||
children | string | Default: — |
The label to display in the AIButton. | ||
isDisabled | boolean | Default: — |
Whether the button is disabled. | ||
onPress | | Default: — |
Handler that is called when the press is released over the target. | ||
onPressStart | | Default: — |
Handler that is called when a press interaction starts. | ||
onPressEnd | | Default: — |
Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target. | ||
onPressChange | | Default: — |
Handler that is called when the press state changes. | ||
onPressUp | | Default: — |
Handler that is called when a press is released over the target, regardless of whether it started on the target or not. | ||
onFocus | | Default: — |
Handler that is called when the element receives focus. | ||
onBlur | | Default: — |
Handler that is called when the element loses focus. | ||
onFocusChange | | Default: — |
Handler that is called when the element's focus status changes. | ||
onKeyDown | | Default: — |
Handler that is called when a key is pressed. | ||
onKeyUp | | Default: — |
Handler that is called when a key is released. | ||
name | string | Default: — |
Submitted as a pair with the button's value as part of the form data. | ||
value | string | Default: — |
The value associated with the button's name when it's submitted with the form data. | ||
type | 'button'
| 'submit'
| 'reset' | Default: 'button'
|
The behavior of the button when used in an HTML form. | ||
form | string | Default: — |
The | ||
formTarget | string | Default: — |
Overrides the target attribute of the button's form owner. | ||
formNoValidate | boolean | Default: — |
Indicates that the form is not to be validated when it is submitted. | ||
formMethod | string | Default: — |
Indicates the HTTP method used to submit the form. | ||
formEncType | string | Default: — |
Indicates how to encode the form data that is submitted. | ||
formAction | ButtonHTMLAttributes | Default: — |
The URL that processes the information submitted by the button. Overrides the action attribute of the button's form owner. | ||
autoFocus | boolean | Default: — |
Whether the element should receive focus on render. | ||
id | string | Default: — |
The element's unique identifier. See MDN. | ||
excludeFromTabOrder | boolean | Default: — |
Whether to exclude the element from the sequential tab order. If true, the element will not be focusable via the keyboard by tabbing. This should be avoided except in rare scenarios where an alternative means of accessing the element or its functionality via the keyboard is available. | ||
preventFocusOnPress | boolean | Default: — |
Whether to prevent focus from moving to the button when pressing it. Caution, this can make the button inaccessible and should only be used when alternative keyboard interaction is provided, such as ComboBox's MenuTrigger or a NumberField's increment/decrement control. | ||
aria-disabled | boolean
| 'true'
| 'false' | Default: — |
Indicates whether the element is disabled to users of assistive technology. | ||
aria-expanded | boolean
| 'true'
| 'false' | Default: — |
Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed. | ||
aria-haspopup | boolean
| 'menu'
| 'listbox'
| 'tree'
| 'grid'
| 'dialog'
| 'true'
| 'false' | Default: — |
Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. | ||
aria-controls | string | Default: — |
Identifies the element (or elements) whose contents or presence are controlled by the current element. | ||
aria-pressed | boolean
| 'true'
| 'false'
| 'mixed' | Default: — |
Indicates the current "pressed" state of toggle buttons. | ||
aria-current | boolean
| 'true'
| 'false'
| 'page'
| 'step'
| 'location'
| 'date'
| 'time' | Default: — |
Indicates whether this element represents the current item within a container or set of related elements. | ||
aria-label | string | Default: — |
Defines a string value that labels the current element. | ||
aria-labelledby | string | Default: — |
Identifies the element (or elements) that labels the current element. | ||
aria-describedby | string | Default: — |
Identifies the element (or elements) that describes the object. | ||
aria-details | string | Default: — |
Identifies the element (or elements) that provide a detailed, extended description for the object. | ||
slot | string | null | Default: — |
A slot name for the component. Slots allow the component to receive props from a parent
component. An explicit | ||