AttachmentButton
Render the round plus attachment trigger used by InputBar. Use onClick to open your picker action.
Getting Started
$pnpm add @sinups/ai-kit @mantine/core @mantine/hooks @tabler/icons-reactExamples
Default
Paperclip icon
Without handler
Source
The component source as it ships in the package. Useful as a reference, or as a starting point if you want to fork a piece.
input/AttachmentButton.tsx
import React, { memo } from 'react';
import { UnstyledButton } from '@mantine/core';
import { IconPaperclip, IconPlus } from '@tabler/icons-react';
import { cx } from '../utils/cx';
import classes from './AttachmentButton.module.css';
export type AttachmentButtonIcon = 'plus' | 'paperclip';
export interface AttachmentButtonProps {
onClick?: () => void;
/**
* Icon to render inside the button.
* - `'plus'` (default): a `+` glyph, matches the generic "add something" affordance.
* - `'paperclip'`: a paperclip glyph, matches the more literal "attach file" affordance.
* - Any ReactNode fully overrides the icon; built-in sizing and color apply only to presets.
*/
icon?: AttachmentButtonIcon | React.ReactNode;
className?: string;
style?: React.CSSProperties;
}
function isIconName(value: unknown): value is AttachmentButtonIcon {
return value === 'plus' || value === 'paperclip';
}
/** Round 28px "Attach" button rendered in the composer toolbar */
export const AttachmentButton = memo(function AttachmentButton({
onClick,
icon = 'plus',
className,
style,
}: AttachmentButtonProps) {
let iconNode: React.ReactNode;
if (isIconName(icon)) {
iconNode =
icon === 'paperclip' ? (
<IconPaperclip size={16} className={classes.icon} stroke={2} />
) : (
<IconPlus size={16} className={classes.icon} stroke={2} />
);
} else {
iconNode = icon;
}
return (
<UnstyledButton
onClick={onClick}
className={cx(classes.root, className)}
style={style}
aria-label="Attach"
>
{iconNode}
</UnstyledButton>
);
});
AttachmentButton.displayName = 'AttachmentButton';
API reference
Prop
Type
Required
onClick
() => void
No
icon
AttachmentButtonIcon | React.ReactNode
No
Icon to render inside the button. - `'plus'` (default): a `+` glyph, matches the generic "add something" affordance. - `'paperclip'`: a paperclip glyph, matches the more literal "attach file" affordance. - Any ReactNode fully overrides the icon; built-in sizing and color apply only to presets.
className
string
No
style
React.CSSProperties
No