Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

2.1 KB
Raw Blame
The Inset Box element is used to visually group content inside a container with a subtle inset background and optional border.

<%= embed OpPrimer::InsetBoxComponentPreview, :default %>

## Anatomy

The Inset Box is made up of:

1. The **container**, which provides consistent padding and background.
2. The **content slot**, which renders any inner content (text, forms, tables, etc.).
3. An optional **border**, which can be toggled off when not needed.

## Default rendering

- **Border:** enabled by default
- **Border radius:** 2
- **Background:** `:inset` (light grey)
- **Padding:** 3

<%= embed OpPrimer::InsetBoxComponentPreview, :default %>

## Customization

The Inset Box supports the following options:

- **Border** – can be disabled with `border: false`.
- **Other system arguments** – all `Primer::Box` arguments are passed through.

<%= embed OpPrimer::InsetBoxComponentPreview, :borderless %>

## Uses

Some places where we already use the Inset Box:

- in project forms (copy form, new project, source project select, template select)
- in `ProjectQueries::PublicFlagComponent`
- in meeting agenda items and outcomes

It is useful whenever content should stand out from the page background while staying lightweight.

If content needs more structure (e.g., with headers, actions, or multiple items), consider using the Border Box component instead.

## Best practices

**Do**

- Use the Inset Box to provide a consistent background for related content.
- Keep its usage lightweight and minimal for clarity.

**Don't**

- Don’t apply arbitrary custom background colors in CSS — use the component’s options.
- Don’t duplicate "grey box" styles manually; always use the Inset Box.
- Don’t use Inset Box if a more structured component (like Border Box) is better suited.

## Technical notes

<%= embed OpPrimer::InsetBoxComponentPreview, :playground, panels: %i[params source] %>

The Inset Box is implemented as a wrapper around `Primer::Box` with opinionated defaults for border, padding, border radius, and background. It passes through all other `system_arguments` to `Primer::Box`.