# Tags

> Tenant tags with a kind, and a link from a tag to a subject. Over the app's tables it can use one link table per subject.

- Category: Work management
- Module: `tags`
- Modes: `managed`, `custom`
- Docs: https://bettersupabase.com/docs/blocks/tags
- Page: https://bettersupabase.com/blocks/tags

## Install

```bash
npx better-supabase add tags
```

The command also installs `updated-at`, `memberships`, `permissions`.

## Configure

Add the block to `better-supabase.config.ts`:

```ts
import { defineConfig } from "better-supabase/config";

export default defineConfig({
  blocks: {
    // Required by tags; add installs them too.
    "updated-at": {},
    memberships: {},
    permissions: {},
    // Modes: "managed", "custom". The default is "managed".
    tags: { mode: "managed" },
  },
});
```

## Client

The React hooks are the registry item `@better-supabase/use-tags` (`npx shadcn add @better-supabase/use-tags`). They return data and actions and render no UI. Source: https://github.com/ScaleDockHQ/better-supabase/blob/main/packages/registry/items/hooks/use-tags.ts

## Events

- `subject.tagged`
- `subject.untagged`
- `tag.created`
- `tag.deleted`
- `tag.updated`

## Related blocks

Requires: [memberships](https://bettersupabase.com/blocks/memberships.md), [permissions](https://bettersupabase.com/blocks/permissions.md)

Works with: [outbox](https://bettersupabase.com/blocks/outbox.md), [drive](https://bettersupabase.com/blocks/drive.md), [subjects](https://bettersupabase.com/blocks/subjects.md), [bulk-actions](https://bettersupabase.com/blocks/bulk-actions.md)

## Recipes

- [Tag input](https://bettersupabase.com/recipes/tag-input.md): A record's tags with suggestions, where typing a name adds a tag or creates it.
- [Record page](https://bettersupabase.com/recipes/record-page.md): One row as a page: its fields, the rows that reference it, and comments and tags once the table is a subject.
