You
What can I build?
brief.mdPractical compositions. Copy the full TSX example into your app and connect it to your own data.
Pair an accessible field with a native checkbox and form actions.
'use client';
import Button from '@precursor/button';
import Checkbox from '@precursor/checkbox';
import Heading from '@precursor/heading';
import Inline from '@precursor/inline';
import Input from '@precursor/input';
import Label from '@precursor/label';
import Panel from '@precursor/panel';
import Stack from '@precursor/stack';
import { useId, useState } from 'react';
export default function SettingsPanel() {
const email = useId();
const [saved, setSaved] = useState(false);
return (
<Panel>
<form
onSubmit={(event) => {
event.preventDefault();
setSaved(true);
}}
onReset={() => setSaved(false)}
>
<Stack gap="s">
<Heading as="h2" size="h4">
Notification settings
</Heading>
<Stack gap="xxs">
<Label htmlFor={email}>Email address</Label>
<Input
id={email}
name="email"
type="email"
defaultValue="team@example.test"
/>
</Stack>
<Checkbox
name="releases"
label="Send release updates"
defaultChecked
/>
<Inline as="div" gap="xs">
<Button type="submit" primary>
Save settings
</Button>
<Button type="reset">Reset</Button>
</Inline>
<output>
{saved ? 'Settings saved for this preview.' : ''}
</output>
</Stack>
</form>
</Panel>
);
}
Summarize progress and slot a status into a release header.
Uses source preview packages: @precursor/progress.
Two of three checks passed.
import Heading from '@precursor/heading';
import Inline from '@precursor/inline';
import Lozenge from '@precursor/lozenge';
import Panel from '@precursor/panel';
import { Progress } from '@precursor/progress';
import Stack from '@precursor/stack';
import Text from '@precursor/text';
export default function ReleaseReview() {
return (
<Panel>
<Stack gap="s">
<Inline as="div" gap="xs">
<Heading as="h2" size="h4">
Release review
</Heading>
<span style={{ alignSelf: 'center' }}>
<Lozenge status="warning">In progress</Lozenge>
</span>
</Inline>
<Text>Two of three checks passed.</Text>
<Progress label="Release checks" value={2} max={3} />
</Stack>
</Panel>
);
}
Put a conversational prompt, transcript, and response field together.
Uses source preview packages: @precursor/chat.
'use client';
import { useId, useState } from 'react';
import {
Attachment,
ChatBubble,
ChatComposer,
ChatComposerActions,
ChatMessage,
ChatMessageAuthor,
ChatThread,
Citation,
ReasoningSummary,
Trace,
TraceStep,
} from '@precursor/chat';
import Button from '@precursor/button';
import Stack from '@precursor/stack';
import TextArea from '@precursor/textarea';
export default function Example() {
const id = useId();
const [draft, setDraft] = useState('');
const [messages, setMessages] = useState<string[]>([]);
return (
<Stack gap="s">
<ChatThread>
<ChatMessage variant="user">
<ChatMessageAuthor>You</ChatMessageAuthor>
<ChatBubble variant="accent">What can I build?</ChatBubble>
<Attachment>brief.md</Attachment>
</ChatMessage>
<ChatMessage>
<ChatMessageAuthor>Assistant</ChatMessageAuthor>
<ChatBubble>
Start with a theme and a few primitives.{' '}
<Citation href="https://danieldelcore.github.io/precursor/docs/foundations/">
Foundations
</Citation>
</ChatBubble>
<ReasoningSummary>
Selected examples from the foundations guide.
</ReasoningSummary>
<Trace>
<TraceStep
label="Read guide"
status="complete"
duration="0.2 s"
>
Found layout and theming examples.
</TraceStep>
</Trace>
</ChatMessage>
{messages.map((message, index) => (
<ChatMessage key={index} variant="user">
<ChatMessageAuthor>You</ChatMessageAuthor>
<ChatBubble variant="accent">{message}</ChatBubble>
</ChatMessage>
))}
</ChatThread>
<ChatComposer
onSubmit={() => {
if (draft.trim()) {
setMessages([...messages, draft.trim()]);
setDraft('');
}
}}
>
<label htmlFor={id}>Message</label>
<TextArea
id={id}
name="message"
value={draft}
onChange={(event) => setDraft(event.currentTarget.value)}
size="s"
/>
<ChatComposerActions>
<Button primary type="submit" disabled={!draft.trim()}>
Send
</Button>
</ChatComposerActions>
</ChatComposer>
</Stack>
);
}