mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
## Problem The Button guidance explains split buttons but doesn't show how to group a visible action with other actions for the same item or section. ## Solution Document when to use each pattern: - **Split button:** the main button runs the most common variation of an action. The attached chevron opens alternatives, such as other export formats. - **Dropdown button:** the whole button opens a menu, such as a time-range picker. - **Button with more actions:** keep the main action visible and use a separate ellipsis menu for distinct actions. The examples show both a primary “Add pipeline” button and a default “Stop” button. Align the Admonition split-button example with the same guidance. ## Review instructions 1. Open the [Button guidance preview](https://design-system-git-dnywh-docs-related-split-buttons-supabase.vercel.app/design-system/docs/components/button#split-with-dropdown) and compare the attached export chevron with the single time-range dropdown. 2. Open each ellipsis in [Button with more actions](https://design-system-git-dnywh-docs-related-split-buttons-supabase.vercel.app/design-system/docs/components/button#button-with-more-actions). Check that the “Add pipeline” menu groups usage and settings separately from “Disable Pipelines”, and that the “Stop” menu separates restart from edit and delete.
128 lines
4.5 KiB
Plaintext
128 lines
4.5 KiB
Plaintext
---
|
||
title: Admonition
|
||
description: Displays a callout for user attention.
|
||
fragment: true
|
||
---
|
||
|
||
Admonition provides the standard product callout pattern for situations that require user attention.
|
||
|
||
<ComponentPreview
|
||
name="admonition-demo"
|
||
className="[&_.preview>[data-orientation=vertical]]:sm:max-w-[70%]"
|
||
peekCode
|
||
wide
|
||
/>
|
||
|
||
Use Admonition instead of the low-level [Alert](../components/alert) primitive unless you specifically need custom composition. If in doubt, stick with Admonition.
|
||
|
||
Use [Collapsible](../components/collapsible) for custom expandable content. Use [DialogDisclosure](../components/dialog#optional-details) for optional details in a dialog.
|
||
|
||
Use `title` for the heading slot when the callout needs its own heading. `title` is optional: short callouts may use `description` without a title when nearby content already provides enough context.
|
||
|
||
Avoid title-only Admonitions in new code. A callout with `title` should also include `description` or `children` so it does not read like an incomplete heading.
|
||
|
||
## Usage
|
||
|
||
```tsx
|
||
import { Admonition } from 'ui-patterns/Admonition'
|
||
```
|
||
|
||
```tsx
|
||
<Admonition
|
||
type="default"
|
||
title="Is it accessible?"
|
||
description="Yes. It adheres to the WAI-ARIA design pattern."
|
||
/>
|
||
```
|
||
|
||
### Buttons
|
||
|
||
Style the color of the button based upon the _context_ of the Admonition, not its inherited `type`. For example, the below `warning` Admonition has an encouraged action, so its button has `type="default"`. The `destructive` Admonition has a button that is destructive, so the button has `type="danger"`.
|
||
|
||
<ComponentPreview
|
||
name="admonition-button"
|
||
className="[&_.preview>[data-orientation=vertical]]:sm:max-w-[70%]"
|
||
/>
|
||
|
||
Only ever use the `primary` (green) button `type` on a `default` Admonition. Even then—given that Admonition is an isolated callout—the `primary` button `type` should rarely be used.
|
||
|
||
### Split button with dropdown
|
||
|
||
When a callout offers variations of the same action, use a [split button](../components/button#split-with-dropdown). For distinct actions, keep the visible button separate from the [more actions menu](../components/button#button-with-more-actions).
|
||
|
||
<ComponentPreview
|
||
name="admonition-button-split"
|
||
className="[&_.preview>[data-orientation=vertical]]:sm:max-w-[70%]"
|
||
peekCode
|
||
/>
|
||
|
||
In responsive Admonitions, add `w-full @lg:w-auto` to `SplitButtonGroup` and `flex-1 @lg:flex-none` to the primary action.
|
||
|
||
## Examples
|
||
|
||
<ComponentPreview
|
||
name="admonition-demo"
|
||
className="[&_.preview>[data-orientation=vertical]]:sm:max-w-[70%]"
|
||
/>
|
||
|
||
### Responsive
|
||
|
||
Resize your browser to see the button(s) change `layout` based on the Admonition’s width.
|
||
|
||
<ComponentPreview
|
||
name="admonition-responsive"
|
||
className="[&_.preview>[data-orientation=vertical]]:sm:max-w-[70%]"
|
||
/>
|
||
|
||
When `layout="responsive"`, the Alert root gets `@container` so the Admonition is the container-query context. The Admonition stays `vertical` when it’s narrow and switches to `horizontal` when its own width reaches the `@md` container breakpoint, independent of page width.
|
||
|
||
### Warning
|
||
|
||
<ComponentPreview
|
||
name="admonition-warning"
|
||
className="[&_.preview>[data-orientation=vertical]]:sm:max-w-[70%]"
|
||
/>
|
||
|
||
There are several components that wrap the `warning` Admonition type with reusable text or functionality. These include:
|
||
|
||
- AlertError
|
||
- NoPermission
|
||
|
||
AlertError for example rolls up consistent error handling and support contact methods.
|
||
|
||
### Description only
|
||
|
||
Use description-only Admonitions for short callouts that sit near a heading or form label with enough context.
|
||
|
||
<ComponentPreview
|
||
name="admonition-description-only"
|
||
className="[&_.preview>[data-orientation=vertical]]:sm:max-w-[70%]"
|
||
/>
|
||
|
||
### Success
|
||
|
||
Use `success` for positive, completed states where the user does not need to take corrective action.
|
||
|
||
<ComponentPreview
|
||
name="admonition-success"
|
||
className="[&_.preview>[data-orientation=vertical]]:sm:max-w-[70%]"
|
||
/>
|
||
|
||
### Destructive
|
||
|
||
<ComponentPreview
|
||
name="admonition-destructive"
|
||
className="[&_.preview>[data-orientation=vertical]]:sm:max-w-[70%]"
|
||
/>
|
||
|
||
### Sandwiched
|
||
|
||
Some [Card](../components/card) or [Dialog](../components/dialog) instances may need to include callout information in-between core content. Admonition can be used ‘full-bleed’ in these cases by removing borders and radii.
|
||
|
||
<ComponentPreview
|
||
name="admonition-sandwiched"
|
||
className="[&_.preview>[data-orientation=vertical]]:sm:max-w-[70%]"
|
||
/>
|
||
|
||
Depending on the context, you may want to reset borders on the Admonition itself rather than the surrounding elements. The above Admonition is `type` `"warning"` with stark yellow borders which we want to emphasize.
|