Actions
The row of buttons that closes a form, a dialog or a step. It puts the main action last and, on phones, sets the buttons two by two so nothing scrolls sideways.
import { Actions } from '@sypnia/ui/react'
Closing a form
Cancel first, the main action last and at the end.
You can change it later.
Code
import { Actions, Button, Field, Input } from '@sypnia/ui/react';
// The main action goes last, at the end: where the eye and the thumb finish.
export default function EndOfForm() {
return (
<div className="sy-stack">
<Field label="Project name" hint="You can change it later."><Input defaultValue="Storefront" /></Field>
<Actions>
<Button>Cancel</Button>
<Button variant="primary">Create project</Button>
</Actions>
</div>
);
} Under a block of settings
align="start" lines the buttons up with the text above them.
Backups run every night at 02:00 and are kept for 7 days.
Code
import { Actions, Button } from '@sypnia/ui/react';
// In a settings page that reads top to bottom, the buttons follow the text and start where it starts.
export default function AtTheStart() {
return (
<div className="sy-stack">
<p className="sy-text--sm sy-text--soft">Backups run every night at 02:00 and are kept for 7 days.</p>
<Actions align="start">
<Button variant="primary">Back up now</Button>
<Button>Change schedule</Button>
</Actions>
</div>
);
} Three buttons
Look at it on a phone: two side by side, and the main action across the whole row.
Code
import { Actions, Button } from '@sypnia/ui/react';
// With an odd number, the main action takes the whole last row on a phone.
export default function ThreeSteps() {
return (
<Actions>
<Button variant="quiet">Skip this step</Button>
<Button icon="chevron-left">Back</Button>
<Button variant="primary" iconEnd="arrow-right">Match columns</Button>
</Actions>
);
} When to use it
Use it when
- A form, a dialog, a drawer or a step ends and the person decides: save or cancel, back or continue.
- Buttons under a block of settings: use
align="start"so they begin where the text begins.
Do not use it when
- The buttons act on one row of a table or one card: those go beside the thing, as icon buttons or a Menu.
- There is a single link to somewhere else: that is a Link, not a row of actions.
- You need more than three buttons: move the rare ones into a Menu.
For everyone
- The order on screen is the order of the Tab key: the safe choice first, the main action last.
- On phones the buttons sit two by two and each one is at least 44 px tall. An odd main action takes the full row.
- It adds no role of its own: the form or dialog around it is what gets announced.
Props
| Actions | Type | Default |
|---|---|---|
align | "start" | "end" | end |
className | string |