Ai Response

PreviousNext

A ai-response item.

Docs
mui-treasuryitem

Preview

Loading preview…
components/ai-response/ai-response.tsx
"use client";

import Box from "@mui/material/Box";
import type { SxProps, Theme } from "@mui/material/styles";
import { type ComponentProps, memo } from "react";
import { Streamdown } from "streamdown";

type ResponseProps = ComponentProps<typeof Streamdown> & {
  sx?: SxProps<Theme>;
};

export const Response = memo(
  ({ sx, ...props }: ResponseProps) => (
    <Box
      sx={{
        width: "100%",
        height: "100%",
        "& > *:first-child": {
          mt: 0,
        },
        "& > *:last-child": {
          mb: 0,
        },
        '& [data-streamdown="ordered-list"], & [data-streamdown="unordered-list"]':
          {
            pl: 2,
          },
        ...sx,
      }}
    >
      <Streamdown {...props} />
    </Box>
  ),
  (prevProps, nextProps) => prevProps.children === nextProps.children,
);

Response.displayName = "Response";

Installation

npx shadcn@latest add @mui-treasury/ai-response

Usage

import { AiResponse } from "@/components/ai-response"
<AiResponse />