@neo4j-ndl/react
Version:
React implementation of Neo4j Design System
91 lines (70 loc) • 2.16 kB
Markdown
Import: `import { FileTag } from '@neo4j-ndl/react/ai'`
| Prop | Type | Required | Default | Description |
|------|------|----------|---------|-------------|
| `fileName` | `string` | ✅ | | The name of the file |
| `fileType` | `string` | ✅ | | The type of the file, e.g. 'pdf', 'docx', 'txt', etc. |
| `icon` | `ReactNode` | ✅ | | The icon that represents the file type |
| `isLoading` | `boolean` | | `false` | Whether the file tag is loading |
| `isRemovable` | `boolean` | | `false` | Whether the file tag is removable |
| `onClick` | `((e: MouseEvent<HTMLElement, MouseEvent>) => void)` | | | Callback function triggered either when the file tag is clicked, or when the remove button is clicked (if isRemovable is true) |
| `ref` | `any` | | | A ref to apply to the root element. |
## Examples
### Chat
```tsx
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
import { FileTag } from '@neo4j-ndl/react/ai';
import { DocumentIconOutline } from '@neo4j-ndl/react/icons';
const Component = () => {
return (
<FileTag
icon={<DocumentIconOutline />}
fileName="Science Fiction Bestsellers"
fileType="pdf"
/>
);
};
export default Component;
```
```tsx
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
import { FileTag } from '@neo4j-ndl/react/ai';
import { DocumentIconOutline } from '@neo4j-ndl/react/icons';
const Component = () => {
return (
<FileTag
isLoading={true}
icon={<DocumentIconOutline />}
fileName="Science Fiction Bestsellers"
fileType="pdf"
onClick={() => {
alert('remove file');
}}
/>
);
};
export default Component;
```
```tsx
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
import { FileTag } from '@neo4j-ndl/react/ai';
import { DocumentIconOutline } from '@neo4j-ndl/react/icons';
const Component = () => {
return (
<FileTag
icon={<DocumentIconOutline />}
fileName="Science Fiction Bestsellers"
fileType="pdf"
isRemovable={true}
onClick={() => {
alert('remove file');
}}
/>
);
};
export default Component;
```