Skip to content

Commit

Permalink
docs: unstyled primitive components
Browse files Browse the repository at this point in the history
  • Loading branch information
veloii committed Oct 23, 2024
1 parent 24082c7 commit 08dbf99
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions docs/src/app/(docs)/concepts/theming/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -509,3 +509,51 @@ type UploadDropzoneProps = {
<d.CustomContent1 />
<d.CustomContent2 />
<d.CustomContent3 />


## Unstyled Primitive Components

These components allow you to bring your own styling solution while not having to implement any of the internals. They accept any normal HTML props and can be assigned specific HTML tags through the `as` prop.

### Setup

```ts {{ title: 'src/utils/uploadthing.ts' }}
import { generateUploadPrimitives } from "@uploadthing/react";
import type { OurFileRouter } from "~/server/uploadthing";
export const UT = generateUploadPrimitives<OurFileRouter>();
```

### Example of Dropzone

<Note>The `dropzone` parameter will only be defined from within children of the `Dropzone` component.</Note>

```jsx
<UT.Root endpoint="mockRoute">
<UT.Dropzone>
{({ dropzone, state }) => (
<div>
<p>Drag and drop</p>
<UT.Button as="button">
{state === "uploading" ? "Uploading" : "Upload file"}
</UT.Button>
<UT.AllowedContent
as="p"
style={{ fontSize: 12, width: "fit-content" }}
/>
</div>
)}
</UT.Dropzone>
</UT.Root>
```

### Example of Button

```jsx
<UT.Root endpoint="mockRoute">
<UT.Button>
{({ state }) => state === "uploading" ? "Uploading" : "Upload file"}
</UT.Button>
</UT.Root>
```

0 comments on commit 08dbf99

Please sign in to comment.