> ## Documentation Index
> Fetch the complete documentation index at: https://docs.attio.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Record widget

> Add a React widget to record pages in Attio

![](https://mintcdn.com/attio/2EyaTyByKNPeSVcd/images/text-widget.png?fit=max\&auto=format\&n=2EyaTyByKNPeSVcd\&q=85\&s=905d99548719a1fe3fa5ed50327194c4)

Add a record widget by creating an extension folder under `src/app/extensions/` whose `extension.tsx` default-exports a `defineExtension` call with `type: "record-widget"`. See [App structure](https://docs.attio.com/sdk/extensions/overview.md) for the discovery rules.

> [!NOTE]
>
> Before your record widget will appear on a record page, you will need to go to "Configure page",
> click on "Add Widget", and select your widget.

## Example

The widget component itself can live in a sibling file inside the extension folder:

```tsx src/app/extensions/company-arr/extension.tsx theme={"system"}
import React from "react"
import {Extensions, Widget} from "attio/client"

import {ArrWidgetContent} from "./arr-widget-content"

export default Extensions.defineExtension({
  type: "record-widget",
  id: "company-arr",
  label: "ARR",
  Widget: ({recordId}) => (
    <React.Suspense fallback={<Widget.Loading />}>
      <ArrWidgetContent recordId={recordId} />
    </React.Suspense>
  ),
  objects: "companies", // only show on company records
})
```

```tsx src/app/extensions/company-arr/arr-widget-content.tsx theme={"system"}
import React from "react"
import {Widget, Badge} from "attio/client"

import {useMyArrQuery} from "./use-my-arr-query"

export const ArrWidgetContent = ({recordId}: {recordId: string}) => {
  const {arr, delta} = useMyArrQuery(recordId) // may suspend!
  return (
    <Widget.TextWidget>
      <Widget.Title>ARR</Widget.Title>
      <Widget.Text.Primary>{arr}</Widget.Text.Primary>
      <Widget.Decoration>
        <Badge color={delta < 0 ? "red" : "green"}>{delta}</Badge>
      </Widget.Decoration>
    </Widget.TextWidget>
  )
}
```

> [!NOTE]
>
> The widget will always display your app's icon, which you set in the [Developer
> console](https://build.attio.com).

## Arguments

**type** `"record-widget"` *required*

Identifies this extension as a record widget.

**id** `string` *required*

The unique identifier for this widget.

It is only used internally; never shown to the user.

**label** `string` *required*

A human-readable label of the widget that will be shown to the user in the widget picker.

**color** `string`

The base hexadecimal color of the gradient displayed in the background of the widget.

**Widget** `(props: \{ recordId: string, object: ObjectSlug \}) =\> React.ReactNode` *required*

A React component that will render the widget.

It can suspend while loading data.

Must return one of the following components as the root element:

* [`Widget.Loading`](../components/widgets/loading)
* [`Widget.TextWidget`](../components/widgets/text-widget)

**objects** `ObjectSlug | Array\<ObjectSlug\> | (recordInfo) =\> boolean`

A single slug, an array of slugs, or a predicate to select which types of record the record
widget will apply to. The predicate receives `{attributes, object, isStandard}` for the record
and returns whether the widget should be shown.

Defaults to `undefined`, which will cause the widget to show on ***all*** types of records.

The built-in slugs are

* [`"companies"`](../../docs/standard-objects/standard-objects-companies)
* [`"people"`](../../docs/standard-objects/standard-objects-people)
* [`"deals"`](../../docs/standard-objects/standard-objects-deals)
* [`"users"`](../../docs/standard-objects/standard-objects-users)
* [`"workspaces"`](../../docs/standard-objects/standard-objects-workspaces)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.